]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #1417 from B00mX0r/master+fix_1416
authorPeter Powell <petpow@saberuk.com>
Sun, 3 Dec 2017 13:51:36 +0000 (13:51 +0000)
committerGitHub <noreply@github.com>
Sun, 3 Dec 2017 13:51:36 +0000 (13:51 +0000)
Fix m_cloaking umode desync

src/modules/m_cloaking.cpp

index a1e4d1af70ef06adf485f86be36f9c5218a199bf..e5f912c95ffa30cc8ea42b0709fb43261ead210f 100644 (file)
@@ -42,14 +42,18 @@ static const char base32[] = "0123456789abcdefghijklmnopqrstuv";
 class CloakUser : public ModeHandler
 {
  public:
+       bool active;
        LocalStringExt ext;
        std::string debounce_uid;
        time_t debounce_ts;
        int debounce_count;
 
        CloakUser(Module* source)
-               : ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER),
-               ext("cloaked_host", ExtensionItem::EXT_USER, source), debounce_ts(0), debounce_count(0)
+               : ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER)
+               , active(false)
+               , ext("cloaked_host", ExtensionItem::EXT_USER, source)
+               , debounce_ts(0)
+               , debounce_count(0)
        {
        }
 
@@ -63,6 +67,8 @@ class CloakUser : public ModeHandler
                 */
                if (!user)
                {
+                       // Remote setters broadcast mode before host while local setters do the opposite, so this takes that into account
+                       active = IS_LOCAL(source) ? adding : !adding;
                        dest->SetMode(this, adding);
                        return MODEACTION_ALLOW;
                }
@@ -146,7 +152,11 @@ class ModuleCloaking : public Module
        unsigned int domainparts;
        dynamic_reference<HashProvider> Hash;
 
-       ModuleCloaking() : cu(this), mode(MODE_OPAQUE), ck(this), Hash(this, "hash/md5")
+       ModuleCloaking()
+               : cu(this)
+               , mode(MODE_OPAQUE)
+               , ck(this)
+               , Hash(this, "hash/md5")
        {
        }
 
@@ -300,11 +310,12 @@ 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) CXX11_OVERRIDE
        {
-               if (u->IsModeSet(cu))
+               if (u->IsModeSet(cu) && !cu.active)
                {
                        u->SetMode(cu, false);
                        u->WriteCommand("MODE", "-" + ConvToStr(cu.GetModeChar()));
                }
+               cu.active = false;
        }
 
        Version GetVersion() CXX11_OVERRIDE