]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 5613a137f9ef3f7dc1f39063a3f05b573b4837ac..1534043ce9cff081b20c6047615a49528e0e91ff 100644 (file)
@@ -26,8 +26,6 @@
 #include "inspircd.h"
 #include "modules/hash.h"
 
-/* $ModDesc: Provides masking of user hostnames */
-
 enum CloakMode
 {
        /** 2.0 cloak of "half" of the hostname plus the full IP hash */
@@ -51,7 +49,7 @@ class CloakUser : public ModeHandler
 
        CloakUser(Module* source)
                : ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER),
-               ext("cloaked_host", source), debounce_ts(0), debounce_count(0)
+               ext("cloaked_host", ExtensionItem::EXT_USER, source), debounce_ts(0), debounce_count(0)
        {
        }
 
@@ -101,7 +99,7 @@ class CloakUser : public ModeHandler
                        }
                        if (cloak)
                        {
-                               user->ChangeDisplayedHost(cloak->c_str());
+                               user->ChangeDisplayedHost(*cloak);
                                user->SetMode(this, true);
                                return MODEACTION_ALLOW;
                        }
@@ -148,18 +146,6 @@ class ModuleCloaking : public Module
        {
        }
 
-       void init() CXX11_OVERRIDE
-       {
-               OnRehash(NULL);
-
-               ServerInstance->Modules->AddService(cu);
-               ServerInstance->Modules->AddService(ck);
-               ServerInstance->Modules->AddService(cu.ext);
-
-               Implementation eventlist[] = { I_OnRehash, I_OnCheckBan, I_OnUserConnect, I_OnChangeHost };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-       }
-
        /** This function takes a domain name string and returns just the last two domain parts,
         * or the last domain part if only two are available. Failing that it just returns what it was given.
         *
@@ -206,7 +192,7 @@ class ModuleCloaking : public Module
                input.append(1, '\0'); // null does not terminate a C++ string
                input.append(item);
 
-               std::string rv = Hash->sum(input).substr(0,len);
+               std::string rv = Hash->GenerateRaw(input).substr(0,len);
                for(int i=0; i < len; i++)
                {
                        // this discards 3 bits per byte. We have an
@@ -315,7 +301,7 @@ class ModuleCloaking : public Module
                if (u->IsModeSet(cu))
                {
                        u->SetMode(cu, false);
-                       u->WriteServ("MODE %s -%c", u->nick.c_str(), cu.GetModeChar());
+                       u->WriteCommand("MODE", "-" + ConvToStr(cu.GetModeChar()));
                }
        }
 
@@ -336,7 +322,7 @@ class ModuleCloaking : public Module
                return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR, testcloak);
        }
 
-       void OnRehash(User* user) CXX11_OVERRIDE
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("cloak");
                prefix = tag->getString("prefix");