mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Alts] Server-side search controls, IP counts, adjustable window
Plumbs the match-type chips through to the server: include_email/include_clientid/include_ip skip disabled identifier types in both matching and frontier expansion, so excluded types (e.g. throwaway domains) never enter the graph at any depth. Session lookback becomes adjustable (session_months, clamped 1-24, default 6). Each alt row carries ip_count, the distinct recent session IP count shown in a new IPs column. All proto additions are optional with old defaults, so old clients/servers interoperate.
This commit is contained in:
parent
2b7ddfd968
commit
b7f04bbb6e
7 changed files with 142 additions and 45 deletions
|
|
@ -42,14 +42,15 @@ constexpr int COL_ALTS_USER = 0;
|
|||
constexpr int COL_ALTS_VIA = 1;
|
||||
constexpr int COL_ALTS_DEPTH = 2;
|
||||
constexpr int COL_ALTS_SHARED = 3;
|
||||
constexpr int COL_ALTS_EMAIL = 4;
|
||||
constexpr int COL_ALTS_CLIENTID = 5;
|
||||
constexpr int COL_ALTS_REGISTERED = 6;
|
||||
constexpr int COL_ALTS_LAST_LOGIN = 7;
|
||||
constexpr int COL_ALTS_WARNS = 8;
|
||||
constexpr int COL_ALTS_BANS = 9;
|
||||
constexpr int COL_ALTS_ACTIVE = 10;
|
||||
constexpr int COL_ALTS_COUNT = 11;
|
||||
constexpr int COL_ALTS_IPS = 4;
|
||||
constexpr int COL_ALTS_EMAIL = 5;
|
||||
constexpr int COL_ALTS_CLIENTID = 6;
|
||||
constexpr int COL_ALTS_REGISTERED = 7;
|
||||
constexpr int COL_ALTS_LAST_LOGIN = 8;
|
||||
constexpr int COL_ALTS_WARNS = 9;
|
||||
constexpr int COL_ALTS_BANS = 10;
|
||||
constexpr int COL_ALTS_ACTIVE = 11;
|
||||
constexpr int COL_ALTS_COUNT = 12;
|
||||
|
||||
constexpr int COL_WARNS_TIME = 0;
|
||||
constexpr int COL_WARNS_MODERATOR = 1;
|
||||
|
|
@ -94,6 +95,7 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
depthSpin->setMinimum(1);
|
||||
depthSpin->setMaximum(MAX_ALT_DEPTH);
|
||||
depthSpin->setValue(1);
|
||||
connect(depthSpin, &QSpinBox::valueChanged, this, &TabAlts::onSearchFilterChanged);
|
||||
|
||||
investigateButton = new QPushButton;
|
||||
connect(investigateButton, &QPushButton::clicked, this, &TabAlts::investigateUser);
|
||||
|
|
@ -126,7 +128,7 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
auto *chip = new QPushButton(text);
|
||||
chip->setCheckable(true);
|
||||
chip->setChecked(true);
|
||||
connect(chip, &QPushButton::toggled, this, &TabAlts::onFilterChanged);
|
||||
connect(chip, &QPushButton::toggled, this, &TabAlts::onSearchFilterChanged);
|
||||
return chip;
|
||||
};
|
||||
emailChip = makeChip(QString());
|
||||
|
|
@ -137,7 +139,13 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
vpnSpin->setMinimum(1);
|
||||
vpnSpin->setMaximum(100000);
|
||||
vpnSpin->setValue(DEFAULT_VPN_THRESHOLD);
|
||||
connect(vpnSpin, &QSpinBox::valueChanged, this, &TabAlts::onFilterChanged);
|
||||
connect(vpnSpin, &QSpinBox::valueChanged, this, &TabAlts::onDisplayFilterChanged);
|
||||
windowLabel = new QLabel;
|
||||
monthsSpin = new QSpinBox;
|
||||
monthsSpin->setMinimum(1);
|
||||
monthsSpin->setMaximum(24);
|
||||
monthsSpin->setValue(6);
|
||||
connect(monthsSpin, &QSpinBox::valueChanged, this, &TabAlts::onSearchFilterChanged);
|
||||
|
||||
auto *filterBar = new QHBoxLayout;
|
||||
filterBar->addWidget(emailChip);
|
||||
|
|
@ -145,6 +153,8 @@ TabAlts::TabAlts(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
filterBar->addWidget(ipChip);
|
||||
filterBar->addWidget(vpnLabel);
|
||||
filterBar->addWidget(vpnSpin);
|
||||
filterBar->addWidget(windowLabel);
|
||||
filterBar->addWidget(monthsSpin);
|
||||
filterBar->addStretch();
|
||||
|
||||
altsTable = new QTableWidget(0, COL_ALTS_COUNT);
|
||||
|
|
@ -235,8 +245,11 @@ void TabAlts::retranslateUi()
|
|||
ipChip->setToolTip(tr("Show or hide IP address matches"));
|
||||
vpnLabel->setText(tr("Hide IPs shared by more than"));
|
||||
vpnSpin->setSuffix(tr(" users"));
|
||||
windowLabel->setText(tr("Session window"));
|
||||
monthsSpin->setSuffix(tr(" months"));
|
||||
monthsSpin->setToolTip(tr("How far back session IPs and client IDs are considered."));
|
||||
|
||||
altsTable->setHorizontalHeaderLabels({tr("User"), tr("Via"), tr("Depth"), tr("Shared"), tr("eMail"),
|
||||
altsTable->setHorizontalHeaderLabels({tr("User"), tr("Via"), tr("Depth"), tr("Shared"), tr("IPs"), tr("eMail"),
|
||||
tr("Client ID"), tr("Registered"), tr("Last login"), tr("Warns"), tr("Bans"),
|
||||
tr("Active")});
|
||||
altsTable->setToolTip(tr("Double-click or press Enter on a row to investigate that account"));
|
||||
|
|
@ -355,6 +368,10 @@ void TabAlts::requestAlts(const QString &userName, int depth)
|
|||
Command_GetUserAlts cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
cmd.set_depth(static_cast<google::protobuf::uint32>(depth));
|
||||
cmd.set_include_email(emailChip->isChecked());
|
||||
cmd.set_include_clientid(clientIdChip->isChecked());
|
||||
cmd.set_include_ip(ipChip->isChecked());
|
||||
cmd.set_session_months(static_cast<google::protobuf::uint32>(monthsSpin->value()));
|
||||
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
||||
connect(pend, &PendingCommand::finished, this, [this, userName](const Response &response) {
|
||||
if (userName == currentUser) {
|
||||
|
|
@ -456,6 +473,9 @@ void TabAlts::renderTable()
|
|||
altsTable->setItem(
|
||||
row, COL_ALTS_SHARED,
|
||||
new QTableWidgetItem(alt.has_shared_count() ? QString::number(alt.shared_count()) : QStringLiteral("-")));
|
||||
altsTable->setItem(
|
||||
row, COL_ALTS_IPS,
|
||||
new QTableWidgetItem(alt.has_ip_count() ? QString::number(alt.ip_count()) : QStringLiteral("-")));
|
||||
altsTable->setItem(row, COL_ALTS_EMAIL, new QTableWidgetItem(QString::fromStdString(alt.email())));
|
||||
altsTable->setItem(row, COL_ALTS_CLIENTID, new QTableWidgetItem(QString::fromStdString(alt.clientid())));
|
||||
altsTable->setItem(row, COL_ALTS_REGISTERED, new QTableWidgetItem(formatEpoch(alt.registration_time())));
|
||||
|
|
@ -513,7 +533,15 @@ void TabAlts::renderTable()
|
|||
}
|
||||
}
|
||||
|
||||
void TabAlts::onFilterChanged()
|
||||
void TabAlts::onSearchFilterChanged()
|
||||
{
|
||||
if (currentUser.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
investigateUser();
|
||||
}
|
||||
|
||||
void TabAlts::onDisplayFilterChanged()
|
||||
{
|
||||
if (lastAlts.isEmpty()) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue