X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_repeat.cpp;h=89f5a12916fe143dd3b402c7ee9f804426a76d1b;hb=3151d60c1ecc9462e4c335282ee6c31672f45111;hp=7ecdf21dc5dbb4b2f8c1ec7ab1bbd3e32b5f94b1;hpb=9ea8191a050aa2262289a11edde115de1bcb0d71;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 7ecdf21dc..89f5a1291 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -1,6 +1,12 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2019 Robby + * Copyright (C) 2018-2019 linuxdaemon + * Copyright (C) 2018 Matt Schatz + * Copyright (C) 2017-2019 Sadie Powell + * Copyright (C) 2015 James Lu + * Copyright (C) 2013-2015 Attila Molnar * Copyright (C) 2013 Daniel Vassdal * * This file is part of InspIRCd. InspIRCd is free software: you can @@ -34,7 +40,7 @@ class ChannelSettings unsigned int Backlog; unsigned int Lines; unsigned int Diff; - unsigned int Seconds; + unsigned long Seconds; void serialize(std::string& out) const { @@ -125,9 +131,10 @@ class RepeatMode : public ParamMode > : ParamMode >(Creator, "repeat", 'E') , MemberInfoExt("repeat_memb", ExtensionItem::EXT_MEMBERSHIP, Creator) { + syntax = "[~|*]:[:][:]"; } - void OnUnset(User* source, Channel* chan) + void OnUnset(User* source, Channel* chan) CXX11_OVERRIDE { // Unset the per-membership extension when the mode is removed const Channel::MemberMap& users = chan->GetUsers(); @@ -140,15 +147,14 @@ class RepeatMode : public ParamMode > ChannelSettings settings; if (!ParseSettings(source, parameter, settings)) { - source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat syntax. Syntax is {[~*]}[lines]:[time]{:[difference]}{:[backlog]}.")); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); return MODEACTION_DENY; } if ((settings.Backlog > 0) && (settings.Lines > settings.Backlog)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat syntax. You can't set needed lines higher than backlog.")); + "You can't set lines higher than backlog.")); return MODEACTION_DENY; } @@ -233,15 +239,15 @@ class RepeatMode : public ParamMode > void ReadConfig() { ConfigTag* conf = ServerInstance->Config->ConfValue("repeat"); - ms.MaxLines = conf->getInt("maxlines", 20); - ms.MaxBacklog = conf->getInt("maxbacklog", 20); - ms.MaxSecs = conf->getDuration("maxtime", conf->getInt("maxsecs", 0)); + ms.MaxLines = conf->getUInt("maxlines", 20); + ms.MaxBacklog = conf->getUInt("maxbacklog", 20); + ms.MaxSecs = conf->getDuration("maxtime", conf->getDuration("maxsecs", 0)); - ms.MaxDiff = conf->getInt("maxdistance", 50); + ms.MaxDiff = conf->getUInt("maxdistance", 50); if (ms.MaxDiff > 100) ms.MaxDiff = 100; - unsigned int newsize = conf->getInt("size", 512); + unsigned int newsize = conf->getUInt("size", 512); if (newsize > ServerInstance->Config->Limits.MaxLine) newsize = ServerInstance->Config->Limits.MaxLine; Resize(newsize); @@ -274,10 +280,10 @@ class RepeatMode : public ParamMode > else settings.Action = ChannelSettings::ACT_KICK; - if ((settings.Lines = ConvToInt(item)) == 0) + if ((settings.Lines = ConvToNum(item)) == 0) return false; - if ((!stream.GetToken(item)) || ((settings.Seconds = InspIRCd::Duration(item)) == 0)) + if ((!stream.GetToken(item)) || !InspIRCd::Duration(item, settings.Seconds) || (settings.Seconds == 0)) // Required parameter missing return false; @@ -286,13 +292,13 @@ class RepeatMode : public ParamMode > if (stream.GetToken(item)) { // There is a diff parameter, see if it's valid (> 0) - if ((settings.Diff = ConvToInt(item)) == 0) + if ((settings.Diff = ConvToNum(item)) == 0) return false; if (stream.GetToken(item)) { // There is a backlog parameter, see if it's valid - if ((settings.Backlog = ConvToInt(item)) == 0) + if ((settings.Backlog = ConvToNum(item)) == 0) return false; // If there are still tokens, then it's invalid because we allow only 4 @@ -309,14 +315,14 @@ class RepeatMode : public ParamMode > if (ms.MaxLines && settings.Lines > ms.MaxLines) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "Invalid repeat parameter. The line number you specified is too great. Maximum allowed is %u.", ms.MaxLines))); + "The line number you specified is too big. Maximum allowed is %u.", ms.MaxLines))); return false; } if (ms.MaxSecs && settings.Seconds > ms.MaxSecs) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "Invalid repeat parameter. The seconds you specified is too great. Maximum allowed is %u.", ms.MaxSecs))); + "The seconds you specified are too big. Maximum allowed is %u.", ms.MaxSecs))); return false; } @@ -324,10 +330,10 @@ class RepeatMode : public ParamMode > { if (ms.MaxDiff == 0) source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat parameter. The server administrator has disabled matching on edit distance.")); + "The server administrator has disabled matching on edit distance.")); else source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "Invalid repeat parameter. The distance you specified is too great. Maximum allowed is %u.", ms.MaxDiff))); + "The distance you specified is too big. Maximum allowed is %u.", ms.MaxDiff))); return false; } @@ -335,10 +341,10 @@ class RepeatMode : public ParamMode > { if (ms.MaxBacklog == 0) source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat parameter. The server administrator has disabled backlog matching.")); + "The server administrator has disabled backlog matching.")); else source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "Invalid repeat paramter. The backlog you specified is too great. Maximum allowed is %u.", ms.MaxBacklog))); + "The backlog you specified is too big. Maximum allowed is %u.", ms.MaxBacklog))); return false; } @@ -409,7 +415,7 @@ class RepeatModule : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Provides the +E channel mode - for blocking of similar messages", VF_COMMON|VF_VENDOR, rm.GetModuleSettings()); + return Version("Adds channel mode E (repeat) which helps protect against spammers which spam the same message repeatedly.", VF_COMMON|VF_VENDOR, rm.GetModuleSettings()); } };