]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Various improvements to UNIX socket support.
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 756781ef052e6167dd5caf2dd70dc119b751d295..d9b2eb78970ea1861f1bdf82ae720eb4e648c7e7 100644 (file)
@@ -210,24 +210,24 @@ class ModuleCloaking : public Module
        {
                // The position at which we found the last dot.
                std::string::const_reverse_iterator dotpos;
-       
+
                // The number of dots we have seen so far.
                unsigned int seendots = 0;
-       
+
                for (std::string::const_reverse_iterator iter = host.rbegin(); iter != host.rend(); ++iter)
                {
                        if (*iter != '.')
                                continue;
-       
+
                        // We have found a dot!
                        dotpos = iter;
                        seendots += 1;
-       
+
                        // Do we have enough segments to stop?
                        if (seendots >= domainparts)
                                break;
                }
-       
+
                // We only returns a domain part if more than one label is
                // present. See above for a full explanation.
                if (!seendots)
@@ -435,7 +435,7 @@ class ModuleCloaking : public Module
                        else if (stdalgo::string::equalsci(mode, "full"))
                                newcloaks.push_back(CloakInfo(MODE_OPAQUE, key, prefix, suffix));
                        else
-                               throw ModuleException(mode + " is an invalid value for <cloak:mode>; acceptable values are 'half' and 'full', at " + tag->getTagLocation()); 
+                               throw ModuleException(mode + " is an invalid value for <cloak:mode>; acceptable values are 'half' and 'full', at " + tag->getTagLocation());
                }
 
                // The cloak configuration was valid so we can apply it.
@@ -466,6 +466,24 @@ class ModuleCloaking : public Module
                return chost;
        }
 
+       void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE
+       {
+               // Connecting users are handled in OnUserConnect not here.
+               if (user->registered != REG_ALL)
+                       return;
+
+               // Remove the cloaks and generate new ones.
+               cu.ext.unset(user);
+               OnUserConnect(user);
+
+               // If a user is using a cloak then update it.
+               if (user->IsModeSet(cu))
+               {
+                       CloakList* cloaklist = cu.ext.get(user);
+                       user->ChangeDisplayedHost(cloaklist->front());
+               }
+       }
+
        void OnUserConnect(LocalUser* dest) CXX11_OVERRIDE
        {
                if (cu.ext.get(dest))