From c4e9c0bf8548da1bf4fe2cfe5e7f5ab101b35e52 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 22 Feb 2024 15:58:23 +0000 Subject: If the IRCd sends a field limit then use it over that of the config. --- src/protocol.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/protocol.cpp') 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("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("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("hostlen")) + if (host.empty() || host.length() > IRCD->GetMaxHost()) return false; const Anope::string &vhostdisablebe = Config->GetBlock("networkinfo")->Get("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("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("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("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("userlen", "10"); + return userlen; +} + MessageSource::MessageSource(const Anope::string &src) : source(src) { /* no source for incoming message is our uplink */ -- cgit