]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Update wiki links to use HTTPS and point to the correct pages.
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 61bf3f4e9f52c9efaed79248c8b81e1cb889a668..f4cfdb54f8b07c7186e11f1e5b27b1196a6c5ee5 100644 (file)
@@ -96,6 +96,10 @@ class CloakUser : public ModeHandler
 
                if (adding)
                {
+                       // assume this is more correct
+                       if (user->registered != REG_ALL && user->host != user->dhost)
+                               return MODEACTION_DENY;
+
                        std::string* cloak = ext.get(user);
 
                        if (!cloak)
@@ -164,7 +168,7 @@ class ModuleCloaking : public Module
                ServerInstance->Modules->AddService(cu.ext);
 
                Implementation eventlist[] = { I_OnRehash, I_OnCheckBan, I_OnUserConnect, I_OnChangeHost };
-               ServerInstance->Modules->Attach(eventlist, this, 4);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        /** This function takes a domain name string and returns just the last two domain parts,
@@ -493,11 +497,14 @@ class ModuleCloaking : public Module
        {
                std::string chost;
 
+               irc::sockets::sockaddrs hostip;
+               bool host_is_ip = irc::sockets::aptosa(host, ip.port(), hostip) && hostip == ip;
+
                switch (mode)
                {
                        case MODE_COMPAT_HOST:
                        {
-                               if (ipstr != host)
+                               if (!host_is_ip)
                                {
                                        std::string tail = LastTwoDomainParts(host);
 
@@ -520,7 +527,7 @@ class ModuleCloaking : public Module
                                break;
                        case MODE_HALF_CLOAK:
                        {
-                               if (ipstr != host)
+                               if (!host_is_ip)
                                        chost = prefix + SegmentCloak(host, 1, 6) + LastTwoDomainParts(host);
                                if (chost.empty() || chost.length() > 50)
                                        chost = SegmentIP(ip, false);