X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_xline%2Fcore_xline.cpp;h=568b7d2693e2a96bf0c4e167e80fdf4a6722ea17;hb=aa692dc1039b63deef7886e914ec499abe7facaf;hp=7fa7da0197369fb412955489fb1e261473e11443;hpb=f62654a6859998f9d63eb22702c572d5ebcff15c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp index 7fa7da019..568b7d269 100644 --- a/src/coremods/core_xline/core_xline.cpp +++ b/src/coremods/core_xline/core_xline.cpp @@ -1,7 +1,11 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2014 Attila Molnar + * Copyright (C) 2019 linuxdaemon + * Copyright (C) 2019 Matt Schatz + * Copyright (C) 2018-2019 Robby + * Copyright (C) 2017-2019 Sadie Powell + * Copyright (C) 2014, 2016 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -28,7 +32,7 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User if (insane->getBool(confkey)) return false; - float itrigger = insane->getFloat("trigger", 95.5); + float itrigger = insane->getFloat("trigger", 95.5, 0.0, 100.0); long matches = test.Run(mask); @@ -38,7 +42,7 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User float percent = ((float)matches / (float)ServerInstance->Users->GetUsers().size()) * 100; if (percent > itrigger) { - ServerInstance->SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a %s-line mask of %s, which covers %.2f%% of the network!", user->nick.c_str(), bantype, mask.c_str(), percent); + ServerInstance->SNO->WriteToSnoMask('a', "\002WARNING\002: %s tried to set a %s-line mask of %s, which covers %.2f%% of the network!", user->nick.c_str(), bantype, mask.c_str(), percent); return true; } return false; @@ -46,8 +50,8 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User bool InsaneBan::IPHostMatcher::Check(User* user, const std::string& mask) const { - return ((InspIRCd::Match(user->MakeHost(), mask, ascii_case_insensitive_map)) || - (InspIRCd::Match(user->MakeHostIP(), mask, ascii_case_insensitive_map))); + return ((InspIRCd::MatchCIDR(user->MakeHost(), mask, ascii_case_insensitive_map)) || + (InspIRCd::MatchCIDR(user->MakeHostIP(), mask, ascii_case_insensitive_map))); } class CoreModXLine : public Module @@ -64,26 +68,43 @@ class CoreModXLine : public Module { } + void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE + { + if (user->quitting) + return; + + user->exempt = (ServerInstance->XLines->MatchesLine("E", user) != NULL); + user->CheckLines(true); + } + ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE { - // Check Q-Lines (for local nick changes only, remote servers have our Q-Lines to enforce themselves) + // Check Q-lines (for local nick changes only, remote servers have our Q-lines to enforce themselves) XLine* xline = ServerInstance->XLines->MatchesLine("Q", newnick); if (!xline) return MOD_RES_PASSTHRU; // No match - // A Q-Line matched the new nick, tell opers if the user is registered + // A Q-line matched the new nick, tell opers if the user is registered if (user->registered == REG_ALL) { - ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s: %s", + ServerInstance->SNO->WriteGlobalSno('a', "Q-lined nickname %s from %s: %s", newnick.c_str(), user->GetFullRealHost().c_str(), xline->reason.c_str()); } // Send a numeric because if we deny then the core doesn't reply anything - user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Invalid nickname: %s", newnick.c_str(), xline->reason.c_str()); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Invalid nickname: %s", xline->reason.c_str())); return MOD_RES_DENY; } + void OnGarbageCollect() CXX11_OVERRIDE + { + // HACK: ELines are not expired properly at the moment but it can't be fixed + // as the XLine system is a spaghetti nightmare. Instead we skip over expired + // ELines in XLineManager::CheckELines() and expire them here instead. + ServerInstance->XLines->GetAll("E"); + } + Version GetVersion() CXX11_OVERRIDE { return Version("Provides the ELINE, GLINE, KLINE, QLINE, and ZLINE commands", VF_VENDOR|VF_CORE);