]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Remove the intercomm system since sqlite is synchronous.
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 5a0fb910297b88fb5f0c18e13625ff0ea7753779..c0ebbc99bfdbe0f92d2a4985b97f811e9c7a2a51 100644 (file)
@@ -57,7 +57,7 @@ class CloakUser : public ModeHandler
                }
 
                /* don't allow this user to spam modechanges */
-               dest->IncreasePenalty(5);
+               IS_LOCAL(dest)->Penalty += 5;
 
                if (adding)
                {
@@ -74,10 +74,10 @@ class CloakUser : public ModeHandler
 
                                std::string* cloak = ext.get(dest);
 
-                               if (!cloak)
+                               if (!cloak && IS_LOCAL(dest))
                                {
                                        /* Force creation of missing cloak */
-                                       creator->OnUserConnect(dest);
+                                       creator->OnUserConnect(IS_LOCAL(dest));
                                        cloak = ext.get(dest);
                                }
                                if (cloak)
@@ -133,7 +133,7 @@ class ModuleCloaking : public Module
                        throw ModuleException("Could not add new modes!");
 
                ServerInstance->Modules->UseInterface("HashRequest");
-               Extensible::Register(&cu.ext);
+               ServerInstance->Extensions.Register(&cu.ext);
 
                Implementation eventlist[] = { I_OnRehash, I_OnCheckBan, I_OnUserConnect };
                ServerInstance->Modules->Attach(eventlist, this, 3);
@@ -237,15 +237,15 @@ class ModuleCloaking : public Module
                char rv[50];
                if (ip.sa.sa_family == AF_INET6)
                {
-                       snprintf(rv, 50, "%02x%02x.%02x%02x.%02x%02x.IP",
+                       snprintf(rv, 50, ".%02x%02x.%02x%02x.%02x%02x.IP",
                                ip.in6.sin6_addr.s6_addr[4], ip.in6.sin6_addr.s6_addr[5],
                                ip.in6.sin6_addr.s6_addr[2], ip.in6.sin6_addr.s6_addr[3],
                                ip.in6.sin6_addr.s6_addr[0], ip.in6.sin6_addr.s6_addr[1]);
                }
                else
                {
-                       const char* ip4 = (const char*)&ip.in4.sin_addr;
-                       snprintf(rv, 50, "%d.%d.IP", ip4[1], ip4[0]);
+                       const unsigned char* ip4 = (const unsigned char*)&ip.in4.sin_addr;
+                       snprintf(rv, 50, ".%d.%d.IP", ip4[1], ip4[0]);
                }
                return rv;
        }
@@ -305,7 +305,7 @@ class ModuleCloaking : public Module
        void CloakExistingUsers()
        {
                std::string* cloak;
-               for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
+               for (std::vector<LocalUser*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
                {
                        cloak = cu.ext.get(*u);
                        if (!cloak)
@@ -344,7 +344,7 @@ class ModuleCloaking : public Module
        {
                // returns the version number of the module to be
                // listed in /MODULES
-               return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR);
        }
 
        void OnRehash(User* user)
@@ -377,10 +377,10 @@ class ModuleCloaking : public Module
                         * We must limit the keys or else we get different results on
                         * amd64/x86 boxes. - psychon */
                        const unsigned int limit = 0x80000000;
-                       compatkey[1] = (unsigned int) Conf.ReadInteger("cloak","key1",0,false);
-                       compatkey[2] = (unsigned int) Conf.ReadInteger("cloak","key2",0,false);
-                       compatkey[3] = (unsigned int) Conf.ReadInteger("cloak","key3",0,false);
-                       compatkey[4] = (unsigned int) Conf.ReadInteger("cloak","key4",0,false);
+                       compatkey[0] = (unsigned int) Conf.ReadInteger("cloak","key1",0,false);
+                       compatkey[1] = (unsigned int) Conf.ReadInteger("cloak","key2",0,false);
+                       compatkey[2] = (unsigned int) Conf.ReadInteger("cloak","key3",0,false);
+                       compatkey[3] = (unsigned int) Conf.ReadInteger("cloak","key4",0,false);
 
                        if (!lowercase)
                        {
@@ -400,17 +400,17 @@ class ModuleCloaking : public Module
                        if (prefix.empty())
                                prefix = ServerInstance->Config->Network;
 
-                       if (!compatkey[1] || !compatkey[2] || !compatkey[3] || !compatkey[4] ||
-                               compatkey[1] >= limit || compatkey[2] >= limit || compatkey[3] >= limit || compatkey[4] >= limit)
+                       if (!compatkey[0] || !compatkey[1] || !compatkey[2] || !compatkey[3] ||
+                               compatkey[0] >= limit || compatkey[1] >= limit || compatkey[2] >= limit || compatkey[3] >= limit)
                        {
                                std::string detail;
-                               if (!compatkey[1] || compatkey[1] >= limit)
+                               if (!compatkey[0] || compatkey[0] >= limit)
                                        detail = "<cloak:key1> is not valid, it may be set to a too high/low value, or it may not exist.";
-                               else if (!compatkey[2] || compatkey[2] >= limit)
+                               else if (!compatkey[1] || compatkey[1] >= limit)
                                        detail = "<cloak:key2> is not valid, it may be set to a too high/low value, or it may not exist.";
-                               else if (!compatkey[3] || compatkey[3] >= limit)
+                               else if (!compatkey[2] || compatkey[2] >= limit)
                                        detail = "<cloak:key3> is not valid, it may be set to a too high/low value, or it may not exist.";
-                               else if (!compatkey[4] || compatkey[4] >= limit)
+                               else if (!compatkey[3] || compatkey[3] >= limit)
                                        detail = "<cloak:key4> is not valid, it may be set to a too high/low value, or it may not exist.";
 
                                throw ModuleException("You have not defined cloak keys for m_cloaking!!! THIS IS INSECURE AND SHOULD BE CHECKED! - " + detail);
@@ -424,7 +424,7 @@ class ModuleCloaking : public Module
                }
        }
 
-       void OnUserConnect(User* dest)
+       void OnUserConnect(LocalUser* dest)
        {
                std::string* cloak = cu.ext.get(dest);
                if (cloak)
@@ -471,12 +471,12 @@ class ModuleCloaking : public Module
                                        tail = LastTwoDomainParts(dest->host);
                                if (tail.empty() || tail.length() > 50)
                                        tail = ReversePartialIP(dest->client_sa);
-                               chost = prefix + SegmentCloak(dest->host, 1) + "." + tail;
+                               chost = prefix + SegmentCloak(dest->host, 1) + tail;
                                break;
                        }
                        case MODE_OPAQUE:
                        default:
-                               chost = SegmentIP(dest->client_sa);
+                               chost = prefix + SegmentIP(dest->client_sa);
                }
                cu.ext.set(dest,chost);
        }