Skip to content

Commit

Permalink
Move OnCheckBan into chanrec::IsBanned() so its always called for any…
Browse files Browse the repository at this point in the history
… attempt to check any ban

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5343 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
braindigitalis committed Sep 27, 2006
1 parent f2bf5b7 commit 29a6302
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/channels.cpp
Expand Up @@ -301,17 +301,12 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
}
if (Ptr->bans.size())
{
MOD_RESULT = 0;
FOREACH_RESULT_I(Instance,I_OnCheckBan,OnCheckBan(user, Ptr));
char mask[MAXBUF];
snprintf(mask, MAXBUF, "%s!%s@%s",user->nick, user->ident, user->GetIPString());
if (!MOD_RESULT)
if (Ptr->IsBanned(user))
{
if (Ptr->IsBanned(user))
{
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;
}
}
}
Expand Down Expand Up @@ -443,18 +438,22 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* u
bool chanrec::IsBanned(userrec* user)
{
char mask[MAXBUF];
snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
int MOD_RESULT = 0;
FOREACH_RESULT_I(Instance,I_OnCheckBan,OnCheckBan(user, Ptr));
if (!MOD_RESULT)
{
/* 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)))
snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
{
return true;
/* 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;
}
Expand Down

0 comments on commit 29a6302

Please sign in to comment.