diff options
author | Sadie Powell <sadie@witchery.services> | 2024-03-12 12:22:57 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-03-12 12:24:02 +0000 |
commit | 06add0e5fc1b83b43014e731cb94229ab2be66f6 (patch) | |
tree | 16e08617a2e81a6bc8f44ab513e056a792bb07c2 /src | |
parent | 63d682314b7eb3f6e25ecf4ba81dc3bb17270f0e (diff) |
Simplify limit extraction code.
Diffstat (limited to 'src')
-rw-r--r-- | src/protocol.cpp | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/src/protocol.cpp b/src/protocol.cpp index 55603c8e7..c1685eb27 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -25,6 +25,10 @@ IRCDProto *IRCD = NULL; IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator, "IRCDProto", creator->name) , proto_name(p) + , MaxChannel(Config->GetBlock("networkinfo")->Get<unsigned>("chanlen", "32")) + , MaxHost(Config->GetBlock("networkinfo")->Get<unsigned>("hostlen", "64")) + , MaxNick(Config->GetBlock("networkinfo")->Get<unsigned>("nicklen", "31")) + , MaxUser(Config->GetBlock("networkinfo")->Get<unsigned>("userlen", "10")) { if (IRCD == NULL) IRCD = this; @@ -296,7 +300,7 @@ bool IRCDProto::IsNickValid(const Anope::string &nick) bool IRCDProto::IsChannelValid(const Anope::string &chan) { - if (chan.empty() || chan[0] != '#' || chan.length() > IRCD->GetMaxChannel()) + if (chan.empty() || chan[0] != '#' || chan.length() > IRCD->MaxChannel) return false; if (chan.find_first_of(" ,") != Anope::string::npos) @@ -307,7 +311,7 @@ bool IRCDProto::IsChannelValid(const Anope::string &chan) bool IRCDProto::IsIdentValid(const Anope::string &ident) { - if (ident.empty() || ident.length() > IRCD->GetMaxUser()) + if (ident.empty() || ident.length() > IRCD->MaxUser) return false; for (auto c : ident) @@ -323,7 +327,7 @@ bool IRCDProto::IsIdentValid(const Anope::string &ident) bool IRCDProto::IsHostValid(const Anope::string &host) { - if (host.empty() || host.length() > IRCD->GetMaxHost()) + if (host.empty() || host.length() > IRCD->MaxHost) return false; const Anope::string &vhostdisablebe = Config->GetBlock("networkinfo")->Get<const Anope::string>("disallow_start_or_end"), @@ -378,34 +382,6 @@ void IRCDProto::SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, }); } -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 */ |