X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=7e6555ae80b94d666f22ae46aa60a1d10ae816df;hb=c8f515121fbdf3e4de693712ef2311cece45477d;hp=7f2485a49903ebcf4ebe34b77432bc4da7bf555f;hpb=b9e11915a976daaf790ebc763aff56e19fd49e0f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 7f2485a49..7e6555ae8 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -138,7 +138,7 @@ void Channel::SetDefaultModes() if (mode->IsPrefixMode()) continue; - if (mode->GetNumParams(true)) + if (mode->NeedsParam(true)) { list.GetToken(parameter); // If the parameter begins with a ':' then it's invalid @@ -148,7 +148,7 @@ void Channel::SetDefaultModes() else parameter.clear(); - if ((mode->GetNumParams(true)) && (parameter.empty())) + if ((mode->NeedsParam(true)) && (parameter.empty())) continue; mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true); @@ -181,7 +181,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co { unsigned int opermaxchans = ConvToInt(user->oper->getConfig("maxchans")); // If not set, use 2.0's , if that's not set either, use limit from CC - if (!opermaxchans) + if (!opermaxchans && user->HasPrivPermission("channels/high-join-limit")) opermaxchans = ServerInstance->Config->OperMaxChans; if (opermaxchans) maxchans = opermaxchans; @@ -267,7 +267,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co if (!limit.empty()) { FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan)); - if (!MOD_RESULT.check((chan->GetUserCounter() < atol(limit.c_str())))) + if (!MOD_RESULT.check(chan->GetUserCounter() < ConvToNum(limit))) { user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)"); return NULL; @@ -349,6 +349,9 @@ bool Channel::IsBanned(User* user) return (result == MOD_RES_DENY); ListModeBase* banlm = static_cast(*ban); + if (!banlm) + return false; + const ListModeBase::ModeList* bans = banlm->GetList(this); if (bans) { @@ -381,8 +384,8 @@ bool Channel::CheckBan(User* user, const std::string& mask) if (InspIRCd::Match(nickIdent, prefix, NULL)) { std::string suffix(mask, at + 1); - if (InspIRCd::Match(user->host, suffix, NULL) || - InspIRCd::Match(user->dhost, suffix, NULL) || + if (InspIRCd::Match(user->GetRealHost(), suffix, NULL) || + InspIRCd::Match(user->GetDisplayedHost(), suffix, NULL) || InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL)) return true; } @@ -397,12 +400,18 @@ ModResult Channel::GetExtBanStatus(User *user, char type) return rv; ListModeBase* banlm = static_cast(*ban); + if (!banlm) + return MOD_RES_PASSTHRU; + const ListModeBase::ModeList* bans = banlm->GetList(this); if (bans) { for (ListModeBase::ModeList::const_iterator it = bans->begin(); it != bans->end(); ++it) { - if (CheckBan(user, it->mask)) + if (it->mask.length() <= 2 || it->mask[0] != type || it->mask[1] != ':') + continue; + + if (CheckBan(user, it->mask.substr(2))) return MOD_RES_DENY; } } @@ -611,20 +620,17 @@ unsigned int Membership::getRank() return rv; } -const char* Membership::GetAllPrefixChars() const +std::string Membership::GetAllPrefixChars() const { - static char prefix[64]; - int ctr = 0; - + std::string ret; for (std::string::const_iterator i = modes.begin(); i != modes.end(); ++i) { PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(*i); if (mh && mh->GetPrefix()) - prefix[ctr++] = mh->GetPrefix(); + ret.push_back(mh->GetPrefix()); } - prefix[ctr] = 0; - return prefix; + return ret; } unsigned int Channel::GetPrefixValue(User* user)