summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-12 12:22:57 +0000
committerSadie Powell <sadie@witchery.services>2024-03-12 12:24:02 +0000
commit06add0e5fc1b83b43014e731cb94229ab2be66f6 (patch)
tree16e08617a2e81a6bc8f44ab513e056a792bb07c2 /modules
parent63d682314b7eb3f6e25ecf4ba81dc3bb17270f0e (diff)
Simplify limit extraction code.
Diffstat (limited to 'modules')
-rw-r--r--modules/botserv/bs_bot.cpp24
-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.cpp2
-rw-r--r--modules/protocol/hybrid.cpp2
-rw-r--r--modules/protocol/inspircd.cpp49
-rw-r--r--modules/protocol/ngircd.cpp12
-rw-r--r--modules/protocol/unrealircd.cpp2
10 files changed, 36 insertions, 77 deletions
diff --git a/modules/botserv/bs_bot.cpp b/modules/botserv/bs_bot.cpp
index 5571a82c9..c50c94411 100644
--- a/modules/botserv/bs_bot.cpp
+++ b/modules/botserv/bs_bot.cpp
@@ -28,21 +28,21 @@ private:
return;
}
- if (nick.length() > IRCD->GetMaxNick())
+ if (nick.length() > IRCD->MaxNick)
{
- source.Reply(_("Bot nicks may only be %zu characters long."), IRCD->GetMaxNick());
+ source.Reply(_("Bot nicks may only be %zu characters long."), IRCD->MaxNick);
return;
}
- if (user.length() > IRCD->GetMaxUser())
+ if (user.length() > IRCD->MaxUser)
{
- source.Reply(_("Bot idents may only be %zu characters long."), IRCD->GetMaxUser());
+ source.Reply(_("Bot idents may only be %zu characters long."), IRCD->MaxUser);
return;
}
- if (host.length() > IRCD->GetMaxHost())
+ if (host.length() > IRCD->MaxHost)
{
- source.Reply(_("Bot hosts may only be %zu characters long."), IRCD->GetMaxHost());
+ source.Reply(_("Bot hosts may only be %zu characters long."), IRCD->MaxHost);
return;
}
@@ -118,21 +118,21 @@ private:
return;
}
- if (nick.length() > IRCD->GetMaxNick())
+ if (nick.length() > IRCD->MaxNick)
{
- source.Reply(_("Bot nicks may only be %zu characters long."), IRCD->GetMaxNick());
+ source.Reply(_("Bot nicks may only be %zu characters long."), IRCD->MaxNick);
return;
}
- if (user.length() > IRCD->GetMaxUser())
+ if (user.length() > IRCD->MaxUser)
{
- source.Reply(_("Bot idents may only be %zu characters long."), IRCD->GetMaxUser());
+ source.Reply(_("Bot idents may only be %zu characters long."), IRCD->MaxUser);
return;
}
- if (host.length() > IRCD->GetMaxHost())
+ if (host.length() > IRCD->MaxHost)
{
- source.Reply(_("Bot hosts may only be %zu characters long."), IRCD->GetMaxHost()
+ source.Reply(_("Bot hosts may only be %zu characters long."), IRCD->MaxHost
);
return;
}
diff --git a/modules/chanserv/cs_seen.cpp b/modules/chanserv/cs_seen.cpp
index 183cd5e05..1603983f5 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() > IRCD->GetMaxNick())
+ if (target.length() > IRCD->MaxNick)
{
- source.Reply(_("Nick too long, max length is %zu characters."), IRCD->GetMaxNick());
+ source.Reply(_("Nick too long, max length is %zu characters."), IRCD->MaxNick);
return;
}
diff --git a/modules/hostserv/hs_request.cpp b/modules/hostserv/hs_request.cpp
index d7bc6bc34..b53cd6fa9 100644
--- a/modules/hostserv/hs_request.cpp
+++ b/modules/hostserv/hs_request.cpp
@@ -122,9 +122,9 @@ public:
if (!user.empty())
{
- if (user.length() > IRCD->GetMaxUser())
+ if (user.length() > IRCD->MaxUser)
{
- source.Reply(HOST_SET_IDENTTOOLONG, IRCD->GetMaxUser());
+ source.Reply(HOST_SET_IDENTTOOLONG, IRCD->MaxUser);
return;
}
else if (!IRCD->CanSetVIdent)
@@ -142,9 +142,9 @@ public:
}
}
- if (host.length() > IRCD->GetMaxHost())
+ if (host.length() > IRCD->MaxHost)
{
- source.Reply(HOST_SET_TOOLONG, IRCD->GetMaxHost());
+ source.Reply(HOST_SET_TOOLONG, IRCD->MaxHost);
return;
}
diff --git a/modules/hostserv/hs_set.cpp b/modules/hostserv/hs_set.cpp
index 261e1e51f..16e4cebf9 100644
--- a/modules/hostserv/hs_set.cpp
+++ b/modules/hostserv/hs_set.cpp
@@ -71,9 +71,9 @@ public:
}
}
- if (host.length() > IRCD->GetMaxHost())
+ if (host.length() > IRCD->MaxHost)
{
- source.Reply(HOST_SET_TOOLONG, IRCD->GetMaxHost());
+ source.Reply(HOST_SET_TOOLONG, IRCD->MaxHost);
return;
}
@@ -174,9 +174,9 @@ public:
}
}
- if (host.length() > IRCD->GetMaxHost())
+ if (host.length() > IRCD->MaxHost)
{
- source.Reply(HOST_SET_TOOLONG, IRCD->GetMaxHost());
+ source.Reply(HOST_SET_TOOLONG, IRCD->MaxHost);
return;
}
diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp
index f1f087163..dee7a2303 100644
--- a/modules/nickserv/nickserv.cpp
+++ b/modules/nickserv/nickserv.cpp
@@ -238,7 +238,7 @@ public:
if (IRCD->CanSVSNick)
{
- unsigned nicklen = IRCD->GetMaxNick();
+ unsigned nicklen = IRCD->MaxNick;
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 ee2131c17..854fd4af2 100644
--- a/modules/operserv/os_svs.cpp
+++ b/modules/operserv/os_svs.cpp
@@ -34,7 +34,7 @@ public:
}
/* Truncate long nicknames to nicklen characters */
- size_t nicklen = IRCD->GetMaxNick();
+ size_t nicklen = IRCD->MaxNick;
if (newnick.length() > nicklen)
{
source.Reply(_("Nick \002%s\002 was truncated to %zu characters."), newnick.c_str(), nicklen);
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index 4d2ed2e82..b060c4f43 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() > IRCD->GetMaxUser())
+ if (ident.empty() || ident.length() > IRCD->MaxUser)
return false;
/*
diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp
index e0cf20b85..8ba398038 100644
--- a/modules/protocol/inspircd.cpp
+++ b/modules/protocol/inspircd.cpp
@@ -25,18 +25,6 @@ struct SASLUser final
namespace
{
- // The maximum length of a channel name.
- size_t maxchannel = 0;
-
- // The maximum length of a hostname.
- size_t maxhost = 0;
-
- // The maximum length of a nickname.
- size_t maxnick = 0;
-
- // The maximum length of a username.
- size_t maxuser = 0;
-
// The SID of a server we are waiting to squit.
Anope::string rsquit_id;
@@ -159,16 +147,6 @@ public:
MaxLine = 4096;
}
- size_t GetMaxChannel() override
- {
- return maxchannel ? maxchannel : IRCDProto::GetMaxChannel();
- }
-
- size_t GetMaxHost() override
- {
- return maxhost ? maxhost : IRCDProto::GetMaxHost();
- }
-
size_t GetMaxListFor(Channel *c, ChannelMode *cm) override
{
ListLimits *limits = maxlist.Get(c);
@@ -183,15 +161,6 @@ 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
{
@@ -650,7 +619,7 @@ public:
bool IsIdentValid(const Anope::string &ident) override
{
- if (ident.empty() || ident.length() > IRCD->GetMaxUser())
+ if (ident.empty() || ident.length() > IRCD->MaxUser)
return false;
for (auto c : ident)
@@ -1540,25 +1509,25 @@ struct IRCDMessageCapab final
{
auto [tokname, tokvalue] = ParseCapability(capab);
if (tokname == "MAXCHANNEL")
- maxchannel = tokvalue;
+ IRCD->MaxChannel = tokvalue;
else if (tokname == "MAXHOST")
- maxhost = tokvalue;
+ IRCD->MaxHost = tokvalue;
else if (tokname == "MAXMODES")
IRCD->MaxModes = tokvalue;
else if (tokname == "MAXNICK")
- maxnick = tokvalue;
+ IRCD->MaxNick = tokvalue;
else if (tokname == "MAXUSER")
- maxuser = tokvalue;
+ IRCD->MaxUser = tokvalue;
// Deprecated 1205 keys.
else if (tokname == "CHANMAX")
- maxchannel = tokvalue;
+ IRCD->MaxChannel = tokvalue;
else if (tokname == "GLOBOPS" && tokvalue)
Servers::Capab.insert("GLOBOPS");
else if (tokname == "IDENTMAX")
- maxuser = tokvalue;
+ IRCD->MaxUser = tokvalue;
else if (tokname == "NICKMAX")
- maxnick = tokvalue;
+ IRCD->MaxNick = tokvalue;
}
}
else if (params[0].equals_cs("END"))
@@ -1995,7 +1964,7 @@ struct IRCDMessageFJoin final
users.push_back(sju);
}
- auto ts = IRCD->ExtractTimestamp(params[0]);
+ auto ts = IRCD->ExtractTimestamp(params[1]);
Message::Join::SJoin(source, params[0], ts, modes, users);
}
};
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index ea9d92294..fc56d1055 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -12,11 +12,6 @@
#include "module.h"
#include "numeric.h"
-namespace
-{
- size_t nicklen = 0;
-}
-
class ngIRCdProto final
: public IRCDProto
{
@@ -37,11 +32,6 @@ 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
@@ -182,7 +172,7 @@ struct IRCDMessage005 final
}
else if (parameter == "NICKLEN")
{
- nicklen = Anope::Convert<size_t>(data, 0);
+ IRCD->MaxNick = Anope::Convert<size_t>(data, IRCD->MaxNick);
}
}
}
diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp
index a49adac56..195ad617c 100644
--- a/modules/protocol/unrealircd.cpp
+++ b/modules/protocol/unrealircd.cpp
@@ -423,7 +423,7 @@ private:
bool IsIdentValid(const Anope::string &ident) override
{
- if (ident.empty() || ident.length() > IRCD->GetMaxUser())
+ if (ident.empty() || ident.length() > IRCD->MaxUser)
return false;
for (auto c : ident)