diff --git a/src/modules/m_bansync.cpp b/src/modules/m_bansync.cpp new file mode 100644 index 0000000000..0d44d85939 --- /dev/null +++ b/src/modules/m_bansync.cpp @@ -0,0 +1,66 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2015 NickG365 + * + * 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 . + */ + +/* $ModAuthor: NickG365 */ +/* $ModAuthorMail: nick+inspircd@gameon365.net */ +/* $ModDesc: Implements extban +b J: - check bans from other channels */ + +#include "inspircd.h" + +class ModuleBanSyncExtban : public Module +{ + public: + void init() + { + Implementation eventlist[] = { I_OnCheckBan, I_On005Numeric }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + } + + Version GetVersion() + { + return Version("Extban 'J' - check bans from other channels", VF_OPTCOMMON); + } + + ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) + { + static bool recursing = false; + + if ((mask.length() > 2) && (mask[0] == 'J') && (mask[1] == ':')) + { + if (recursing) + return MOD_RES_PASSTHRU; + std::string rm = mask.substr(2); + Channel* channel = ServerInstance->FindChan(rm); + if (channel == NULL || channel == c) + return MOD_RES_PASSTHRU; + recursing = true; + if (channel->IsBanned(user)) + return MOD_RES_DENY; + recursing = false; + } + return MOD_RES_PASSTHRU; + } + + void On005Numeric(std::string &output) + { + ServerInstance->AddExtBanChar('J'); + } +}; + +MODULE_INIT(ModuleBanSyncExtban) + diff --git a/src/modules/m_conn_banner.cpp b/src/modules/m_conn_banner.cpp new file mode 100644 index 0000000000..9ad2f10a74 --- /dev/null +++ b/src/modules/m_conn_banner.cpp @@ -0,0 +1,54 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2012 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 + * 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 . + */ + +/* $ModAuthor: Attila Molnar */ +/* $ModAuthorMail: attilamolnar@hush.com */ +/* $ModDesc: Displays a static text to every connecting user before registration */ +/* $ModDepends: core 2.0 */ + +#include "inspircd.h" + +class ModuleConnBanner : public Module +{ + std::string text; + public: + void init() + { + OnRehash(NULL); + Implementation eventlist[] = { I_OnRehash, I_OnUserInit }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + } + + void OnRehash(User* user) + { + text = ServerInstance->Config->ConfValue("connbanner")->getString("text"); + } + + void OnUserInit(LocalUser* user) + { + if (!text.empty()) + user->WriteServ("NOTICE Auth :*** " + text); + } + + Version GetVersion() + { + return Version("Displays a static text to every connecting user before registration"); + } +}; + +MODULE_INIT(ModuleConnBanner) diff --git a/src/modules/m_forceident.cpp b/src/modules/m_forceident.cpp new file mode 100644 index 0000000000..2c4b2df362 --- /dev/null +++ b/src/modules/m_forceident.cpp @@ -0,0 +1,55 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2013 Peter Powell + * + * 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 . + */ + + +/* $ModAuthor: Peter "SaberUK" Powell */ +/* $ModAuthorMail: petpow@saberuk.com */ +/* $ModDesc: Allows forcing idents on users based on their connect class. */ +/* $ModDepends: core 2.0 */ +/* $ModConfig: */ + +#include "inspircd.h" + +class ModuleForceIdent : public Module +{ + public: + void init() + { + ServerInstance->Modules->Attach(I_OnUserConnect, this); + } + + void OnUserConnect(LocalUser* user) + { + ConfigTag* tag = user->MyClass->config; + std::string ident = tag->getString("forceident"); + if (ServerInstance->IsIdent(ident.c_str())) + { + ServerInstance->Logs->Log("m_forceident", DEBUG, "Setting ident of user '%s' (%s) in class '%s' to '%s'.", + user->nick.c_str(), user->uuid.c_str(), user->MyClass->name.c_str(), ident.c_str()); + user->ident = ident; + user->InvalidateCache(); + } + } + + Version GetVersion() + { + return Version("Allows forcing idents on users based on their connect class."); + } +}; + +MODULE_INIT(ModuleForceIdent) diff --git a/src/modules/m_morebans.cpp b/src/modules/m_morebans.cpp new file mode 100644 index 0000000000..64ffc2d69d --- /dev/null +++ b/src/modules/m_morebans.cpp @@ -0,0 +1,97 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2015 NickG365 + * + * 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 . + */ + +/* $ModAuthor: NickG365 */ +/* $ModAuthorMail: nick+inspircd@gameon365.net */ +/* $ModDesc: Allows increasing the ban list limit for specific channels with channel mode +E (max) */ + +#include +#include "inspircd.h" + +class LargeBanListMode : public ModeHandler +{ + public: + LargeBanListMode(Module* Creator) : ModeHandler(Creator, "largebanlist", 'E', PARAM_SETONLY, MODETYPE_CHANNEL) + { + oper = true; + } + + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) + { + // Removing mode that wasn't set + if (channel->IsModeSet(this) == false && !adding) + return MODEACTION_DENY; + // Removing mode + if (channel->IsModeSet(this) && !adding) + { + ServerInstance->Config->maxbans[channel->name] = ServerInstance->Config->maxbans.count("*") ? ServerInstance->Config->maxbans["*"] : 64; + channel->ResetMaxBans(); + return MODEACTION_ALLOW; + } + // Adding or updating mode + long newmax = strtol(parameter.c_str(), NULL, 10); + if (newmax == channel->GetMaxBans() || newmax == (ServerInstance->Config->maxbans.count("*") ? ServerInstance->Config->maxbans["*"] : 64)) + return MODEACTION_DENY; + ServerInstance->Config->maxbans[channel->name] = newmax; + channel->ResetMaxBans(); + channel->SetModeParam(this, parameter); + return MODEACTION_ALLOW; + } +}; + +class ModuleLargeBanList : public Module +{ + private: + LargeBanListMode mode; + public: + ModuleLargeBanList() : mode(this) + { + } + + void init() + { + ServerInstance->Modules->AddService(mode); + + Implementation eventlist[] = { I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + + OnRehash(NULL); + } + + void OnRehash(User* user) + { + for (chan_hash::iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ) + { + Channel* channel = i->second; + ++i; + if (channel->IsModeSet('E')) + { + long newmax = strtol(channel->GetModeParameter('E').c_str(), NULL, 10); + ServerInstance->Config->maxbans[channel->name] = newmax; + channel->ResetMaxBans(); + } + } + } + + Version GetVersion() + { + return Version("Allows increasing the ban list limit for specific channels with channel mode +E (max)"); + } +}; + +MODULE_INIT(ModuleLargeBanList)