X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_serverban.cpp;h=405703f842ffa2cac23cccd14e69e20189427921;hb=80e81e3b81b779901fd9d67f8ae030ee30c0bcec;hp=ca3b51e5035b007ebb1a219d60f42ca5f75de619;hpb=b6de960d973dc8a22c1bf5b0cbcf0a20461faa13;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_serverban.cpp b/src/modules/m_serverban.cpp index ca3b51e50..405703f84 100644 --- a/src/modules/m_serverban.cpp +++ b/src/modules/m_serverban.cpp @@ -1,62 +1,52 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * Copyright (C) 2013, 2020 Sadie Powell + * Copyright (C) 2012, 2014 Attila Molnar + * Copyright (C) 2012 Robby + * Copyright (C) 2010 Craig Edwards + * Copyright (C) 2009 Uli Schlachter + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2008 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * 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 + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#include "inspircd.h" -/* $ModDesc: Implements extban +b s: - server name bans */ +#include "inspircd.h" class ModuleServerBan : public Module { - private: public: - ModuleServerBan(InspIRCd* Me) : Module(Me) - { - Implementation eventlist[] = { I_OnUserPreJoin, I_On005Numeric }; - ServerInstance->Modules->Attach(eventlist, this, 2); - } - - virtual ~ModuleServerBan() - { - } - - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { - return Version("$Id$",VF_COMMON|VF_VENDOR,API_VERSION); + return Version("Adds the s: extended ban which check whether users are on a server matching the specified glob pattern.", VF_OPTCOMMON|VF_VENDOR); } - virtual int OnUserPreJoin(User *user, Channel *c, const char *cname, std::string &privs, const std::string &key) + ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) CXX11_OVERRIDE { - if (!IS_LOCAL(user)) - return 0; - - if (!c) - return 0; - - if (c->IsExtBanned(user->server, 's')) + if ((mask.length() > 2) && (mask[0] == 's') && (mask[1] == ':')) { - user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)", user->nick.c_str(), c->name.c_str()); - return 1; + if (InspIRCd::Match(user->server->GetName(), mask.substr(2))) + return MOD_RES_DENY; } - - return 0; + return MOD_RES_PASSTHRU; } - virtual void On005Numeric(std::string &output) + void On005Numeric(std::map& tokens) CXX11_OVERRIDE { - ServerInstance->AddExtBanChar('s'); + tokens["EXTBAN"].push_back('s'); } }; - MODULE_INIT(ModuleServerBan) -