* | 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
{
}
- 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;
if (!IS_LOCAL(dest))
return MODEACTION_ALLOW;
+ /* don't allow this user to spam modechanges */
+ dest->IncreasePenalty(5);
+
if (adding)
{
if(!dest->IsModeSet('x'))
* 'real' hostname which you shouldnt write to.
*/
- /* 2007/08/18: add <cloak:ipalways> which always cloaks
+ /* 2008/08/18: add <cloak:ipalways> which always cloaks
* the IP, for anonymity. --nenolod
*/
if (!ipalways)
{
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);
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()
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)