X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=d917edb84b6bfd03f4a301594ba56ccd19091eb2;hb=0a45c56f10efb2af30835652b75317f2969a0b06;hp=fbec272b37623b826ac5bd42206b695e22c084b9;hpb=4e599dd4fbfe5abc0d60a05008344e35e6bc870d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index fbec272b3..d917edb84 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -453,26 +453,32 @@ bool Channel::IsBanned(User* user) bool Channel::IsExtBanned(User *user, char type) { - // XXX. do we need events? char mask[MAXBUF]; + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnCheckExtBan,OnCheckExtBan(user, this, type)); - 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 (MOD_RESULT == -1) + return true; + else if (MOD_RESULT == 0) { - 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); + snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString()); - /* 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))) + for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) { - return true; + 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); + + /* 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; + } } } @@ -485,15 +491,9 @@ bool Channel::IsExtBanned(User *user, char type) * * XXX: bleh, string copy of reason, fixme! -- w00t */ -long Channel::PartUser(User *user, const char* reason) +long Channel::PartUser(User *user, std::string &reason) { bool silent = false; - std::string freason; - - if (reason) - freason = reason; - else - freason = ""; if (!user) return this->GetUserCounter(); @@ -501,10 +501,10 @@ long Channel::PartUser(User *user, const char* reason) UCListIter i = user->chans.find(this); if (i != user->chans.end()) { - FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, freason, silent)); + FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason, silent)); if (!silent) - this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason ? " :" : "", reason ? reason : ""); + this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : ":", reason.c_str()); user->chans.erase(i); this->RemoveAllPrefixes(user);