diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-07-12 20:38:14 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-07-12 20:38:14 +0000 |
commit | 0e4715e8e369414cdb140679b20f6e687fa6a853 (patch) | |
tree | 18cdedd4a5c76c162fd9d3be5c6c7c31895f124c | |
parent | 12ffb909a66401f540234aecbeeee6f94ef2fc6d (diff) |
Overload IsExtBanned to provide a *string matching* version, this finally opens the way for non-hostmask based extbans, which is good ;p. On the downside, this requires rethinking of the extban exemption stuff I did yesterday.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9987 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/channels.h | 4 | ||||
-rw-r--r-- | src/channels.cpp | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/include/channels.h b/include/channels.h index 67a76f73b..0d4c4813c 100644 --- a/include/channels.h +++ b/include/channels.h @@ -535,6 +535,10 @@ class CoreExport Channel : public Extensible */ bool IsExtBanned(User *u, char type); + /** Overloaded version to check whether a particular string is extbanned + */ + bool IsExtBanned(const std::string &str, char type); + /** Clears the cached max bans value */ void ResetMaxBans(); diff --git a/src/channels.cpp b/src/channels.cpp index d917edb84..7fd1036d2 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -451,6 +451,32 @@ bool Channel::IsBanned(User* user) return false; } +bool Channel::IsExtBanned(const std::string &str, char type) +{ +// XXX XXX XXX need to figure out how to get this to work with string types... +// int MOD_RESULT = 0; +// FOREACH_RESULT(I_OnCheckExtBan,OnCheckExtBan(user, this, type)); + +// if (MOD_RESULT == -1) +// return true; +// else if (MOD_RESULT == 0) +// { + for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) + { + if (i->data[0] != type || i->data[1] != ':') + continue; + + // Iterate past char and : to get to the mask without doing a data copy(!) + std::string maskptr = i->data.substr(2); + + if (match(str, maskptr)) + return true; + } +// } + + return false; +} + bool Channel::IsExtBanned(User *user, char type) { char mask[MAXBUF]; |