X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_override.cpp;h=d931891c2e67a1ad86e578e6224da831cdd303fe;hb=de69e28a4a1aea89e410b693bbbb67890ecb0bd3;hp=1f2eb876ad37911b4e7f183a6a8e56c36356141e;hpb=7892c8a0313c50d8138942ff3b112691caf05a2f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 1f2eb876a..d931891c2 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -12,7 +12,6 @@ */ #include "inspircd.h" -#include "m_override.h" /* $ModDesc: Provides support for unreal-style oper-override */ @@ -26,24 +25,19 @@ class ModuleOverride : public Module public: - ModuleOverride(InspIRCd* Me) - : Module(Me) - { + ModuleOverride() + { // read our config options (main config file) OnRehash(NULL); ServerInstance->SNO->EnableSnomask('G', "GODMODE"); - if (!ServerInstance->Modules->PublishFeature("Override", this)) - { - throw ModuleException("m_override: Unable to publish feature 'Override'"); - } - Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange, I_OnRequest }; - ServerInstance->Modules->Attach(eventlist, this, 7); + Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange }; + ServerInstance->Modules->Attach(eventlist, this, 6); } void OnRehash(User* user) { // on a rehash we delete our classes for good measure and create them again. - ConfigReader Conf(ServerInstance); + ConfigReader Conf; // re-read our config options on a rehash NoisyOverride = Conf.ReadFlag("override", "noisy", 0); @@ -67,7 +61,7 @@ class ModuleOverride : public Module bool CanOverride(User* source, const char* token) { // checks to see if the oper's type has - override_t::iterator j = overrides.find(source->oper); + override_t::iterator j = overrides.find(source->oper->name); if (j != overrides.end()) { @@ -138,10 +132,10 @@ class ModuleOverride : public Module { if (chan) { - if ((chan->modes[CM_INVITEONLY]) && (CanOverride(user,"INVITE"))) + if (chan->IsModeSet('i') && (CanOverride(user,"INVITE"))) { irc::string x(chan->name.c_str()); - if (!user->IsInvited(x)) + if (!IS_LOCAL(user)->IsInvited(x)) { if (RequireKey && keygiven != "override") { @@ -151,13 +145,13 @@ class ModuleOverride : public Module } if (NoisyOverride) - chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass invite-only", cname, user->nick.c_str()); + chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass invite-only", cname, user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('G', user->nick+" used oper override to bypass +i on "+std::string(cname)); } return MOD_RES_ALLOW; } - if ((chan->modes[CM_KEY]) && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k')) + if (chan->IsModeSet('k') && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k')) { if (RequireKey && keygiven != "override") { @@ -167,12 +161,12 @@ class ModuleOverride : public Module } if (NoisyOverride) - chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass the channel key", cname, user->nick.c_str()); + chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass the channel key", cname, user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('G', user->nick+" used oper override to bypass +k on "+std::string(cname)); return MOD_RES_ALLOW; } - if ((chan->modes[CM_LIMIT]) && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT"))) + if (chan->IsModeSet('l') && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT"))) { if (RequireKey && keygiven != "override") { @@ -182,7 +176,7 @@ class ModuleOverride : public Module } if (NoisyOverride) - chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass the channel limit", cname, user->nick.c_str()); + chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass the channel limit", cname, user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('G', user->nick+" used oper override to bypass +l on "+std::string(cname)); return MOD_RES_ALLOW; } @@ -197,7 +191,7 @@ class ModuleOverride : public Module } if (NoisyOverride) - chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s used oper override to bypass channel ban", cname, user->nick.c_str()); + chan->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "NOTICE %s :%s used oper override to bypass channel ban", cname, user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('G',"%s used oper override to bypass channel ban on %s", user->nick.c_str(), cname); return MOD_RES_ALLOW; } @@ -206,25 +200,14 @@ class ModuleOverride : public Module return MOD_RES_PASSTHRU; } - const char* OnRequest(Request* request) - { - if(strcmp(OVRREQID, request->GetId()) == 0) - { - OVRrequest* req = static_cast(request); - return this->CanOverride(req->requser,req->reqtoken.c_str()) ? "yes":""; - } - return NULL; - } - ~ModuleOverride() { - ServerInstance->Modules->UnpublishFeature("Override"); ServerInstance->SNO->DisableSnomask('G'); } Version GetVersion() { - return Version("$Id$",VF_VENDOR,API_VERSION); + return Version("Provides support for unreal-style oper-override",VF_VENDOR); } };