From 64340dc50901f88336d9a2933dad98b462b6f36b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 14 Dec 2021 15:48:57 +0000 Subject: Sync uniqueusername from the connect class to the user. This is a massive hack for now but should be made to sync properly in v4 when we have extensibles that don't suck. --- src/users.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 6d8766082..fc66cf70c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -84,6 +84,7 @@ User::User(const std::string& uid, Server* srv, UserType type) , server(srv) , registered(REG_NONE) , quitting(false) + , uniqueusername(false) , usertype(type) { client_sa.sa.sa_family = AF_UNSPEC; @@ -555,6 +556,7 @@ void LocalUser::CheckClass(bool clone_count) } this->nextping = ServerInstance->Time() + a->GetPingTime(); + this->uniqueusername = a->uniqueusername; } bool LocalUser::CheckLines(bool doZline) -- cgit v1.3.1-10-gc9f91 From 15a68932b6238cf52c3e86d1d029b0e65b8b755b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 14 Dec 2021 15:54:51 +0000 Subject: If a user has a unique username then include it in bans. --- include/users.h | 3 +++ src/coremods/core_xline/cmd_eline.cpp | 4 ++-- src/coremods/core_xline/cmd_gline.cpp | 4 ++-- src/coremods/core_xline/cmd_kline.cpp | 4 ++-- src/modules/m_anticaps.cpp | 5 +++-- src/modules/m_clearchan.cpp | 2 +- src/modules/m_dnsbl.cpp | 12 ++++++------ src/modules/m_messageflood.cpp | 2 +- src/modules/m_repeat.cpp | 2 +- src/modules/m_shun.cpp | 2 +- src/users.cpp | 6 ++++++ 11 files changed, 28 insertions(+), 18 deletions(-) (limited to 'src/users.cpp') diff --git a/include/users.h b/include/users.h index 04225ba6e..0862c7dd3 100644 --- a/include/users.h +++ b/include/users.h @@ -379,6 +379,9 @@ class CoreExport User : public Extensible */ const std::string& GetHost(bool uncloak) const; + /** Retrieves the username which should be included in bans for this user. */ + const std::string& GetBanIdent() const; + /** Retrieves this user's displayed hostname. */ const std::string& GetDisplayedHost() const; diff --git a/src/coremods/core_xline/cmd_eline.cpp b/src/coremods/core_xline/cmd_eline.cpp index 3572a4069..13ed8a685 100644 --- a/src/coremods/core_xline/cmd_eline.cpp +++ b/src/coremods/core_xline/cmd_eline.cpp @@ -48,9 +48,9 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters) User* find = ServerInstance->FindNick(target); if ((find) && (find->registered == REG_ALL)) { - ih.first = "*"; + ih.first = find->GetBanIdent(); ih.second = find->GetIPString(); - target = std::string("*@") + find->GetIPString(); + target = ih.first + "@" + ih.second; } else ih = ServerInstance->XLines->IdentSplit(target); diff --git a/src/coremods/core_xline/cmd_gline.cpp b/src/coremods/core_xline/cmd_gline.cpp index dc4fd0986..16b7abbf4 100644 --- a/src/coremods/core_xline/cmd_gline.cpp +++ b/src/coremods/core_xline/cmd_gline.cpp @@ -49,9 +49,9 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters) User* find = ServerInstance->FindNick(target); if ((find) && (find->registered == REG_ALL)) { - ih.first = "*"; + ih.first = find->GetBanIdent(); ih.second = find->GetIPString(); - target = std::string("*@") + find->GetIPString(); + target = ih.first + "@" + ih.second; } else ih = ServerInstance->XLines->IdentSplit(target); diff --git a/src/coremods/core_xline/cmd_kline.cpp b/src/coremods/core_xline/cmd_kline.cpp index 84477fda4..62538e481 100644 --- a/src/coremods/core_xline/cmd_kline.cpp +++ b/src/coremods/core_xline/cmd_kline.cpp @@ -49,9 +49,9 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters) User* find = ServerInstance->FindNick(target); if ((find) && (find->registered == REG_ALL)) { - ih.first = "*"; + ih.first = find->GetBanIdent(); ih.second = find->GetIPString(); - target = std::string("*@") + find->GetIPString(); + target = ih.first + "@" + ih.second; } else ih = ServerInstance->XLines->IdentSplit(target); diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 7c59cc2ba..d41a4105b 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -165,8 +165,9 @@ class ModuleAntiCaps : public Module void CreateBan(Channel* channel, User* user, bool mute) { - std::string banmask(mute ? "m:" : ""); - banmask.append("*!*@"); + std::string banmask(mute ? "m:*!" : "*!"); + banmask.append(user->GetBanIdent()); + banmask.append("@"); banmask.append(user->GetDisplayedHost()); Modes::ChangeList changelist; diff --git a/src/modules/m_clearchan.cpp b/src/modules/m_clearchan.cpp index 592559afc..fba493960 100644 --- a/src/modules/m_clearchan.cpp +++ b/src/modules/m_clearchan.cpp @@ -118,7 +118,7 @@ class CommandClearChan : public Command XLine* xline; try { - mask = ((method[0] == 'Z') ? curr->GetIPString() : "*@" + curr->GetRealHost()); + mask = (method[0] == 'Z') ? curr->GetIPString() : (curr->GetBanIdent() + "@" + curr->GetRealHost()); xline = xlf->Generate(ServerInstance->Time(), 60*60, user->nick, reason, mask); } catch (ModuleException&) diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index dc43dda3f..6cfadff59 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -182,11 +182,11 @@ class DNSBLResolver : public DNS::Request case DNSBLConfEntry::I_KLINE: { KLine* kl = new KLine(ServerInstance->Time(), ConfEntry->duration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), - "*", them->GetIPString()); + them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(kl,NULL)) { - ServerInstance->SNO->WriteToSnoMask('x', "K-line added due to DNSBL match on *@%s to expire in %s (on %s): %s", - them->GetIPString().c_str(), InspIRCd::DurationString(kl->duration).c_str(), + ServerInstance->SNO->WriteToSnoMask('x', "K-line added due to DNSBL match on %s to expire in %s (on %s): %s", + kl->Displayable().c_str(), InspIRCd::DurationString(kl->duration).c_str(), InspIRCd::TimeString(kl->expiry).c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } @@ -200,11 +200,11 @@ class DNSBLResolver : public DNS::Request case DNSBLConfEntry::I_GLINE: { GLine* gl = new GLine(ServerInstance->Time(), ConfEntry->duration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), - "*", them->GetIPString()); + them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(gl,NULL)) { - ServerInstance->SNO->WriteToSnoMask('x', "G-line added due to DNSBL match on *@%s to expire in %s (on %s): %s", - them->GetIPString().c_str(), InspIRCd::DurationString(gl->duration).c_str(), + ServerInstance->SNO->WriteToSnoMask('x', "G-line added due to DNSBL match on %s to expire in %s (on %s): %s", + gl->Displayable().c_str(), InspIRCd::DurationString(gl->duration).c_str(), InspIRCd::TimeString(gl->expiry).c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 4c79318fc..5db1e1e9d 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -161,7 +161,7 @@ private: if (f->ban) { Modes::ChangeList changelist; - changelist.push_add(*banmode, "*!*@" + user->GetDisplayedHost()); + changelist.push_add(*banmode, "*!" + user->GetBanIdent() + "@" + user->GetDisplayedHost()); ServerInstance->Modes->Process(ServerInstance->FakeClient, dest, NULL, changelist); } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index c114d9396..c432ae57e 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -413,7 +413,7 @@ class RepeatModule : public Module if (settings->Action == ChannelSettings::ACT_BAN) { Modes::ChangeList changelist; - changelist.push_add(*banmode, "*!*@" + user->GetDisplayedHost()); + changelist.push_add(*banmode, "*!" + user->GetBanIdent() + "@" + user->GetDisplayedHost()); ServerInstance->Modes->Process(ServerInstance->FakeClient, chan, NULL, changelist); } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 671d21233..89e71e4ca 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -73,7 +73,7 @@ class CommandShun : public Command User *find = ServerInstance->FindNick(target); if ((find) && (find->registered == REG_ALL)) - target = std::string("*!*@") + find->GetIPString(); + target = "*!" + find->GetBanIdent() + "@" + find->GetIPString(); if (parameters.size() == 1) { diff --git a/src/users.cpp b/src/users.cpp index fc66cf70c..38e677226 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -722,6 +722,12 @@ const std::string& User::GetIPString() return cachedip; } +const std::string& User::GetBanIdent() const +{ + static const std::string wildcard = "*"; + return uniqueusername ? ident : wildcard; +} + const std::string& User::GetHost(bool uncloak) const { return uncloak ? GetRealHost() : GetDisplayedHost(); -- cgit v1.3.1-10-gc9f91