diff options
| author | 2021-04-11 14:53:44 +0100 | |
|---|---|---|
| committer | 2021-04-11 14:53:44 +0100 | |
| commit | 351d04e19ad9d759a0be3860051a1bb726796473 (patch) | |
| tree | ccce621c819d62c0931a0013beae86c1637530dc /src/modules | |
| parent | Replace interfacebase with deleted operator new. (diff) | |
| parent | Allow banning WebIRC users by their gateway name. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_cgiirc.cpp | 33 | ||||
| -rw-r--r-- | src/modules/m_check.cpp | 12 |
2 files changed, 26 insertions, 19 deletions
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 699669418..20020eee1 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -29,6 +29,7 @@ #include "inspircd.h" +#include "modules/extban.h" #include "modules/ssl.h" #include "modules/webirc.h" #include "modules/whois.h" @@ -202,12 +203,31 @@ class CommandHexIP : public SplitCommand } }; +class GatewayExtBan + : public ExtBan::MatchingBase +{ + public: + StringExtItem gateway; + + GatewayExtBan(Module* Creator) + : ExtBan::MatchingBase(Creator, "gateway", 'w') + , gateway(Creator, "cgiirc_gateway", ExtensionItem::EXT_USER, true) + { + } + + bool IsMatch(User* user, Channel* channel, const std::string& text) override + { + const std::string* gatewayname = gateway.Get(user); + return gatewayname ? InspIRCd::Match(*gatewayname, text) : false; + } +}; + class CommandWebIRC : public SplitCommand { public: std::vector<WebIRCHost> hosts; bool notify; - StringExtItem gateway; + GatewayExtBan extban; StringExtItem realhost; StringExtItem realip; UserCertificateAPI sslapi; @@ -215,7 +235,7 @@ class CommandWebIRC : public SplitCommand CommandWebIRC(Module* Creator) : SplitCommand(Creator, "WEBIRC", 4) - , gateway(Creator, "cgiirc_gateway", ExtensionItem::EXT_USER, true) + , extban(Creator) , realhost(Creator, "cgiirc_realhost", ExtensionItem::EXT_USER, true) , realip(Creator, "cgiirc_realip", ExtensionItem::EXT_USER, true) , sslapi(Creator) @@ -247,7 +267,7 @@ class CommandWebIRC : public SplitCommand } // The user matched a WebIRC block! - gateway.Set(user, parameters[1]); + extban.gateway.Set(user, parameters[1]); realhost.Set(user, user->GetRealHost()); realip.Set(user, user->GetIPString()); @@ -399,7 +419,7 @@ class ModuleCgiIRC // If the user is not connecting via a WebIRC gateway then they // cannot match this connect class. - const std::string* gateway = cmdwebirc.gateway.Get(user); + const std::string* gateway = cmdwebirc.extban.gateway.Get(user); if (!gateway) { ServerInstance->Logs.Log("CONNECTCLASS", LOG_DEBUG, "The %s connect class is not suitable as it requires a connection via a WebIRC gateway", @@ -514,16 +534,13 @@ class ModuleCgiIRC void OnWhois(Whois::Context& whois) override { - if (!whois.IsSelfWhois() && !whois.GetSource()->HasPrivPermission("users/auspex")) - return; - // If these fields are not set then the client is not using a gateway. const std::string* realhost = cmdwebirc.realhost.Get(whois.GetTarget()); const std::string* realip = cmdwebirc.realip.Get(whois.GetTarget()); if (!realhost || !realip) return; - const std::string* gateway = cmdwebirc.gateway.Get(whois.GetTarget()); + const std::string* gateway = cmdwebirc.extban.gateway.Get(whois.GetTarget()); if (gateway) whois.SendLine(RPL_WHOISGATEWAY, *realhost, *realip, "is connected via the " + *gateway + " WebIRC gateway"); else diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index d0b2d1fdb..cbb65264a 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -168,7 +168,6 @@ class CommandCheck : public Command User *targuser; Channel *targchan; - std::string chliststr; targuser = ServerInstance->Users.Find(parameters[0]); targchan = ServerInstance->FindChan(parameters[0]); @@ -236,16 +235,7 @@ class CommandCheck : public Command CheckContext::List chanlist(context, "onchans"); for (const auto* memb : targuser->chans) - { - Channel* c = memb->chan; - char prefix = memb->GetPrefixChar(); - if (prefix) - chliststr.push_back(prefix); - chliststr.append(c->name); - chanlist.Add(chliststr); - chliststr.clear(); - } - + chanlist.Add(memb->GetAllPrefixChars() + memb->chan->name); chanlist.Flush(); context.DumpExt(targuser); |
