]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Check Q-Lines on nick change in core_xline
authorAttila Molnar <attilamolnar@hush.com>
Fri, 20 Jun 2014 14:34:03 +0000 (16:34 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Fri, 20 Jun 2014 14:34:03 +0000 (16:34 +0200)
src/coremods/core_xline/core_xline.cpp
src/users.cpp

index 7daa70b49ec964089145cc5eb7d2b45e019f950b..7fa7da0197369fb412955489fb1e261473e11443 100644 (file)
@@ -18,6 +18,7 @@
 
 
 #include "inspircd.h"
+#include "xline.h"
 #include "core_xline.h"
 
 bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey)
@@ -63,6 +64,26 @@ class CoreModXLine : public Module
        {
        }
 
+       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)
+
+               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
+               if (user->registered == REG_ALL)
+               {
+                       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());
+               return MOD_RES_DENY;
+       }
+
        Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides the ELINE, GLINE, KLINE, QLINE, and ZLINE commands", VF_VENDOR|VF_CORE);
index 87e40a53ec084b4f999fab7ded618b8846a0c295..75852330f2e2680bf0e818cc93a2d4ea68fa3e56 100644 (file)
@@ -647,7 +647,7 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
 
        if (assign(newnick) == assign(nick))
        {
-               // case change, don't need to check Q:lines and such
+               // case change, don't need to check campers
                // and, if it's identical including case, we can leave right now
                // We also don't update the nick TS if it's a case change, either
                if (newnick == nick)
@@ -655,29 +655,6 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
        }
        else
        {
-               /*
-                * Don't check Q:Lines if it's a server-enforced change, just on the off-chance some fucking *moron*
-                * tries to Q:Line SIDs, also, this means we just get our way period, as it really should be.
-                * Thanks Kein for finding this. -- w00t
-                *
-                * Also don't check Q:Lines for remote nickchanges, they should have our Q:Lines anyway to enforce themselves.
-                *              -- w00t
-                */
-               if (IS_LOCAL(this) && !force)
-               {
-                       XLine* mq = ServerInstance->XLines->MatchesLine("Q",newnick);
-                       if (mq)
-                       {
-                               if (this->registered == REG_ALL)
-                               {
-                                       ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s: %s",
-                                               newnick.c_str(), GetFullRealHost().c_str(), mq->reason.c_str());
-                               }
-                               this->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Invalid nickname: %s", newnick.c_str(), mq->reason.c_str());
-                               return false;
-                       }
-               }
-
                /*
                 * Uh oh.. if the nickname is in use, and it's not in use by the person using it (doh) --
                 * then we have a potential collide. Check whether someone else is camping on the nick