return false;
}
-bool Channel::IsExtBanned(User *user, char type)
+bool Channel::IsExtBanned(const std::string &str, char type)
{
- // XXX. do we need events?
- char mask[MAXBUF];
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnCheckStringExtBan, OnCheckStringExtBan(str, this, type));
- snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString());
+ 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;
+ }
+ }
- for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
+ return false;
+}
+
+bool Channel::IsExtBanned(User *user, char type)
+{
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnCheckExtBan, OnCheckExtBan(user, this, type));
+
+ if (MOD_RESULT == -1)
+ return true;
+ else if (MOD_RESULT == 0)
{
- if (i->data[0] != type || i->data[1] != ':')
- continue;
+ char mask[MAXBUF];
+ snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString());
- // Iterate past char and : to get to the mask without doing a data copy(!)
- std::string maskptr = i->data.substr(2);
+ // XXX: we should probably hook cloaked hosts in here somehow too..
+ if (this->IsExtBanned(mask, 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)))
- {
+ if (this->IsExtBanned(user->GetFullHost(), type))
+ return true;
+
+ if (this->IsExtBanned(user->GetFullRealHost(), type))
return true;
- }
}
return false;