summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-03-04 05:17:42 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-03-04 05:17:42 +0000
commitaa78167e12a291d0a8c334bab1c5eacbcb25082c (patch)
tree1b9a2c024ea18ad880b8342df23f41f98bafb863 /src
parenta898a149fbe7b19232115a068bdfd4da4b881c72 (diff)
Unset umode +x when a different vhost is set on a user
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12589 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_cloaking.cpp64
1 files changed, 28 insertions, 36 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 0d6e2b00a..8f3f42a92 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -59,47 +59,32 @@ class CloakUser : public ModeHandler
/* don't allow this user to spam modechanges */
IS_LOCAL(dest)->CommandFloodPenalty += 5000;
- if (adding)
+ if (adding && !dest->IsModeSet('x'))
{
- if(!dest->IsModeSet('x'))
+ std::string* cloak = ext.get(dest);
+
+ if (!cloak)
{
- /* The mode is being turned on - so attempt to
- * allocate the user a cloaked host using a non-reversible
- * algorithm (its simple, but its non-reversible so the
- * simplicity doesnt really matter). This algorithm
- * will not work if the user has only one level of domain
- * naming in their hostname (e.g. if they are on a lan or
- * are connecting via localhost) -- this doesnt matter much.
- */
-
- std::string* cloak = ext.get(dest);
-
- if (!cloak && IS_LOCAL(dest))
- {
- /* Force creation of missing cloak */
- creator->OnUserConnect(IS_LOCAL(dest));
- cloak = ext.get(dest);
- }
- if (cloak)
- {
- dest->ChangeDisplayedHost(cloak->c_str());
- dest->SetMode('x',true);
- return MODEACTION_ALLOW;
- }
+ /* Force creation of missing cloak */
+ creator->OnUserConnect(IS_LOCAL(dest));
+ cloak = ext.get(dest);
}
- }
- else
- {
- if (dest->IsModeSet('x'))
+ if (cloak)
{
- /* User is removing the mode, so just restore their real host
- * and make it match the displayed one.
- */
- dest->ChangeDisplayedHost(dest->host.c_str());
- dest->SetMode('x',false);
+ dest->ChangeDisplayedHost(cloak->c_str());
+ dest->SetMode('x',true);
return MODEACTION_ALLOW;
}
}
+ else if (!adding && dest->IsModeSet('x'))
+ {
+ /* User is removing the mode, so restore their real host
+ * and make it match the displayed one.
+ */
+ dest->ChangeDisplayedHost(dest->host.c_str());
+ dest->SetMode('x',false);
+ return MODEACTION_ALLOW;
+ }
return MODEACTION_DENY;
}
@@ -133,8 +118,8 @@ class ModuleCloaking : public Module
ServerInstance->Extensions.Register(&cu.ext);
- Implementation eventlist[] = { I_OnRehash, I_OnCheckBan, I_OnUserConnect };
- ServerInstance->Modules->Attach(eventlist, this, 3);
+ Implementation eventlist[] = { I_OnRehash, I_OnCheckBan, I_OnUserConnect, I_OnChangeHost };
+ ServerInstance->Modules->Attach(eventlist, this, 4);
}
/** This function takes a domain name string and returns just the last two domain parts,
@@ -330,6 +315,13 @@ class ModuleCloaking : public Module
ServerInstance->Modules->SetPriority(this, I_OnCheckBan, PRIORITY_LAST);
}
+ // this unsets umode +x on every host change. If we are actually doing a +x
+ // mode change, we will call SetMode back to true AFTER the host change is done.
+ void OnChangeHost(User* u, const std::string& host)
+ {
+ u->SetMode('x', false);
+ }
+
~ModuleCloaking()
{
}