X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_cloaking.cpp;h=8422abd43792d519fc70623427c6181b6268a3c2;hb=f51d9ad5ab7015f78a29039ca7ed169b281ff6bb;hp=d4c4c4529d37d073e6b92af8ba657ccef1d6f0ca;hpb=4e7c9f5a9257723765f9994aff90440a0b6cf3c9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index d4c4c4529..8422abd43 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * InspIRCd: (C) 2002-2008 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -67,7 +67,7 @@ class CloakUser : public ModeHandler { } - ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (source != dest) return MODEACTION_DENY; @@ -78,6 +78,9 @@ class CloakUser : public ModeHandler if (!IS_LOCAL(dest)) return MODEACTION_ALLOW; + /* don't allow this user to spam modechanges */ + dest->IncreasePenalty(5); + if (adding) { if(!dest->IsModeSet('x')) @@ -106,7 +109,7 @@ class CloakUser : public ModeHandler * 'real' hostname which you shouldnt write to. */ - /* 2007/08/18: add which always cloaks + /* 2008/08/18: add which always cloaks * the IP, for anonymity. --nenolod */ if (!ipalways) @@ -254,12 +257,17 @@ class CloakUser : public ModeHandler { ConfigReader Conf(ServerInstance); bool lowercase; - + + /* These are *not* using the need_positive parameter of ReadInteger - + * that will limit the valid values to only the positive values in a + * signed int. Instead, accept any value that fits into an int and + * cast it to an unsigned int. That will, a bit oddly, give us the full + * spectrum of an unsigned integer. - Special */ key1 = key2 = key3 = key4 = 0; - key1 = Conf.ReadInteger("cloak","key1",0,true); - key2 = Conf.ReadInteger("cloak","key2",0,true); - key3 = Conf.ReadInteger("cloak","key3",0,true); - key4 = Conf.ReadInteger("cloak","key4",0,true); + key1 = (unsigned int) Conf.ReadInteger("cloak","key1",0,false); + key2 = (unsigned int) Conf.ReadInteger("cloak","key2",0,false); + key3 = (unsigned int) Conf.ReadInteger("cloak","key3",0,false); + key4 = (unsigned int) Conf.ReadInteger("cloak","key4",0,false); prefix = Conf.ReadValue("cloak","prefix",0); ipalways = Conf.ReadFlag("cloak", "ipalways", 0); lowercase = Conf.ReadFlag("cloak", "lowercase", 0); @@ -311,28 +319,41 @@ class ModuleCloaking : public Module ModuleCloaking(InspIRCd* Me) : Module(Me) { - ServerInstance->UseInterface("HashRequest"); - /* Attempt to locate the md5 service provider, bail if we can't find it */ - HashModule = ServerInstance->FindModule("m_md5.so"); + HashModule = ServerInstance->Modules->Find("m_md5.so"); if (!HashModule) throw ModuleException("Can't find m_md5.so. Please load m_md5.so before m_cloaking.so."); - /* Create new mode handler object */ cu = new CloakUser(ServerInstance, this, HashModule); - /* Register it with the core */ - if (!ServerInstance->AddMode(cu, 'x')) + try + { + OnRehash(NULL,""); + } + catch (CoreException &e) + { + delete cu; + throw e; + } + + /* Register it with the core */ + if (!ServerInstance->Modes->AddMode(cu)) + { + delete cu; throw ModuleException("Could not add new modes!"); + } - OnRehash(NULL,""); + ServerInstance->Modules->UseInterface("HashRequest"); + + Implementation eventlist[] = { I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 1); } virtual ~ModuleCloaking() { ServerInstance->Modes->DelMode(cu); - DELETE(cu); - ServerInstance->DoneWithInterface("HashRequest"); + delete cu; + ServerInstance->Modules->DoneWithInterface("HashRequest"); } virtual Version GetVersion() @@ -342,15 +363,11 @@ class ModuleCloaking : public Module return Version(1,1,0,2,VF_COMMON|VF_VENDOR,API_VERSION); } - virtual void OnRehash(userrec* user, const std::string ¶meter) + virtual void OnRehash(User* user, const std::string ¶meter) { cu->DoRehash(); } - void Implements(char* List) - { - List[I_OnRehash] = 1; - } }; MODULE_INIT(ModuleCloaking)