X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Flistmode.cpp;h=f3b2d5fc57937e93c339c3a077b6fb2aec7219cf;hb=ff06be6c442359aa223aa68c43d1d8c41920fb91;hp=1ce0da500fca08dabe17a75b58a1b80181932335;hpb=87b1461e2a4710a38b32186c2582da9fe9bb3804;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/listmode.cpp b/src/listmode.cpp index 1ce0da500..f3b2d5fc5 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -1,7 +1,10 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2018 linuxdaemon + * Copyright (C) 2018 B00mX0r + * Copyright (C) 2017-2019 Sadie Powell + * Copyright (C) 2013-2014, 2016 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -64,6 +67,7 @@ void ListModeBase::DoRehash() { ConfigTagList tags = ServerInstance->Config->ConfTags("maxlist"); limitlist newlimits; + bool seen_default = false; for (ConfigIter i = tags.first; i != tags.second; i++) { ConfigTag* c = i->second; @@ -72,20 +76,24 @@ void ListModeBase::DoRehash() if (!mname.empty() && !stdalgo::string::equalsci(mname, name) && !(mname.length() == 1 && GetModeChar() == mname[0])) continue; - ListLimit limit(c->getString("chan", "*"), c->getUInt("limit", 0)); + ListLimit limit(c->getString("chan", "*", 1), c->getUInt("limit", DEFAULT_LIST_SIZE)); if (limit.mask.empty()) throw ModuleException(InspIRCd::Format(" is empty, at %s", c->getTagLocation().c_str())); - if (limit.limit <= 0) - throw ModuleException(InspIRCd::Format(" must be non-zero, at %s", c->getTagLocation().c_str())); + if (limit.mask == "*" || limit.mask == "#*") + seen_default = true; newlimits.push_back(limit); } - // Add the default entry. This is inserted last so if the user specifies a - // wildcard record in the config it will take precedence over this entry. - newlimits.push_back(ListLimit("*", DEFAULT_LIST_SIZE)); + // If no default limit has been specified then insert one. + if (!seen_default) + { + ServerInstance->Logs->Log("MODE", LOG_DEBUG, "No default entry was found for the %s mode; defaulting to %u", + name.c_str(), DEFAULT_LIST_SIZE); + newlimits.push_back(ListLimit("*", DEFAULT_LIST_SIZE)); + } // Most of the time our settings are unchanged, so we can avoid iterating the chanlist if (chanlimits == newlimits) @@ -112,7 +120,7 @@ unsigned int ListModeBase::FindLimit(const std::string& channame) return it->limit; } } - return DEFAULT_LIST_SIZE; + return 0; } unsigned int ListModeBase::GetLimitInternal(const std::string& channame, ChanData* cd) @@ -133,13 +141,16 @@ unsigned int ListModeBase::GetLimit(Channel* channel) unsigned int ListModeBase::GetLowerLimit() { + if (chanlimits.empty()) + return DEFAULT_LIST_SIZE; + unsigned int limit = UINT_MAX; for (limitlist::iterator iter = chanlimits.begin(); iter != chanlimits.end(); ++iter) { if (iter->limit < limit) limit = iter->limit; } - return limit == UINT_MAX ? DEFAULT_LIST_SIZE : limit; + return limit; } ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) @@ -152,9 +163,6 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std if (tidy) ModeParser::CleanMask(parameter); - if (parameter.length() > 250) - return MODEACTION_DENY; - // If there was no list if (!cd) {