From c18edeeea37d81dfdefe4f8a9d57a5d153da8e5b Mon Sep 17 00:00:00 2001 From: B00mX0r Date: Sat, 25 Nov 2017 11:53:42 -0800 Subject: Fix m_cloaking umode syncing Servers will now correctly show whether a remote user has +x or not. --- src/modules/m_cloaking.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index a1e4d1af7..e5f912c95 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -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 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 -- cgit v1.2.3