summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-02-22 15:58:23 +0000
committerSadie Powell <sadie@witchery.services>2024-02-22 17:05:30 +0000
commitc4e9c0bf8548da1bf4fe2cfe5e7f5ab101b35e52 (patch)
treeedcb3b44b2c600aa40ebfb743fe7edfad4f06149 /modules
parent84ad85ee857e9a088bf2d5e3e5b1056d1bf52bf8 (diff)
If the IRCd sends a field limit then use it over that of the config.
Diffstat (limited to 'modules')
-rw-r--r--modules/botserv/bs_bot.cpp29
-rw-r--r--modules/chanserv/cs_seen.cpp4
-rw-r--r--modules/hostserv/hs_request.cpp8
-rw-r--r--modules/hostserv/hs_set.cpp8
-rw-r--r--modules/nickserv/nickserv.cpp2
-rw-r--r--modules/operserv/os_svs.cpp4
-rw-r--r--modules/protocol/hybrid.cpp2
-rw-r--r--modules/protocol/inspircd.cpp54
-rw-r--r--modules/protocol/ngircd.cpp16
-rw-r--r--modules/protocol/unrealircd.cpp2
10 files changed, 87 insertions, 42 deletions
diff --git a/modules/botserv/bs_bot.cpp b/modules/botserv/bs_bot.cpp
index 170e1073a..5571a82c9 100644
--- a/modules/botserv/bs_bot.cpp
+++ b/modules/botserv/bs_bot.cpp
@@ -28,23 +28,21 @@ private:
return;
}
- Configuration::Block *networkinfo = Config->GetBlock("networkinfo");
-
- if (nick.length() > networkinfo->Get<unsigned>("nicklen"))
+ if (nick.length() > IRCD->GetMaxNick())
{
- source.Reply(_("Bot nicks may only be %d characters long."), networkinfo->Get<unsigned>("nicklen"));
+ source.Reply(_("Bot nicks may only be %zu characters long."), IRCD->GetMaxNick());
return;
}
- if (user.length() > networkinfo->Get<unsigned>("userlen"))
+ if (user.length() > IRCD->GetMaxUser())
{
- source.Reply(_("Bot idents may only be %d characters long."), networkinfo->Get<unsigned>("userlen"));
+ source.Reply(_("Bot idents may only be %zu characters long."), IRCD->GetMaxUser());
return;
}
- if (host.length() > networkinfo->Get<unsigned>("hostlen"))
+ if (host.length() > IRCD->GetMaxHost())
{
- source.Reply(_("Bot hosts may only be %d characters long."), networkinfo->Get<unsigned>("hostlen"));
+ source.Reply(_("Bot hosts may only be %zu characters long."), IRCD->GetMaxHost());
return;
}
@@ -120,23 +118,22 @@ private:
return;
}
- Configuration::Block *networkinfo = Config->GetBlock("networkinfo");
-
- if (nick.length() > networkinfo->Get<unsigned>("nicklen"))
+ if (nick.length() > IRCD->GetMaxNick())
{
- source.Reply(_("Bot nicks may only be %d characters long."), networkinfo->Get<unsigned>("nicklen"));
+ source.Reply(_("Bot nicks may only be %zu characters long."), IRCD->GetMaxNick());
return;
}
- if (user.length() > networkinfo->Get<unsigned>("userlen"))
+ if (user.length() > IRCD->GetMaxUser())
{
- source.Reply(_("Bot idents may only be %d characters long."), networkinfo->Get<unsigned>("userlen"));
+ source.Reply(_("Bot idents may only be %zu characters long."), IRCD->GetMaxUser());
return;
}
- if (host.length() > networkinfo->Get<unsigned>("hostlen"))
+ if (host.length() > IRCD->GetMaxHost())
{
- source.Reply(_("Bot hosts may only be %d characters long."), networkinfo->Get<unsigned>("hostlen"));
+ source.Reply(_("Bot hosts may only be %zu characters long."), IRCD->GetMaxHost()
+ );
return;
}
diff --git a/modules/chanserv/cs_seen.cpp b/modules/chanserv/cs_seen.cpp
index 99f44e9fd..6f4119e2f 100644
--- a/modules/chanserv/cs_seen.cpp
+++ b/modules/chanserv/cs_seen.cpp
@@ -270,9 +270,9 @@ public:
if (simple)
return this->SimpleSeen(source, params);
- if (target.length() > Config->GetBlock("networkinfo")->Get<unsigned>("nicklen"))
+ if (target.length() > IRCD->GetMaxNick())
{
- source.Reply(_("Nick too long, max length is %u characters."), Config->GetBlock("networkinfo")->Get<unsigned>("nicklen"));
+ source.Reply(_("Nick too long, max length is %zu characters."), IRCD->GetMaxNick());
return;
}
diff --git a/modules/hostserv/hs_request.cpp b/modules/hostserv/hs_request.cpp
index 25f089647..44612ada0 100644
--- a/modules/hostserv/hs_request.cpp
+++ b/modules/hostserv/hs_request.cpp
@@ -124,9 +124,9 @@ public:
if (!user.empty())
{
- if (user.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
+ if (user.length() > IRCD->GetMaxUser())
{
- source.Reply(HOST_SET_IDENTTOOLONG, Config->GetBlock("networkinfo")->Get<unsigned>("userlen"));
+ source.Reply(HOST_SET_IDENTTOOLONG, IRCD->GetMaxUser());
return;
}
else if (!IRCD->CanSetVIdent)
@@ -144,9 +144,9 @@ public:
}
}
- if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"))
+ if (host.length() > IRCD->GetMaxHost())
{
- source.Reply(HOST_SET_TOOLONG, Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"));
+ source.Reply(HOST_SET_TOOLONG, IRCD->GetMaxHost());
return;
}
diff --git a/modules/hostserv/hs_set.cpp b/modules/hostserv/hs_set.cpp
index e35f4d3b9..f923057c2 100644
--- a/modules/hostserv/hs_set.cpp
+++ b/modules/hostserv/hs_set.cpp
@@ -71,9 +71,9 @@ public:
}
}
- if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"))
+ if (host.length() > IRCD->GetMaxHost())
{
- source.Reply(HOST_SET_TOOLONG, Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"));
+ source.Reply(HOST_SET_TOOLONG, IRCD->GetMaxHost());
return;
}
@@ -177,9 +177,9 @@ public:
}
}
- if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"))
+ if (host.length() > IRCD->GetMaxHost())
{
- source.Reply(HOST_SET_TOOLONG, Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"));
+ source.Reply(HOST_SET_TOOLONG, IRCD->GetMaxHost());
return;
}
diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp
index 2706ea23e..673400e92 100644
--- a/modules/nickserv/nickserv.cpp
+++ b/modules/nickserv/nickserv.cpp
@@ -251,7 +251,7 @@ public:
if (IRCD->CanSVSNick)
{
- unsigned nicklen = Config->GetBlock("networkinfo")->Get<unsigned>("nicklen");
+ unsigned nicklen = IRCD->GetMaxNick();
const Anope::string &guestprefix = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest");
Anope::string guestnick;
diff --git a/modules/operserv/os_svs.cpp b/modules/operserv/os_svs.cpp
index 3a1ba29b8..ee2131c17 100644
--- a/modules/operserv/os_svs.cpp
+++ b/modules/operserv/os_svs.cpp
@@ -34,10 +34,10 @@ public:
}
/* Truncate long nicknames to nicklen characters */
- unsigned nicklen = Config->GetBlock("networkinfo")->Get<unsigned>("nicklen");
+ size_t nicklen = IRCD->GetMaxNick();
if (newnick.length() > nicklen)
{
- source.Reply(_("Nick \002%s\002 was truncated to %u characters."), newnick.c_str(), nicklen);
+ source.Reply(_("Nick \002%s\002 was truncated to %zu characters."), newnick.c_str(), nicklen);
newnick = params[1].substr(0, nicklen);
}
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)