summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-07-12 20:53:19 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-07-12 20:53:19 +0000
commit8ed5d452db32932d2b1148332dd9012cb3aed625 (patch)
tree91db141c52b9be4b650d8be314107d962a6b4616 /src
parent0e4715e8e369414cdb140679b20f6e687fa6a853 (diff)
Okay, and there's the working version of it. Extbans that don't work on users have OnCheckStringExtBan. ;p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9988 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp43
-rw-r--r--src/modules.cpp1
2 files changed, 18 insertions, 26 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 7fd1036d2..e9d7f4a27 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -453,14 +453,13 @@ bool Channel::IsBanned(User* user)
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)
-// {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnCheckStringExtBan, OnCheckStringExtBan(str, 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] != ':')
@@ -472,40 +471,32 @@ bool Channel::IsExtBanned(const std::string &str, char type)
if (match(str, maskptr))
return true;
}
-// }
+ }
return false;
}
bool Channel::IsExtBanned(User *user, char type)
{
- char mask[MAXBUF];
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnCheckExtBan,OnCheckExtBan(user, this, type));
+ FOREACH_RESULT(I_OnCheckExtBan, OnCheckExtBan(user, this, type));
if (MOD_RESULT == -1)
return true;
else if (MOD_RESULT == 0)
{
+ char mask[MAXBUF];
snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString());
- for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
- {
- if (i->data[0] != type || i->data[1] != ':')
- continue;
+ // XXX: we should probably hook cloaked hosts in here somehow too..
+ if (this->IsExtBanned(mask, type))
+ return true;
- // Iterate past char and : to get to the mask without doing a data copy(!)
- std::string maskptr = i->data.substr(2);
+ if (this->IsExtBanned(user->GetFullHost(), type))
+ return true;
- /* This allows CIDR ban matching
- *
- * Full masked host Full unmasked host IP with/without CIDR
- */
- if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true)))
- {
- return true;
- }
- }
+ if (this->IsExtBanned(user->GetFullRealHost(), type))
+ return true;
}
return false;
diff --git a/src/modules.cpp b/src/modules.cpp
index d3de60f6a..8d6f3f9a1 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -144,6 +144,7 @@ int Module::OnCheckKey(User*, Channel*, const std::string&) { return 0; }
int Module::OnCheckLimit(User*, Channel*) { return 0; }
int Module::OnCheckBan(User*, Channel*) { return 0; }
int Module::OnCheckExtBan(User *, Channel *, char) { return 0; }
+int Module::OnCheckStringExtBan(const std::string &s, Channel *c, char type) { return 0; }
int Module::OnStats(char, User*, string_list&) { return 0; }
int Module::OnChangeLocalUserHost(User*, const std::string&) { return 0; }
int Module::OnChangeLocalUserGECOS(User*, const std::string&) { return 0; }