mirror of
https://github.com/anope/anope.git
synced 2026-06-30 13:46:38 +02:00
If the IRCd sends a field limit then use it over that of the config.
This commit is contained in:
+13
-16
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/*
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
Anope::string maxmodes(capab.begin() + 9, capab.end());
|
||||
IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
|
||||
}
|
||||
else if (capab == "GLOBOPS=1")
|
||||
if (capab == "GLOBOPS=1")
|
||||
Servers::Capab.insert("GLOBOPS");
|
||||
else if (capab.find("CHANMAX=") != Anope::string::npos)
|
||||
{
|
||||
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 (params[0].equals_cs("END"))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user