Merge branch 'insp3' into master.

This commit is contained in:
Sadie Powell 2022-04-05 23:37:33 +01:00
commit 72372136c4
18 changed files with 64 additions and 52 deletions

View File

@ -649,7 +649,7 @@
#
#<connectban threshold="10"
# banmessage="Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect."
# banduration="10m"
# banduration="6h"
# ipv4cidr="32"
# ipv6cidr="128"
# bootwait="2m"

View File

@ -425,7 +425,7 @@ const char* Channel::ChanModes(bool showsecret)
void Channel::WriteNotice(const std::string& text, char status)
{
ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, this, text, MSG_NOTICE, status);
Write(ServerInstance->GetRFCEvents().privmsg, privmsg);
Write(ServerInstance->GetRFCEvents().privmsg, privmsg, status);
}
void Channel::WriteRemoteNotice(const std::string& text, char status)

View File

@ -74,11 +74,11 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters)
{
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent E-line for %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent E-line on %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed E-line for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed E-line on %s, expires in %s (on %s): %s",
user->nick.c_str(), target.c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -81,11 +81,11 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters)
{
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent G-line for %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent G-line on %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed G-line for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed G-line on %s, expires in %s (on %s): %s",
user->nick.c_str(), target.c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -81,11 +81,11 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters)
{
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent K-line for %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent K-line on %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed K-line for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed K-line on %s, expires in %s (on %s): %s",
user->nick.c_str(), target.c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -63,11 +63,11 @@ CmdResult CommandQline::Handle(User* user, const Params& parameters)
{
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent Q-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent Q-line on %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed Q-line for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed Q-line on %s, expires in %s (on %s): %s",
user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -81,11 +81,11 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters)
{
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent Z-line for %s: %s", user->nick.c_str(), ipaddr, parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent Z-line on %s: %s", user->nick.c_str(), ipaddr, parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed Z-line for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed Z-line on %s, expires in %s (on %s): %s",
user->nick.c_str(), ipaddr, InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -286,9 +286,19 @@ void TokenList::Remove(const std::string& token)
std::string TokenList::ToString() const
{
std::string buffer(permissive ? "* " : "-* ");
buffer.append(stdalgo::string::join(tokens));
return buffer;
if (permissive)
{
// If the token list is in permissive mode then the tokens are a list
// of disallowed tokens.
std::string buffer("*");
for (const auto& token : tokens)
buffer.append(" -").append(token);
return buffer;
}
// If the token list is not in permissive mode then the token list is just
// a list of allowed tokens.
return stdalgo::string::join(tokens);
}
bool TokenList::operator==(const TokenList& other) const

View File

@ -271,11 +271,6 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode
if (MOD_RESULT == MOD_RES_PASSTHRU)
{
unsigned int neededrank = mh->GetLevelRequired(mcitem.adding);
/* Compare our rank on the channel against the rank of the required prefix,
* allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown
* in NAMES(X) are not in rank order, we know the most powerful mode is listed
* first, so we don't need to iterate, we just look up the first instead.
*/
unsigned int ourrank = chan->GetPrefixValue(user);
if (ourrank < neededrank)
{

View File

@ -109,7 +109,7 @@ public:
if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "CBAN", reason, user))
{
ServerInstance->SNO.WriteGlobalSno('x', "%s removed CBan on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s removed CBan on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str());
}
else
{
@ -133,11 +133,11 @@ public:
{
if (!duration)
{
ServerInstance->SNO.WriteGlobalSno('x', "%s added permanent CBan for %s: %s", user->nick.c_str(), parameters[0].c_str(), reason);
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent CBan on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason);
}
else
{
ServerInstance->SNO.WriteGlobalSno('x', "%s added timed CBan for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed CBan on %s, expires in %s (on %s): %s",
user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), reason);
}

View File

@ -100,12 +100,12 @@ public:
{
auto tag = ServerInstance->Config->ConfValue("connectban");
ipv4_cidr = static_cast<unsigned int>(tag->getUInt("ipv4cidr", 32, 1, 32));
ipv6_cidr = static_cast<unsigned int>(tag->getUInt("ipv6cidr", 128, 1, 128));
ipv4_cidr = static_cast<unsigned int>(tag->getUInt("ipv4cidr", ServerInstance->Config->c_ipv4_range, 1, 32));
ipv6_cidr = static_cast<unsigned int>(tag->getUInt("ipv6cidr", ServerInstance->Config->c_ipv6_range, 1, 128));
threshold = tag->getUInt("threshold", 10, 1);
bootwait = tag->getDuration("bootwait", 60*2);
splitwait = tag->getDuration("splitwait", 60*2);
banduration = tag->getDuration("banduration", 10*60, 1);
banduration = tag->getDuration("banduration", 6*60*60, 1);
banmessage = tag->getString("banmessage", "Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect.");
if (status.initial)
@ -147,18 +147,19 @@ public:
if (i->second >= threshold)
{
// Create Z-line for set duration.
ZLine* zl = new ZLine(ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, banmessage, mask.str());
ZLine* zl = new ZLine(ServerInstance->Time(), banduration, MODNAME "@" + ServerInstance->Config->ServerName, banmessage, mask.str());
if (!ServerInstance->XLines->AddLine(zl, NULL))
{
delete zl;
return;
}
ServerInstance->XLines->ApplyLines();
std::string maskstr = mask.str();
ServerInstance->SNO.WriteGlobalSno('x', "Z-line added by module m_connectban on %s to expire in %s (on %s): Connect flooding",
maskstr.c_str(), InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed Z-line on %s, expires in %s (on %s): %s",
zl->source.c_str(), maskstr.c_str(), InspIRCd::DurationString(zl->duration).c_str(),
InspIRCd::TimeString(zl->expiry).c_str(), zl->reason.c_str());
ServerInstance->SNO.WriteGlobalSno('a', "Connect flooding from IP range %s (%lu)", maskstr.c_str(), threshold);
connects.erase(i);
ServerInstance->XLines->ApplyLines();
}
}
else

View File

@ -170,16 +170,16 @@ private:
template <typename Line, typename... Extra>
void AddLine(const char* type, const std::string& reason, unsigned long duration, Extra&&... extra)
{
auto line = new Line(ServerInstance->Time(), duration, ServerInstance->Config->ServerName, reason, std::forward<Extra>(extra)...);
auto line = new Line(ServerInstance->Time(), duration, MODNAME "@" + ServerInstance->Config->ServerName, reason, std::forward<Extra>(extra)...);
if (!ServerInstance->XLines->AddLine(line, nullptr))
{
delete line;
return;
}
ServerInstance->SNO.WriteToSnoMask('x', "%s added due to DNSBL match on %s to expire in %s (on %s): %s",
type, line->Displayable().c_str(), InspIRCd::DurationString(line->duration).c_str(),
InspIRCd::TimeString(line->expiry).c_str(), reason.c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed %s on %s, expires in %s (on %s): %s",
line->source.c_str(), type, line->Displayable().c_str(), InspIRCd::DurationString(line->duration).c_str(),
InspIRCd::TimeString(line->expiry).c_str(), line->reason.c_str());
ServerInstance->XLines->ApplyLines();
}

View File

@ -68,12 +68,20 @@ public:
{
if (ZlineOnMatch)
{
ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString());
ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason.c_str(), u->GetIPString());
if (ServerInstance->XLines->AddLine(zl, NULL))
{
std::string expirystr = zl->duration ? InspIRCd::Format(" to expire in %s (on %s)", InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()) : "";
ServerInstance->SNO.WriteToSnoMask('x', "Z-line added due to R-line match on %s%s: %s",
zl->ipaddr.c_str(), expirystr.c_str(), zl->reason.c_str());
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent Z-line on %s: %s",
zl->source.c_str(), u->GetIPString().c_str(), zl->reason.c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed Z-line on %s, expires in %s (on %s): %s",
zl->source.c_str(), u->GetIPString().c_str(), InspIRCd::DurationString(zl->duration).c_str(),
InspIRCd::TimeString(zl->duration).c_str(), zl->reason.c_str());
}
added_zline = true;
}
else
@ -166,11 +174,11 @@ public:
{
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent R-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent R-line on %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed R-line for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed R-line on %s, expires in %s (on %s): %s",
user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -123,7 +123,7 @@ public:
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed SHUN for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed SHUN on %s, expires in %s (on %s): %s",
user->nick.c_str(), target.c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), expr.c_str());
}

