]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Fix some of the include guard names (requested by SaberUK)
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 1b46bb75e72c51b31c1c8cf306b92bf4e4a7ffdd..ba7005396054804cb156684aac0263f4f3a173b2 100644 (file)
@@ -106,8 +106,8 @@ class CloakUser : public ModeHandler
                        /* User is removing the mode, so restore their real host
                         * and make it match the displayed one.
                         */
-                       user->ChangeDisplayedHost(user->host.c_str());
                        user->SetMode('x',false);
+                       user->ChangeDisplayedHost(user->host.c_str());
                        return MODEACTION_ALLOW;
                }
        }
@@ -198,7 +198,7 @@ class ModuleCloaking : public Module
                input.reserve(key.length() + 3 + item.length());
                input.append(1, id);
                input.append(key);
-               input.append(1, 0); // null does not terminate a C++ string
+               input.append(1, '\0'); // null does not terminate a C++ string
                input.append(item);
 
                std::string rv = Hash->sum(input).substr(0,len);
@@ -365,7 +365,11 @@ class ModuleCloaking : public Module
        // mode change, we will call SetMode back to true AFTER the host change is done.
        void OnChangeHost(User* u, const std::string& host)
        {
-               u->SetMode('x', false);
+               if(u->IsModeSet('x'))
+               {
+                       u->SetMode('x', false);
+                       u->WriteServ("MODE %s -x", u->nick.c_str());
+               }
        }
 
        ~ModuleCloaking()
@@ -485,8 +489,8 @@ class ModuleCloaking : public Module
                                {
                                        std::string tail = LastTwoDomainParts(host);
 
-                                       /* Generate a cloak using specialized Hash */
-                                       chost = prefix + "-" + Hash->sumIV(compatkey, xtab[(dest->host[0]) % 4], dest->host).substr(0,8) + tail;
+                                       // xtab is not used here due to a bug in 1.2 cloaking
+                                       chost = prefix + "-" + Hash->sumIV(compatkey, "0123456789abcdef", host).substr(0,8) + tail;
 
                                        /* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
                                         * according to the DNS RFC) then they get cloaked as an IP.