]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #251 from Shawn-Smith/insp20+extbanU
authorRobin Burchell <viroteck@viroteck.net>
Mon, 13 Aug 2012 08:08:35 +0000 (01:08 -0700)
committerRobin Burchell <viroteck@viroteck.net>
Mon, 13 Aug 2012 08:08:35 +0000 (01:08 -0700)
[2.0] Add ExtBan U to match only unregistered users

docs/conf/inspircd.helpop-full.example
docs/conf/inspircd.helpop.example
docs/conf/modules.conf.example
src/modules/m_services_account.cpp

index 1887b1a8094fa739d38114c5b1a2e9f9bd1fbcdf..27b689f51ab02302368a0264811ba369e39f53a2 100644 (file)
@@ -1051,6 +1051,8 @@ Acting extbans:
                users (requires stripcolor module).
  T:<ban>       Blocks notices from matching users (requires nonotice
                module).
+ U:<ban>       Blocks unregistered users matching the given ban.
+               (requires m_services_account)
 
 A ban given to an acting extban may either be a nick!user@host mask,
 matched against users as for a normal ban, or a matching extban.
index 4b3354837bd61009186ac9d2c33371f0b768e2bc..2ba4ac5a18340dde02ede507b362a4336d2472d6 100644 (file)
@@ -288,6 +288,8 @@ help channel if you have any questions.">
               users (requires stripcolor module).
  T:n!u@h      Blocks notices from matching users (requires nonotice
               module).
+ U:n!u@h      Blocks unregistered users matching the given ban.
+              (requires m_services_account)
 
  Redirect     n!u@h#channel will redirect the banned user to #channel
               when they try to join (requires banredirect module).
index 0f0da74c77a138696306c2d2c9678c480a193cb8..76563fbeb0c42439997a8f6fd3d3034781201e1a 100644 (file)
 #
 # This replaces m_services from 1.1 and earlier.
 #
-# Also of note is that this module implements two extbans:
+# Also of note is that this module implements three extbans:
 # +b R: (stop matching account names from joining)
 # +b M: (stop matching account names from speaking)
+# +b U:n!u@h (blocks matching unregistered users)
 #                                                                       
 #<module name="m_services_account.so">
 
index a28be61dccbd652b2bf9abfee5e35ed92c890492..08986d53c400d17880ceddf3f1714450a246da0c 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2012 Shawn Smith <shawn@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *   Copyright (C) 2006-2008 Robin Burchell <robin+git@viroteck.net>
  *   Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
@@ -134,6 +135,7 @@ class ModuleServicesAccount : public Module
        void On005Numeric(std::string &t)
        {
                ServerInstance->AddExtBanChar('R');
+               ServerInstance->AddExtBanChar('U');
        }
 
        /* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
@@ -207,12 +209,30 @@ class ModuleServicesAccount : public Module
 
        ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask)
        {
-               if (mask[0] == 'R' && mask[1] == ':')
+               if (mask[1] == ':')
                {
-                       std::string *account = accountname.get(user);
-                       if (account && InspIRCd::Match(*account, mask.substr(2)))
-                               return MOD_RES_DENY;
+                       if (mask[0] == 'R')
+                       {
+                               std::string *account = accountname.get(user);
+                               if (account && InspIRCd::Match(*account, mask.substr(2)))
+                                       return MOD_RES_DENY;
+                       }
+                       else if (mask[0] == 'U')
+                       {
+                               std::string *account = accountname.get(user);
+                               /* If the user is registered we don't care. */
+                               if (account)
+                                       return MOD_RES_PASSTHRU;
+
+                               /* If we made it this far we know the user isn't registered
+                                       so just deny if it matches */
+                               if (chan->GetExtBanStatus(user, 'U') == MOD_RES_DENY)
+                                       return MOD_RES_DENY;
+                       }
                }
+
+               /* If we made it this far then the ban wasn't an ExtBan
+                       or the user we were checking for didn't match either ExtBan */
                return MOD_RES_PASSTHRU;
        }