summaryrefslogtreecommitdiff
path: root/src
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 /src
parent84ad85ee857e9a088bf2d5e3e5b1056d1bf52bf8 (diff)
If the IRCd sends a field limit then use it over that of the config.
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp8
-rw-r--r--src/protocol.cpp34
2 files changed, 35 insertions, 7 deletions
diff --git a/src/config.cpp b/src/config.cpp
index c3e27d469..bcba9de38 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -178,10 +178,10 @@ Conf::Conf() : Block("")
ValidateNotZero("options", "readtimeout", options->Get<time_t>("readtimeout"));
ValidateNotZero("options", "warningtimeout", options->Get<time_t>("warningtimeout"));
- ValidateNotZero("networkinfo", "nicklen", networkinfo->Get<unsigned>("nicklen"));
- ValidateNotZero("networkinfo", "userlen", networkinfo->Get<unsigned>("userlen"));
- ValidateNotZero("networkinfo", "hostlen", networkinfo->Get<unsigned>("hostlen"));
- ValidateNotZero("networkinfo", "chanlen", networkinfo->Get<unsigned>("chanlen"));
+ ValidateNotZero("networkinfo", "nicklen", networkinfo->Get<unsigned>("nicklen", "1"));
+ ValidateNotZero("networkinfo", "userlen", networkinfo->Get<unsigned>("userlen", "1"));
+ ValidateNotZero("networkinfo", "hostlen", networkinfo->Get<unsigned>("hostlen", "1"));
+ ValidateNotZero("networkinfo", "chanlen", networkinfo->Get<unsigned>("chanlen", "1"));
spacesepstream(options->Get<const Anope::string>("ulineservers")).GetTokens(this->Ulines);
diff --git a/src/protocol.cpp b/src/protocol.cpp
index bf7d1bc28..06b654123 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -343,7 +343,7 @@ bool IRCDProto::IsNickValid(const Anope::string &nick)
bool IRCDProto::IsChannelValid(const Anope::string &chan)
{
- if (chan.empty() || chan[0] != '#' || chan.length() > Config->GetBlock("networkinfo")->Get<unsigned>("chanlen"))
+ if (chan.empty() || chan[0] != '#' || chan.length() > IRCD->GetMaxChannel())
return false;
if (chan.find_first_of(" ,") != Anope::string::npos)
@@ -354,7 +354,7 @@ bool IRCDProto::IsChannelValid(const Anope::string &chan)
bool IRCDProto::IsIdentValid(const Anope::string &ident)
{
- if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
+ if (ident.empty() || ident.length() > IRCD->GetMaxUser())
return false;
for (auto c : ident)
@@ -370,7 +370,7 @@ bool IRCDProto::IsIdentValid(const Anope::string &ident)
bool IRCDProto::IsHostValid(const Anope::string &host)
{
- if (host.empty() || host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"))
+ if (host.empty() || host.length() > IRCD->GetMaxHost())
return false;
const Anope::string &vhostdisablebe = Config->GetBlock("networkinfo")->Get<const Anope::string>("disallow_start_or_end"),
@@ -416,6 +416,34 @@ Anope::string IRCDProto::NormalizeMask(const Anope::string &mask)
return Entry("", mask).GetNUHMask();
}
+size_t IRCDProto::GetMaxChannel()
+{
+ // We can cache this as its not allowed to change on rehash.
+ static size_t chanlen = Config->GetBlock("networkinfo")->Get<unsigned>("chanlen", "32");
+ return chanlen;
+}
+
+size_t IRCDProto::GetMaxHost()
+{
+ // We can cache this as its not allowed to change on rehash.
+ static size_t hostlen = Config->GetBlock("networkinfo")->Get<unsigned>("hostlen", "64");
+ return hostlen;
+}
+
+size_t IRCDProto::GetMaxNick()
+{
+ // We can cache this as its not allowed to change on rehash.
+ static size_t nicklen = Config->GetBlock("networkinfo")->Get<unsigned>("nicklen", "31");
+ return nicklen;
+}
+
+size_t IRCDProto::GetMaxUser()
+{
+ // We can cache this as its not allowed to change on rehash.
+ static size_t userlen = Config->GetBlock("networkinfo")->Get<unsigned>("userlen", "10");
+ return userlen;
+}
+
MessageSource::MessageSource(const Anope::string &src) : source(src)
{
/* no source for incoming message is our uplink */