From: Shawn Smith Date: Sat, 7 Jul 2012 17:20:18 +0000 (-0400) Subject: Added ExtBan U to match only Unregistered users X-Git-Tag: v2.0.23~583^2 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=61429d9c680188abd63e629d72fbc09e7e5cfc38;p=user%2Fhenk%2Fcode%2Finspircd.git Added ExtBan U to match only Unregistered users Enhancement requested in Issue #247 --- diff --git a/docs/conf/inspircd.helpop-full.example b/docs/conf/inspircd.helpop-full.example index 9c4ae0b92..c4936eea6 100644 --- a/docs/conf/inspircd.helpop-full.example +++ b/docs/conf/inspircd.helpop-full.example @@ -1050,6 +1050,8 @@ Acting extbans: users (requires stripcolor module). T: Blocks notices from matching users (requires nonotice module). + U: 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. diff --git a/docs/conf/inspircd.helpop.example b/docs/conf/inspircd.helpop.example index 4b3354837..2ba4ac5a1 100644 --- a/docs/conf/inspircd.helpop.example +++ b/docs/conf/inspircd.helpop.example @@ -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). diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index f86ebfa6c..9d9b61b93 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -1530,9 +1530,10 @@ # # 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) # # diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index cd34e955a..57a08ada4 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -1,6 +1,7 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2012 Shawn Smith * Copyright (C) 2009 Daniel De Graaf * Copyright (C) 2006-2008 Robin Burchell * Copyright (C) 2008 Pippijn van Steenhoven @@ -137,6 +138,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 */ @@ -210,12 +212,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; }