X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fmodules%2Fm_cloaking.cpp;h=a2bc778b0cc2e64b2da5d74a3babb1fd552fc43b;hb=HEAD;hp=fd3e4e1eb6ae3a86681da6402dbaadbf35eda1fb;hpb=aa692dc1039b63deef7886e914ec499abe7facaf;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index fd3e4e1eb..a2bc778b0 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -1,19 +1,20 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2017-2019 B00mX0r + * Copyright (C) 2017, 2019 B00mX0r * Copyright (C) 2017 Sheogorath * Copyright (C) 2016 Adam * Copyright (C) 2014 Thomas Fargeix * Copyright (C) 2013, 2018 Attila Molnar - * Copyright (C) 2013, 2016-2019 Sadie Powell + * Copyright (C) 2013, 2016-2021 Sadie Powell * Copyright (C) 2012 Robby * Copyright (C) 2011 jackmcbarn * Copyright (C) 2009-2010 Daniel De Graaf * Copyright (C) 2007-2009 Robin Burchell - * Copyright (C) 2007-2008, 2010 Craig Edwards * Copyright (C) 2007-2008 Dennis Friis + * Copyright (C) 2007 John Brooks * Copyright (C) 2006 Oliver Lupton + * Copyright (C) 2003, 2007-2008, 2010 Craig Edwards * * 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 @@ -80,13 +81,25 @@ struct CloakInfo typedef std::vector CloakList; -/** Handles user mode +x - */ +class CloakExtItem : public SimpleExtItem +{ + public: + CloakExtItem(Module* Creator) + : SimpleExtItem("cloaks", ExtensionItem::EXT_USER, Creator) + { + } + + std::string ToHuman(const Extensible* container, void* item) const CXX11_OVERRIDE + { + return stdalgo::string::join(*static_cast(item), ' '); + } +}; + class CloakUser : public ModeHandler { public: bool active; - SimpleExtItem ext; + CloakExtItem ext; std::string debounce_uid; time_t debounce_ts; int debounce_count; @@ -94,7 +107,7 @@ class CloakUser : public ModeHandler CloakUser(Module* source) : ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER) , active(false) - , ext("cloaked_host", ExtensionItem::EXT_USER, source) + , ext(source) , debounce_ts(0) , debounce_count(0) { @@ -146,8 +159,16 @@ class CloakUser : public ModeHandler if (!cloaks) { /* Force creation of missing cloak */ - creator->OnUserConnect(user); - cloaks = ext.get(user); + try + { + creator->OnUserConnect(user); + cloaks = ext.get(user); + } + catch (CoreException& modexcept) + { + ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Exception caught when generating cloak: " + modexcept.GetReason()); + return MODEACTION_DENY; + } } // If we have a cloak then set the hostname. @@ -416,7 +437,7 @@ class ModuleCloaking : public Module testcloak = info.prefix + SegmentCloak(info, "*", 4, 8) + info.suffix + (info.ignorecase ? "-ci" : ""); } } - return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR, testcloak); + return Version("Adds user mode x (cloak) which allows user hostnames to be hidden.", VF_COMMON|VF_VENDOR, testcloak); } void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE @@ -485,7 +506,7 @@ class ModuleCloaking : public Module void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE { // Connecting users are handled in OnUserConnect not here. - if (user->registered != REG_ALL) + if (user->registered != REG_ALL || user->quitting) return; // Remove the cloaks and generate new ones.