summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-04 21:43:21 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-04 21:43:21 +0000
commitf00094febf62beb74fb45a765a9fccd1ba4c8b8b (patch)
treed532bc5147fc104a75bf75427240dc5056395c97 /src/channels.cpp
parentccea6c12cd10e26c3ccacc91fdc16897d00582de (diff)
The start of extended bans infrastructure: syntax is e.g. +b n:w00tdiff@*, bans of any type can be applied and checked against, but there's more to come with this.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9337 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index c03a69ace..5dde87117 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -450,6 +450,38 @@ bool Channel::IsBanned(User* user)
return false;
}
+bool Channel::IsExtBanned(User *user, char type)
+{
+ // XXX. do we need events?
+ char mask[MAXBUF];
+ char *maskptr;
+
+ snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
+
+ 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(!)
+ maskptr = i->data;
+ maskptr++; // past the char
+ maskptr++; // past the :
+printf("realmask: %s\n", maskptr);
+
+ /* 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;
+ }
+ }
+
+ return false;
+}
+
/* Channel::PartUser
* remove a channel from a users record, and return the number of users left.
* Therefore, if this function returns 0 the caller should delete the Channel.