summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 5c3bb266f..dab518844 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -318,17 +318,10 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
sprintf(mask,"%s!%s@%s",user->nick, user->ident, user->GetIPString());
if (!MOD_RESULT)
{
- for (BanList::iterator i = Ptr->bans.begin(); i != Ptr->bans.end(); i++)
+ if (Ptr->IsBanned(user))
{
- /* This allows CIDR ban matching
- *
- * Full masked host Full unmasked host IP with/without CIDR
- */
- if ((match(user->GetFullHost(),i->data)) || (match(user->GetFullRealHost(),i->data)) || (match(mask, i->data, true)))
- {
- user->WriteServ("474 %s %s :Cannot join channel (You're banned)",user->nick, Ptr->name);
- return NULL;
- }
+ user->WriteServ("474 %s %s :Cannot join channel (You're banned)",user->nick, Ptr->name);
+ return NULL;
}
}
}
@@ -442,6 +435,25 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* u
return Ptr;
}
+bool chanrec::IsBanned(userrec* user)
+{
+ char mask[MAXBUF];
+ sprintf(mask,"%s!%s@%s",user->nick, user->ident, user->GetIPString());
+ for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
+ {
+ /* This allows CIDR ban matching
+ *
+ * Full masked host Full unmasked host IP with/without CIDR
+ */
+ if ((match(user->GetFullHost(),i->data)) || (match(user->GetFullRealHost(),i->data)) || (match(mask, i->data, true)))
+ {
+ return true;
+ }
+
+ }
+ return false;
+}
+
/* chanrec::PartUser
* remove a channel from a users record, and remove the record from the hash
* if the channel has become empty