diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-10 20:48:46 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-10 20:48:46 +0000 |
commit | 9d5dfe04342ea1842ff1e763a19a5fa65eaf034d (patch) | |
tree | 2eb1ccd992f340a6bdb519ed22c429a5bd867703 /src | |
parent | 1885e8805103c95aa75d73af8ee2fd55ad1b67e1 (diff) |
Fix for bug #513
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9449 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_cloaking.cpp | 55 |
2 files changed, 57 insertions, 3 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 5f0f545ae..838013c4c 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -433,7 +433,10 @@ bool Channel::IsBanned(User* user) char mask[MAXBUF]; int MOD_RESULT = 0; FOREACH_RESULT(I_OnCheckBan,OnCheckBan(user, this)); - if (!MOD_RESULT) + + if (MOD_RESULT == -1) + return true; + else if (MOD_RESULT == 0) { snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString()); for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 8a3a4e482..a0853b78b 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -12,6 +12,7 @@ */ #include "inspircd.h" +#include "wildcard.h" #include "m_hash.h" /* $ModDesc: Provides masking of user hostnames */ @@ -77,7 +78,10 @@ class CloakUser : public ModeHandler * This is fine, as we will recieve it later. */ if (!IS_LOCAL(dest)) + { + dest->SetMode('x',adding); return MODEACTION_ALLOW; + } /* don't allow this user to spam modechanges */ dest->IncreasePenalty(5); @@ -95,6 +99,16 @@ class CloakUser : public ModeHandler * are connecting via localhost) -- this doesnt matter much. */ + std::string* cloak; + + if (dest->GetExt("cloaked_host", cloak)) + { + /* Cloaked host has been set before on this user, don't bother to recalculate and waste cpu */ + dest->ChangeDisplayedHost(cloak->c_str()); + dest->SetMode('x',true); + return MODEACTION_ALLOW; + } + char* n1 = strchr(dest->host,'.'); char* n2 = strchr(dest->host,':'); @@ -161,6 +175,7 @@ class CloakUser : public ModeHandler } dest->ChangeDisplayedHost(b.c_str()); + dest->Extend("cloaked_host", new std::string(b)); } dest->SetMode('x',true); @@ -346,8 +361,44 @@ class ModuleCloaking : public Module ServerInstance->Modules->UseInterface("HashRequest"); - Implementation eventlist[] = { I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, 1); + Implementation eventlist[] = { I_OnRehash, I_OnUserDisconnect, I_OnCleanup, I_OnCheckBan }; + ServerInstance->Modules->Attach(eventlist, this, 4); + } + + virtual int OnCheckBan(User* user, Channel* chan) + { + char mask[MAXBUF]; + std::string* tofree; + /* Check if they have a cloaked host, but are not using it */ + if (user->GetExt("cloaked_host", tofree) && *tofree != user->dhost) + { + snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, tofree->c_str()); + for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) + { + if (match(mask,i->data)) + return -1; + } + } + return 0; + } + + void Prioritize() + { + /* Needs to be after m_banexception etc. */ + ServerInstance->Modules->SetPriority(this, I_OnCheckBan, PRIO_LAST); + } + + virtual void OnUserDisconnect(User* user) + { + std::string* tofree; + if (user->GetExt("cloaked_host", tofree)) + delete tofree; + } + + virtual void OnCleanup(int target_type, void* item) + { + if (target_type == TYPE_USER) + OnUserDisconnect((User*)item); } virtual ~ModuleCloaking() |