]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Change /CHECK <#channel> to correctly report timestamp since it might have been TS...
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 6163b41b7d092552021cdd1c461815e85282292d..31f9eea5d9cc7fdc1d0cc38a8b22a098f6d5abfa 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -69,9 +69,6 @@ class CloakUser : public ModeHandler
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
-               if (source != dest)
-                       return MODEACTION_DENY;
-
                /* For remote clients, we dont take any action, we just allow it.
                 * The local server where they are will set their cloak instead.
                 * This is fine, as we will recieve it later.
@@ -163,11 +160,6 @@ class CloakUser : public ModeHandler
 
        std::string Cloak6(const char* ip)
        {
-               /* Theyre using 4in6 (YUCK). Translate as ipv4 cloak */
-               if (!strncmp(ip, "0::ffff:", 8))
-                       return Cloak4(ip + 8);
-
-               /* If we get here, yes it really is an ipv6 ip */
                unsigned int iv[] = { key1, key2, key3, key4 };
                std::vector<std::string> hashies;
                std::string item;
@@ -292,8 +284,10 @@ class ModuleCloaking : public Module
 
                ServerInstance->Modules->UseInterface("HashRequest");
 
-               Implementation eventlist[] = { I_OnRehash, I_OnUserDisconnect, I_OnCleanup, I_OnCheckBan, I_OnUserConnect, I_OnSyncUserMetaData };
+               Implementation eventlist[] = { I_OnRehash, I_OnUserDisconnect, I_OnCleanup, I_OnCheckBan, I_OnUserConnect, I_OnSyncUserMetaData, I_OnCleanup };
                ServerInstance->Modules->Attach(eventlist, this, 6);
+
+               CloakExistingUsers();
        }
 
        void OnSyncUserMetaData(User* user, Module* proto,void* opaque, const std::string &extname, bool displayable)
@@ -306,6 +300,17 @@ 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++)
+               {
+                       if (!(*u)->GetExt("cloaked_host", cloak))
+                       {
+                               OnUserConnect(*u);
+                       }
+               }
+       }
 
        virtual int OnCheckBan(User* user, Channel* chan)
        {
@@ -338,7 +343,10 @@ class ModuleCloaking : public Module
        {
                std::string* tofree;
                if (user->GetExt("cloaked_host", tofree))
+               {
                        delete tofree;
+                       user->Shrink("cloaked_host");
+               }
        }
 
        virtual void OnCleanup(int target_type, void* item)