View File

@ -57,14 +57,14 @@ CmdResult CommandAddLine::Handle(User* usr, Params& params)
{
if (xl->duration)
{
ServerInstance->SNO.WriteToSnoMask('X', "%s added timed %s%s for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('X', "%s added a timed %s%s on %s, expires in %s (on %s): %s",
setter.c_str(), params[0].c_str(), params[0].length() == 1 ? "-line" : "",
params[1].c_str(), InspIRCd::DurationString(xl->duration).c_str(),
InspIRCd::TimeString(xl->expiry).c_str(), params[5].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('X', "%s added permanent %s%s on %s: %s",
ServerInstance->SNO.WriteToSnoMask('X', "%s added a permanent %s%s on %s: %s",
setter.c_str(), params[0].c_str(), params[0].length() == 1 ? "-line" : "",
params[1].c_str(), params[5].c_str());
}

View File

@ -64,10 +64,7 @@ public:
void DisplayExpiry() override
{
if (!silent)
{
ServerInstance->SNO.WriteToSnoMask('x', "Removing expired SVSHOLD %s (set by %s %s ago): %s",
nickname.c_str(), source.c_str(), InspIRCd::DurationString(ServerInstance->Time() - set_time).c_str(), reason.c_str());
}
XLine::DisplayExpiry();
}
const std::string& Displayable() override
@ -150,11 +147,11 @@ public:
if (!duration)
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added permanent SVSHOLD for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
ServerInstance->SNO.WriteToSnoMask('x', "%s added a permanent SVSHOLD on %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
}
else
{
ServerInstance->SNO.WriteToSnoMask('x', "%s added timed SVSHOLD for %s, expires in %s (on %s): %s",
ServerInstance->SNO.WriteToSnoMask('x', "%s added a timed SVSHOLD on %s, expires in %s (on %s): %s",
user->nick.c_str(), parameters[0].c_str(), InspIRCd::DurationString(duration).c_str(),
InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
}

View File

@ -703,7 +703,7 @@ void ELine::OnAdd()
void XLine::DisplayExpiry()
{
bool onechar = (type.length() == 1);
ServerInstance->SNO.WriteToSnoMask('x', "Removing expired %s%s %s (set by %s %s ago): %s",
ServerInstance->SNO.WriteToSnoMask('x', "Removing an expired %s%s on %s (set by %s %s ago): %s",
type.c_str(), (onechar ? "-line" : ""), Displayable().c_str(), source.c_str(), InspIRCd::DurationString(ServerInstance->Time() - set_time).c_str(), reason.c_str());
}

View File

@ -1,4 +1,4 @@
# Last updated: 2022-03-19
# Last updated: 2022-04-05
#
# Modules we can't legally ship: geo_maxmind, ssl_mbedtls, ssl_openssl
# Modules which don't apply to Windows: regex_posix, sslrehashsignal
@ -8,12 +8,13 @@
argon2/20190702
# libmaxminddb/1.6.0
libmysqlclient/8.0.25
libpq/13.4
libpq/14.2
# mbedtls/3.1.0
# openssl/3.0.2
pcre2/10.39
re2/20220201
sqlite3/3.38.1
zlib/1.2.12 # force override to fix a conflict between libmysqlclient and pcre
[options]
argon2:shared=True