diff options
| author | 2021-07-04 14:45:03 +0100 | |
|---|---|---|
| committer | 2021-07-04 14:53:16 +0100 | |
| commit | 5bc4720d55116b1a668e32add2a2b2da459010f2 (patch) | |
| tree | 541228319bc34fc18277cd555998c3bb04ce70ae /src/modules | |
| parent | Move ModeParser::BuildPrefixes to core_mode. (diff) | |
| parent | Allow hostchange to select users based on connect class. (diff) | |
| download | inspircd++-5bc4720d55116b1a668e32add2a2b2da459010f2.tar.gz inspircd++-5bc4720d55116b1a668e32add2a2b2da459010f2.tar.bz2 inspircd++-5bc4720d55116b1a668e32add2a2b2da459010f2.zip | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_callerid.cpp | 10 | ||||
| -rw-r--r-- | src/modules/m_check.cpp | 50 | ||||
| -rw-r--r-- | src/modules/m_hostchange.cpp | 42 | ||||
| -rw-r--r-- | src/modules/m_services_account.cpp | 8 |
4 files changed, 60 insertions, 50 deletions
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 9cf857460..a86e0c0a5 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -138,14 +138,14 @@ struct CallerIDExtInfo : public ExtensionItem // We need to walk the list of users on our accept list, and remove ourselves from their wholistsme. for (const auto& user : dat->accepting) { - callerid_data* targ = this->Get(user, false); - if (!targ) + callerid_data* target = this->Get(user, false); + if (!target) { ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (1)"); continue; // shouldn't happen, but oh well. } - if (!stdalgo::vector::swaperase(targ->wholistsme, dat)) + if (!stdalgo::vector::swaperase(target->wholistsme, dat)) ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (2)"); } delete dat; @@ -289,8 +289,8 @@ public: } // Now, look them up, and add me to their list - callerid_data *targ = extInfo.Get(whotoadd, true); - targ->wholistsme.push_back(dat); + callerid_data* target = extInfo.Get(whotoadd, true); + target->wholistsme.push_back(dat); user->WriteNotice(whotoadd->nick + " is now on your accept list"); return true; diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 6a0b7c24c..798747541 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -164,8 +164,8 @@ class CommandCheck : public Command if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName)) return CmdResult::SUCCESS; - User* targetuser = ServerInstance->Users.Find(parameters[0]); - Channel* targchan = ServerInstance->Channels.Find(parameters[0]); + User* targetuser = ServerInstance->Users.FindNick(parameters[0]); + Channel* targetchan = ServerInstance->Channels.Find(parameters[0]); /* * Syntax of a /check reply: @@ -179,7 +179,7 @@ class CommandCheck : public Command if (targetuser) { - LocalUser* loctarg = IS_LOCAL(targetuser); + LocalUser* localtarget = IS_LOCAL(targetuser); /* /check on a user */ context.Write("nuh", targetuser->GetFullHost()); context.Write("realnuh", targetuser->GetFullRealHost()); @@ -190,8 +190,8 @@ class CommandCheck : public Command context.Write("uid", targetuser->uuid); context.Write("signon", targetuser->signon); context.Write("nickts", targetuser->age); - if (loctarg) - context.Write("lastmsg", loctarg->idle_lastmsg); + if (localtarget) + context.Write("lastmsg", localtarget->idle_lastmsg); if (targetuser->IsAway()) { @@ -204,26 +204,26 @@ class CommandCheck : public Command { /* user is an oper of type ____ */ context.Write("opertype", targetuser->oper->name); - if (loctarg) + if (localtarget) { - context.Write("chanmodeperms", GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL)); - context.Write("usermodeperms", GetAllowedOperOnlyModes(loctarg, MODETYPE_USER)); - context.Write("snomaskperms", GetAllowedOperOnlySnomasks(loctarg)); + context.Write("chanmodeperms", GetAllowedOperOnlyModes(localtarget, MODETYPE_CHANNEL)); + context.Write("usermodeperms", GetAllowedOperOnlyModes(localtarget, MODETYPE_USER)); + context.Write("snomaskperms", GetAllowedOperOnlySnomasks(localtarget)); context.Write("commandperms", targetuser->oper->AllowedOperCommands.ToString()); context.Write("permissions", targetuser->oper->AllowedPrivs.ToString()); } } - if (loctarg) + if (localtarget) { - context.Write("clientaddr", loctarg->client_sa.str()); - context.Write("serveraddr", loctarg->server_sa.str()); + context.Write("clientaddr", localtarget->client_sa.str()); + context.Write("serveraddr", localtarget->server_sa.str()); - std::string classname = loctarg->GetClass()->name; + std::string classname = localtarget->GetClass()->name; if (!classname.empty()) context.Write("connectclass", classname); - context.Write("exempt", loctarg->exempt ? "yes" : "no"); + context.Write("exempt", localtarget->exempt ? "yes" : "no"); } else context.Write("onip", targetuser->GetIPString()); @@ -235,23 +235,23 @@ class CommandCheck : public Command context.DumpExt(targetuser); } - else if (targchan) + else if (targetchan) { /* /check on a channel */ - context.Write("createdat", targchan->age); + context.Write("createdat", targetchan->age); - if (!targchan->topic.empty()) + if (!targetchan->topic.empty()) { /* there is a topic, assume topic related information exists */ - context.Write("topic", targchan->topic); - context.Write("topic_setby", targchan->setby); - context.Write("topic_setat", targchan->topicset); + context.Write("topic", targetchan->topic); + context.Write("topic_setby", targetchan->setby); + context.Write("topic_setat", targetchan->topicset); } - context.Write("modes", targchan->ChanModes(true)); - context.Write("membercount", ConvToStr(targchan->GetUserCounter())); + context.Write("modes", targetchan->ChanModes(true)); + context.Write("membercount", ConvToStr(targetchan->GetUserCounter())); - for (const auto& [u, memb] : targchan->GetUsers()) + for (const auto& [u, memb] : targetchan->GetUsers()) { /* * Unlike Asuka, I define a clone as coming from the same host. --w00t @@ -263,9 +263,9 @@ class CommandCheck : public Command } for (const auto& lm : ServerInstance->Modes.GetListModes()) - context.DumpListMode(lm, targchan); + context.DumpListMode(lm, targetchan); - context.DumpExt(targchan); + context.DumpExt(targetchan); } else { diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 86c00d592..57eb0ac92 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -45,27 +45,43 @@ class HostRule private: HostChangeAction action; std::string host; + std::string klass; std::string mask; insp::flat_set<long> ports; std::string prefix; std::string suffix; + void ReadConfig(std::shared_ptr<ConfigTag> tag) + { + // Parse <hostchange:class>. + klass = tag->getString("class"); + + // Parse <hostchange:port>. + const std::string portlist = tag->getString("ports"); + if (!portlist.empty()) + { + irc::portparser portrange(portlist, false); + while (int port = portrange.GetToken()) + ports.insert(port); + } + } + public: - HostRule(const std::string& Mask, const std::string& Host, const insp::flat_set<long>& Ports) + HostRule(std::shared_ptr<ConfigTag> tag, const std::string& Mask, const std::string& Host) : action(HCA_SET) , host(Host) , mask(Mask) - , ports(Ports) { + ReadConfig(tag); } - HostRule(HostChangeAction Action, const std::string& Mask, const insp::flat_set<long>& Ports, const std::string& Prefix, const std::string& Suffix) + HostRule(std::shared_ptr<ConfigTag> tag, HostChangeAction Action, const std::string& Mask, const std::string& Prefix, const std::string& Suffix) : action(Action) , mask(Mask) - , ports(Ports) , prefix(Prefix) , suffix(Suffix) { + ReadConfig(tag); } HostChangeAction GetAction() const @@ -80,6 +96,9 @@ class HostRule bool Matches(LocalUser* user) const { + if (!klass.empty() && !stdalgo::string::equalsci(klass, user->GetClass()->GetName())) + return false; + if (!ports.empty() && !ports.count(user->server_sa.port())) return false; @@ -138,26 +157,17 @@ private: if (mask.empty()) throw ModuleException("<hostchange:mask> is a mandatory field, at " + tag->source.str()); - insp::flat_set<long> ports; - const std::string portlist = tag->getString("ports"); - if (!portlist.empty()) - { - irc::portparser portrange(portlist, false); - while (long port = portrange.GetToken()) - ports.insert(port); - } - // Determine what type of host rule this is. const std::string action = tag->getString("action"); if (stdalgo::string::equalsci(action, "addaccount")) { // The hostname is in the format [prefix]<account>[suffix]. - rules.emplace_back(HostRule::HCA_ADDACCOUNT, mask, ports, tag->getString("prefix"), tag->getString("suffix")); + rules.emplace_back(tag, HostRule::HCA_ADDACCOUNT, mask, tag->getString("prefix"), tag->getString("suffix")); } else if (stdalgo::string::equalsci(action, "addnick")) { // The hostname is in the format [prefix]<nick>[suffix]. - rules.emplace_back(HostRule::HCA_ADDNICK, mask, ports, tag->getString("prefix"), tag->getString("suffix")); + rules.emplace_back(tag, HostRule::HCA_ADDNICK, mask, tag->getString("prefix"), tag->getString("suffix")); } else if (stdalgo::string::equalsci(action, "set")) { @@ -167,7 +177,7 @@ private: throw ModuleException("<hostchange:value> is a mandatory field when using the 'set' action, at " + tag->source.str()); // The hostname is in the format <value>. - rules.emplace_back(mask, value, ports); + rules.emplace_back(tag, mask, value); continue; } else diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 205f925be..ae5d69d3b 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -247,16 +247,16 @@ class ModuleServicesAccount { case MessageTarget::TYPE_CHANNEL: { - Channel* targchan = target.Get<Channel>(); + Channel* targetchan = target.Get<Channel>(); - if (!targchan->IsModeSet(regmoderatedmode) || is_registered) + if (!targetchan->IsModeSet(regmoderatedmode) || is_registered) return MOD_RES_PASSTHRU; - if (CheckExemption::Call(exemptionprov, user, targchan, "regmoderated") == MOD_RES_ALLOW) + if (CheckExemption::Call(exemptionprov, user, targetchan, "regmoderated") == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; // User is messaging a +M channel and is not registered or exempt. - user->WriteNumeric(ERR_NEEDREGGEDNICK, targchan->name, "You need to be identified to a registered account to message this channel"); + user->WriteNumeric(ERR_NEEDREGGEDNICK, targetchan->name, "You need to be identified to a registered account to message this channel"); return MOD_RES_DENY; } case MessageTarget::TYPE_USER: |
