X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_channel%2Fcore_channel.cpp;h=e95736ccc5d154447241d95dc8f31bceac4b9ea2;hb=2ab383f707ec648ceeb29059ce4f54d4bbb056a4;hp=4e49ba2b4a6ff1b41e095e3d82ec4bb89fc4ba5f;hpb=77730fd5f09f8fc193205654c8bba84d34365670;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp index 4e49ba2b4..e95736ccc 100644 --- a/src/coremods/core_channel/core_channel.cpp +++ b/src/coremods/core_channel/core_channel.cpp @@ -122,7 +122,7 @@ class CoreModChannel : public Module, public CheckExemption::EventListener public: CoreModChannel() - : CheckExemption::EventListener(this) + : CheckExemption::EventListener(this, UINT_MAX) , invapi(this) , cmdinvite(this, invapi) , cmdjoin(this) @@ -148,16 +148,6 @@ class CoreModChannel : public Module, public CheckExemption::EventListener void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* optionstag = ServerInstance->Config->ConfValue("options"); - Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan }; - if (optionstag->getBool("invitebypassmodes", true)) - ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation)); - else - { - for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++) - ServerInstance->Modules.Detach(events[i], this); - } - - joinhook.modefromuser = optionstag->getBool("cyclehostsfromuser"); std::string current; irc::spacesepstream defaultstream(optionstag->getString("exemptchanops")); @@ -174,26 +164,41 @@ class CoreModChannel : public Module, public CheckExemption::EventListener ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Exempting prefix %c from %s", prefix, restriction.c_str()); exempts[restriction] = prefix; } - exemptions.swap(exempts); ConfigTag* securitytag = ServerInstance->Config->ConfValue("security"); const std::string announceinvites = securitytag->getString("announceinvites", "dynamic"); + Invite::AnnounceState newannouncestate; if (stdalgo::string::equalsci(announceinvites, "none")) - cmdinvite.announceinvites = Invite::ANNOUNCE_NONE; + newannouncestate = Invite::ANNOUNCE_NONE; else if (stdalgo::string::equalsci(announceinvites, "all")) - cmdinvite.announceinvites = Invite::ANNOUNCE_ALL; + newannouncestate = Invite::ANNOUNCE_ALL; else if (stdalgo::string::equalsci(announceinvites, "ops")) - cmdinvite.announceinvites = Invite::ANNOUNCE_OPS; + newannouncestate = Invite::ANNOUNCE_OPS; else if (stdalgo::string::equalsci(announceinvites, "dynamic")) - cmdinvite.announceinvites = Invite::ANNOUNCE_DYNAMIC; + newannouncestate = Invite::ANNOUNCE_DYNAMIC; else throw ModuleException(announceinvites + " is an invalid value, at " + securitytag->getTagLocation()); + // Config is valid, apply it + + // Validates and applies tags, so do it first + banmode.DoRehash(); + + exemptions.swap(exempts); // In 2.0 we allowed limits of 0 to be set. This is non-standard behaviour // and will be removed in the next major release. - limitmode.minlimit = optionstag->getBool("allowzerolimit", true) ? 0 : 1; + limitmode.minlimit = optionstag->getBool("allowzerolimit", true) ? 0 : 1;; + cmdinvite.announceinvites = newannouncestate; + joinhook.modefromuser = optionstag->getBool("cyclehostsfromuser"); - banmode.DoRehash(); + Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan }; + if (optionstag->getBool("invitebypassmodes", true)) + ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation)); + else + { + for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++) + ServerInstance->Modules.Detach(events[i], this); + } } void On005Numeric(std::map& tokens) CXX11_OVERRIDE @@ -216,7 +221,10 @@ class CoreModChannel : public Module, public CheckExemption::EventListener if (!buffer.empty()) buffer.push_back(','); - buffer.append(iter->second); + std::string modes(iter->second); + std::sort(modes.begin(), modes.end()); + + buffer.append(modes); buffer.push_back(':'); buffer.append(ConvToStr(iter->first)); } @@ -236,7 +244,7 @@ class CoreModChannel : public Module, public CheckExemption::EventListener if (!MOD_RESULT.check(InspIRCd::TimingSafeCompare(ckey, keygiven))) { // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled) - user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (Incorrect channel key)"); + user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (incorrect channel key)"); return MOD_RES_DENY; } } @@ -248,7 +256,7 @@ class CoreModChannel : public Module, public CheckExemption::EventListener FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan)); if (MOD_RESULT != MOD_RES_ALLOW) { - user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (Invite only)"); + user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (invite only)"); return MOD_RES_DENY; } } @@ -260,7 +268,7 @@ class CoreModChannel : public Module, public CheckExemption::EventListener FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan)); if (!MOD_RESULT.check(chan->GetUserCounter() < static_cast(limitmode.ext.get(chan)))) { - user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)"); + user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (channel is full)"); return MOD_RES_DENY; } }