diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_banredirect.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_blockamsg.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_cban.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_censor.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_dccallow.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_knock.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_services_account.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_silence.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/link.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/server.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 18 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 19 |
15 files changed, 49 insertions, 64 deletions
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index c44a10f05..f98cbd420 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -166,7 +166,7 @@ class BanRedirect : public ModeWatcher return false; } - if (assign(channel->name) == mask[CHAN]) + if (irc::equals(channel->name, mask[CHAN])) { source->WriteNumeric(690, channel->name, "You cannot set a ban redirection to the channel the ban is on"); return false; @@ -199,8 +199,7 @@ class BanRedirect : public ModeWatcher for(BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); redir++) { - /* Ugly as fuck */ - if((irc::string(redir->targetchan.c_str()) == irc::string(mask[CHAN].c_str())) && (irc::string(redir->banmask.c_str()) == irc::string(param.c_str()))) + if ((irc::equals(redir->targetchan, mask[CHAN])) && (irc::equals(redir->banmask, param))) { redirects->erase(redir); diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index 9614203c3..266497b90 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -37,11 +37,11 @@ class BlockedMessage { public: std::string message; - irc::string target; + std::string target; time_t sent; BlockedMessage(const std::string& msg, const std::string& tgt, time_t when) - : message(msg), target(tgt.c_str()), sent(when) + : message(msg), target(tgt), sent(when) { } }; @@ -116,7 +116,7 @@ class ModuleBlockAmsg : public Module // OR // The number of target channels is equal to the number of channels the sender is on..a little suspicious. // Check it's more than 1 too, or else users on one channel would have fun. - if ((m && (m->message == parameters[1]) && (m->target != parameters[0]) && (ForgetDelay != -1) && (m->sent >= ServerInstance->Time()-ForgetDelay)) || ((targets > 1) && (targets == user->chans.size()))) + if ((m && (m->message == parameters[1]) && (!irc::equals(m->target, parameters[0])) && (ForgetDelay != -1) && (m->sent >= ServerInstance->Time()-ForgetDelay)) || ((targets > 1) && (targets == user->chans.size()))) { // Block it... if (action == IBLOCK_KILLOPERS || action == IBLOCK_NOTICEOPERS) @@ -134,7 +134,7 @@ class ModuleBlockAmsg : public Module { // If there's already a BlockedMessage allocated, use it. m->message = parameters[1]; - m->target = parameters[0].c_str(); + m->target = parameters[0]; m->sent = ServerInstance->Time(); } else diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 2a969bec7..42cff2850 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -28,15 +28,13 @@ class CBan : public XLine { private: - std::string displaytext; - irc::string matchtext; + std::string matchtext; public: CBan(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& ch) : XLine(s_time, d, src, re, "CBAN") + , matchtext(ch) { - this->displaytext = ch; - this->matchtext = ch.c_str(); } // XXX I shouldn't have to define this @@ -47,14 +45,12 @@ public: bool Matches(const std::string &s) { - if (matchtext == s) - return true; - return false; + return irc::equals(matchtext, s); } const std::string& Displayable() { - return displaytext; + return matchtext; } }; diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index c8b6b73a8..d2a60275a 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -79,11 +79,11 @@ class ModuleCensor : public Module { if (index->second.empty()) { - user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first, "Your message contained a censored word, and was blocked"); + user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first.c_str(), "Your message contained a censored word, and was blocked"); return MOD_RES_DENY; } - SearchAndReplace(text2, index->first, index->second); + stdalgo::string::replace_all(text2, index->first, index->second); } } text = text2.c_str(); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index d8fbef69a..edf9d012f 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -328,12 +328,12 @@ class ModuleDCCAllow : public Module if (s == std::string::npos) return MOD_RES_PASSTHRU; - irc::string type = assign(buf.substr(0, s)); + const std::string type = buf.substr(0, s); ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow"); bool blockchat = conftag->getBool("blockchat"); - if (type == "SEND") + if (stdalgo::string::equalsci(type, "SEND")) { size_t first; @@ -386,7 +386,7 @@ class ModuleDCCAllow : public Module u->WriteNotice("If you trust " + user->nick + " and were expecting this, you can type /DCCALLOW HELP for information on the DCCALLOW system."); return MOD_RES_DENY; } - else if ((type == "CHAT") && (blockchat)) + else if ((blockchat) && (stdalgo::string::equalsci(type, "CHAT"))) { user->WriteNotice("The user " + u->nick + " is not accepting DCC CHAT requests from you."); u->WriteNotice(user->nick + " (" + user->ident + "@" + user->dhost + ") attempted to initiate a DCC CHAT session, which was blocked."); diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index a3e30ecb4..bd19a60ba 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -632,17 +632,15 @@ std::pair<bool, std::string> ModuleFilter::AddFilter(const std::string &freeform bool ModuleFilter::StringToFilterAction(const std::string& str, FilterAction& fa) { - irc::string s(str.c_str()); - - if (s == "gline") + if (stdalgo::string::equalsci(str, "gline")) fa = FA_GLINE; - else if (s == "block") + else if (stdalgo::string::equalsci(str, "block")) fa = FA_BLOCK; - else if (s == "silent") + else if (stdalgo::string::equalsci(str, "silent")) fa = FA_SILENT; - else if (s == "kill") + else if (stdalgo::string::equalsci(str, "kill")) fa = FA_KILL; - else if (s == "none") + else if (stdalgo::string::equalsci(str, "none")) fa = FA_NONE; else return false; diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index a6352749f..cf623c4ab 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -98,14 +98,12 @@ class ModuleKnock : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string knocknotify = ServerInstance->Config->ConfValue("knock")->getString("notify"); - irc::string notify(knocknotify.c_str()); - - if (notify == "numeric") + if (stdalgo::string::equalsci(knocknotify, "numeric")) { cmd.sendnotice = false; cmd.sendnumeric = true; } - else if (notify == "both") + else if (stdalgo::string::equalsci(knocknotify, "both")) { cmd.sendnotice = true; cmd.sendnumeric = true; diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 559f28ea8..e97e1b02f 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -181,7 +181,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE { /* On nickchange, if they have +r, remove it */ - if (user->IsModeSet(m5) && assign(user->nick) != oldnick) + if ((user->IsModeSet(m5)) && (ServerInstance->FindNickOnly(oldnick) != user)) m5.RemoveMode(user); } diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 0ec40a92f..cb065d2fc 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -167,8 +167,8 @@ class CommandSilence : public Command for (silencelist::iterator i = sl->begin(); i != sl->end(); i++) { // search through for the item - irc::string listitem = i->first.c_str(); - if (listitem == mask && i->second == pattern) + const std::string& listitem = i->first; + if ((irc::equals(listitem, mask)) && (i->second == pattern)) { sl->erase(i); user->WriteNumeric(950, user->nick, InspIRCd::Format("Removed %s %s from silence list", mask.c_str(), decomppattern.c_str())); @@ -200,8 +200,8 @@ class CommandSilence : public Command std::string decomppattern = DecompPattern(pattern); for (silencelist::iterator n = sl->begin(); n != sl->end(); n++) { - irc::string listitem = n->first.c_str(); - if (listitem == mask && n->second == pattern) + const std::string& listitem = n->first; + if ((irc::equals(listitem, mask)) && (n->second == pattern)) { user->WriteNumeric(952, user->nick, InspIRCd::Format("%s %s is already on your silence list", mask.c_str(), decomppattern.c_str())); return CMD_FAILURE; diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h index 21213fb3e..632982623 100644 --- a/src/modules/m_spanningtree/link.h +++ b/src/modules/m_spanningtree/link.h @@ -24,7 +24,7 @@ class Link : public refcountbase { public: reference<ConfigTag> tag; - irc::string Name; + std::string Name; std::string IPAddr; int Port; std::string SendPass; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 81543b0da..f26b3c828 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -194,7 +194,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) { bool ipvalid = true; - if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map)) + if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map)) { ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself."); return; @@ -318,9 +318,9 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++) { Link* x = *i; - if (InspIRCd::Match(x->Name.c_str(),parameters[0], rfc_case_insensitive_map)) + if (InspIRCd::Match(x->Name, parameters[0], ascii_case_insensitive_map)) { - if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map)) + if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map)) { user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Server \002%s\002 is ME, not connecting.", x->Name.c_str())); return MOD_RES_DENY; diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 3000dd391..50f63e117 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -98,7 +98,6 @@ Link* TreeSocket::AuthRemote(const parameterlist& params) return NULL; } - irc::string servername = params[0].c_str(); const std::string& sname = params[0]; const std::string& password = params[1]; const std::string& sid = params[3]; @@ -115,7 +114,7 @@ Link* TreeSocket::AuthRemote(const parameterlist& params) for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++) { Link* x = *i; - if (x->Name != servername && x->Name != "*") // open link allowance + if ((!stdalgo::string::equalsci(x->Name, sname)) && (x->Name != "*")) // open link allowance continue; if (!ComparePass(*x, password)) diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index e1642a086..a96c4a90c 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -37,7 +37,7 @@ * and only do minor initialization tasks ourselves. */ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr) - : linkID(assign(link->Name)), LinkState(CONNECTING), MyRoot(NULL), proto_version(0) + : linkID(link->Name), LinkState(CONNECTING), MyRoot(NULL), proto_version(0) , burstsent(false), age(ServerInstance->Time()) { capab = new CapabData; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 6de47de94..c1c32e80a 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -267,31 +267,31 @@ void SpanningTreeUtilities::ReadConfiguration() throw ModuleException("Invalid configuration, found a link tag without a name!" + (!L->IPAddr.empty() ? " IP address: "+L->IPAddr : "")); if (L->Name.find('.') == std::string::npos) - throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it must contain at least one '.' character"); + throw ModuleException("The link name '"+L->Name+"' is invalid as it must contain at least one '.' character"); if (L->Name.length() > ServerInstance->Config->Limits.MaxHost) - throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it is longer than " + ConvToStr(ServerInstance->Config->Limits.MaxHost) + " characters"); + throw ModuleException("The link name '"+L->Name+"' is invalid as it is longer than " + ConvToStr(ServerInstance->Config->Limits.MaxHost) + " characters"); if (L->RecvPass.empty()) - throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', recvpass not defined"); + throw ModuleException("Invalid configuration for server '"+L->Name+"', recvpass not defined"); if (L->SendPass.empty()) - throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', sendpass not defined"); + throw ModuleException("Invalid configuration for server '"+L->Name+"', sendpass not defined"); if ((L->SendPass.find(' ') != std::string::npos) || (L->RecvPass.find(' ') != std::string::npos)) - throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that contains a space character which is invalid"); + throw ModuleException("Link block '" + L->Name + "' has a password set that contains a space character which is invalid"); if ((L->SendPass[0] == ':') || (L->RecvPass[0] == ':')) - throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that begins with a colon (:) which is invalid"); + throw ModuleException("Link block '" + L->Name + "' has a password set that begins with a colon (:) which is invalid"); if (L->IPAddr.empty()) { L->IPAddr = "*"; - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want."); + ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + L->Name + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want."); } if (!L->Port) - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no port defined, you will not be able to /connect it."); + ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + L->Name + "' has no port defined, you will not be able to /connect it."); L->Fingerprint.erase(std::remove(L->Fingerprint.begin(), L->Fingerprint.end(), ':'), L->Fingerprint.end()); LinkBlocks.push_back(L); @@ -331,7 +331,7 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name) for (std::vector<reference<Link> >::iterator i = LinkBlocks.begin(); i != LinkBlocks.end(); ++i) { Link* x = *i; - if (InspIRCd::Match(x->Name.c_str(), name.c_str(), rfc_case_insensitive_map)) + if (InspIRCd::Match(x->Name, name, ascii_case_insensitive_map)) { return x; } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 8a627b9a6..874e6440f 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -28,7 +28,6 @@ class TimedBan { public: - std::string channel; std::string mask; time_t expire; Channel* chan; @@ -83,7 +82,6 @@ class CommandTban : public Command } TimedBan T; - std::string channelname = parameters[0]; unsigned long duration = InspIRCd::Duration(parameters[1]); unsigned long expire = duration + ServerInstance->Time(); if (duration < 1) @@ -114,7 +112,6 @@ class CommandTban : public Command } CUList tmp; - T.channel = channelname; T.mask = mask; T.expire = expire + (IS_REMOTE(user) ? 5 : 0); T.chan = channel; @@ -147,13 +144,13 @@ class BanWatcher : public ModeWatcher if (adding) return; - irc::string listitem = banmask.c_str(); - irc::string thischan = chan->name.c_str(); for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end(); ++i) { - irc::string target = i->mask.c_str(); - irc::string tchan = i->channel.c_str(); - if ((listitem == target) && (tchan == thischan)) + if (i->chan != chan) + continue; + + const std::string& target = i->mask; + if (irc::equals(banmask, target)) { TimedBanList.erase(i); break; @@ -206,13 +203,11 @@ class ModuleTimedBans : public Module for (timedbans::iterator i = expired.begin(); i != expired.end(); i++) { - std::string chan = i->channel; std::string mask = i->mask; - Channel* cr = ServerInstance->FindChan(chan); - if (cr) + Channel* cr = i->chan; { CUList empty; - std::string expiry = "*** Timed ban on " + chan + " expired."; + std::string expiry = "*** Timed ban on " + cr->name + " expired."; cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str()); ServerInstance->PI->SendChannelNotice(cr, '@', expiry); |