diff options
| author | Sadie Powell <sadie@witchery.services> | 2024-02-22 15:58:23 +0000 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2024-02-22 17:05:30 +0000 |
| commit | c4e9c0bf8548da1bf4fe2cfe5e7f5ab101b35e52 (patch) | |
| tree | edcb3b44b2c600aa40ebfb743fe7edfad4f06149 /modules/protocol | |
| parent | 84ad85ee857e9a088bf2d5e3e5b1056d1bf52bf8 (diff) | |
If the IRCd sends a field limit then use it over that of the config.
Diffstat (limited to 'modules/protocol')
| -rw-r--r-- | modules/protocol/hybrid.cpp | 2 | ||||
| -rw-r--r-- | modules/protocol/inspircd.cpp | 54 | ||||
| -rw-r--r-- | modules/protocol/ngircd.cpp | 16 | ||||
| -rw-r--r-- | modules/protocol/unrealircd.cpp | 2 |
4 files changed, 61 insertions, 13 deletions
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index fa095f485..3e19daf1a 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -280,7 +280,7 @@ public: bool IsIdentValid(const Anope::string &ident) override { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + if (ident.empty() || ident.length() > IRCD->GetMaxUser()) return false; /* diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index b72f06f49..4702fac25 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -26,6 +26,8 @@ static std::list<SASLUser> saslusers; static Anope::string rsquit_server, rsquit_id; +static size_t maxchannel = 0, maxhost = 0, maxnick = 0, maxuser = 0; + static void ParseModule(const Anope::string &module, Anope::string &modname, Anope::string &moddata) { size_t sep = module.find('='); @@ -102,6 +104,16 @@ public: MaxLine = 4096; } + size_t GetMaxChannel() override + { + return maxchannel ? maxchannel : IRCDProto::GetMaxChannel(); + } + + size_t GetMaxHost() override + { + return maxhost ? maxhost : IRCDProto::GetMaxHost(); + } + unsigned GetMaxListFor(Channel *c, ChannelMode *cm) override { ListLimits *limits = maxlist.Get(c); @@ -116,6 +128,16 @@ public: return IRCDProto::GetMaxListFor(c, cm); } + size_t GetMaxNick() override + { + return maxnick ? maxnick : IRCDProto::GetMaxNick(); + } + + size_t GetMaxUser() override + { + return maxuser ? maxuser : IRCDProto::GetMaxUser(); + } + void SendConnect() override { Uplink::Send("CAPAB", "START", 1205); @@ -526,7 +548,7 @@ public: bool IsIdentValid(const Anope::string &ident) override { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + if (ident.empty() || ident.length() > IRCD->GetMaxUser()) return false; for (auto c : ident) @@ -1212,13 +1234,33 @@ struct IRCDMessageCapab final Anope::string capab; while (ssep.GetToken(capab)) { - if (capab.find("MAXMODES=") != Anope::string::npos) + if (capab == "GLOBOPS=1") + Servers::Capab.insert("GLOBOPS"); + else if (capab.find("CHANMAX=") != Anope::string::npos) { - Anope::string maxmodes(capab.begin() + 9, capab.end()); - IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; + Anope::string value(capab.begin() + 8, capab.end()); + maxchannel = value.is_pos_number_only() ? convertTo<unsigned>(value) : 0; + } + else if (capab.find("IDENTMAX=") != Anope::string::npos) + { + Anope::string value(capab.begin() + 9, capab.end()); + maxuser = value.is_pos_number_only() ? convertTo<unsigned>(value) : 0; + } + else if (capab.find("MAXMODES=") != Anope::string::npos) + { + Anope::string value(capab.begin() + 9, capab.end()); + IRCD->MaxModes = value.is_pos_number_only() ? convertTo<unsigned>(value) : 3; + } + else if (capab.find("MAXHOST=") != Anope::string::npos) + { + Anope::string value(capab.begin() + 8, capab.end()); + maxhost = value.is_pos_number_only() ? convertTo<unsigned>(value) : 0; + } + else if (capab.find("NICKMAX=") != Anope::string::npos) + { + Anope::string value(capab.begin() + 8, capab.end()); + maxnick = value.is_pos_number_only() ? convertTo<unsigned>(value) : 0; } - else if (capab == "GLOBOPS=1") - Servers::Capab.insert("GLOBOPS"); } } else if (params[0].equals_cs("END")) diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 6dfb91b6c..3c80fecc6 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -11,6 +11,11 @@ #include "module.h" +namespace +{ + size_t nicklen = 0; +} + class ngIRCdProto final : public IRCDProto { @@ -31,6 +36,11 @@ public: MaxModes = 5; } + size_t GetMaxNick() override + { + return nicklen ? nicklen : IRCDProto::GetMaxNick(); + } + void SendAkill(User *u, XLine *x) override { // Calculate the time left before this would expire @@ -172,11 +182,7 @@ struct IRCDMessage005 final } else if (parameter == "NICKLEN") { - unsigned newlen = convertTo<unsigned>(data), len = Config->GetBlock("networkinfo")->Get<unsigned>("nicklen"); - if (len != newlen) - { - Log() << "Warning: NICKLEN is " << newlen << " but networkinfo:nicklen is " << len; - } + nicklen = data.is_pos_number_only() ? convertTo<size_t>(data) : 0; } } } diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp index 24a61fca3..22c1d4734 100644 --- a/modules/protocol/unrealircd.cpp +++ b/modules/protocol/unrealircd.cpp @@ -422,7 +422,7 @@ private: bool IsIdentValid(const Anope::string &ident) override { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + if (ident.empty() || ident.length() > IRCD->GetMaxUser()) return false; for (auto c : ident) |
