diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_ldapoper.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_chanhistory.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_chanlog.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_cloaking.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_customtitle.cpp | 24 | ||||
-rw-r--r-- | src/modules/m_dnsbl.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_namedmodes.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_sqloper.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_sslinfo.cpp | 14 |
10 files changed, 20 insertions, 88 deletions
diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp index 856e42dc3..f10773ec9 100644 --- a/src/modules/extra/m_ldapoper.cpp +++ b/src/modules/extra/m_ldapoper.cpp @@ -35,21 +35,6 @@ /* $ModDesc: Adds the ability to authenticate opers via LDAP */ /* $LinkerFlags: -lldap */ -// Duplicated code, also found in cmd_oper and m_sqloper -static bool OneOfMatches(const char* host, const char* ip, const std::string& hostlist) -{ - std::stringstream hl(hostlist); - std::string xhost; - while (hl >> xhost) - { - if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) - { - return true; - } - } - return false; -} - struct RAIILDAPString { char *str; @@ -97,7 +82,7 @@ class ModuleLDAPAuth : public Module std::string acceptedhosts = tag->getString("host"); std::string hostname = user->ident + "@" + user->host; - if (!OneOfMatches(hostname.c_str(), user->GetIPString().c_str(), acceptedhosts)) + if (!InspIRCd::MatchMask(acceptedhosts, hostname, user->GetIPString())) return false; if (!LookupOper(opername, inputpass)) diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index 3ee823b4a..6633e9582 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -133,7 +133,7 @@ class ModuleChanHistory : public Module sendnotice = tag->getBool("notice", true); } - void OnUserMessage(User* user,void* dest,int target_type, const std::string &text, char status, const CUList&) + void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList&) { if (target_type == TYPE_CHANNEL && status == 0) { @@ -141,10 +141,8 @@ class ModuleChanHistory : public Module HistoryList* list = m.ext.get(c); if (list) { - char buf[MAXBUF]; - snprintf(buf, MAXBUF, ":%s PRIVMSG %s :%s", - user->GetFullHost().c_str(), c->name.c_str(), text.c_str()); - list->lines.push_back(HistoryItem(buf)); + const std::string line = ":" + user->GetFullHost() + " PRIVMSG " + c->name + " :" + text; + list->lines.push_back(HistoryItem(line)); if (list->lines.size() > list->maxlen) list->lines.pop_front(); } diff --git a/src/modules/m_chanlog.cpp b/src/modules/m_chanlog.cpp index 4bfce2108..0f53ceedf 100644 --- a/src/modules/m_chanlog.cpp +++ b/src/modules/m_chanlog.cpp @@ -73,16 +73,15 @@ class ModuleChanLog : public Module if (itpair.first == itpair.second) return MOD_RES_PASSTHRU; - char buf[MAXBUF]; - snprintf(buf, MAXBUF, "\2%s\2: %s", desc.c_str(), msg.c_str()); + const std::string snotice = "\2" + desc + "\2: " + msg; for (ChanLogTargets::const_iterator it = itpair.first; it != itpair.second; ++it) { Channel *c = ServerInstance->FindChan(it->second); if (c) { - c->WriteChannelWithServ(ServerInstance->Config->ServerName, "PRIVMSG %s :%s", c->name.c_str(), buf); - ServerInstance->PI->SendChannelPrivmsg(c, 0, buf); + c->WriteChannelWithServ(ServerInstance->Config->ServerName, "PRIVMSG %s :%s", c->name.c_str(), snotice.c_str()); + ServerInstance->PI->SendChannelPrivmsg(c, 0, snotice); } } diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 691b61138..31b361b6f 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -295,9 +295,8 @@ class ModuleCloaking : public Module /* Check if they have a cloaked host, but are not using it */ if (cloak && *cloak != user->dhost) { - char cmask[MAXBUF]; - snprintf(cmask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), cloak->c_str()); - if (InspIRCd::Match(cmask,mask)) + const std::string cloakMask = user->nick + "!" + user->ident + "@" + *cloak; + if (InspIRCd::Match(cloakMask, mask)) return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index 1fc49190b..6b100605e 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -35,27 +35,10 @@ class CommandTitle : public Command syntax = "<user> <password>"; } - bool OneOfMatches(const char* host, const char* ip, const char* hostlist) - { - std::stringstream hl(hostlist); - std::string xhost; - while (hl >> xhost) - { - if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) - { - return true; - } - } - return false; - } - CmdResult Handle(const std::vector<std::string> ¶meters, User* user) { - char TheHost[MAXBUF]; - char TheIP[MAXBUF]; - - snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(), user->host.c_str()); - snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString().c_str()); + const std::string userHost = user->ident + "@" + user->host; + const std::string userIP = user->ident + "@" + user->GetIPString(); ConfigTagList tags = ServerInstance->Config->ConfTags("title"); for (ConfigIter i = tags.first; i != tags.second; ++i) @@ -67,7 +50,8 @@ class CommandTitle : public Command std::string title = i->second->getString("title"); std::string vhost = i->second->getString("vhost"); - if (Name == parameters[0] && !ServerInstance->PassCompare(user, pass, parameters[1], hash) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty()) + if (Name == parameters[0] && !ServerInstance->PassCompare(user, pass, parameters[1], hash) && + InspIRCd::MatchMask(host, userHost, userIP) && !title.empty()) { ctitle.set(user, title); diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 9e0b89fc3..a0ff5b84a 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -361,16 +361,12 @@ class ModuleDNSBL : public Module ServerInstance->Logs->Log("m_dnsbl", LOG_DEBUG, "User has no connect class in OnSetUserIP"); unsigned char a, b, c, d; - char reversedipbuf[128]; - std::string reversedip; - d = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF; c = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF; b = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF; a = (unsigned char) user->client_sa.in4.sin_addr.s_addr & 0xFF; - snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a); - reversedip = std::string(reversedipbuf); + const std::string reversedip = ConvToStr(d) + "." + ConvToStr(c) + "." + ConvToStr(b) + "." + ConvToStr(a); countExt.set(user, DNSBLConfEntries.size()); diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 9ff17924d..a367ecda3 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -160,10 +160,10 @@ class ModuleMsgFlood : public Module ServerInstance->SendGlobalMode(parameters, ServerInstance->FakeClient); } - char kickmessage[MAXBUF]; - snprintf(kickmessage, MAXBUF, "Channel flood triggered (limit is %u lines in %u secs)", f->lines, f->secs); + const std::string kickMessage = "Channel flood triggered (limit is " + ConvToStr(f->lines) + + " in " + ConvToStr(f->secs) + " secs)"; - dest->KickUser(ServerInstance->FakeClient, user, kickmessage); + dest->KickUser(ServerInstance->FakeClient, user, kickMessage); return MOD_RES_DENY; } diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 4db1f70b9..7d0d3a040 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -35,9 +35,8 @@ static void DisplayList(User* user, Channel* channel) if (mh->GetNumParams(true)) items << " " << channel->GetModeParameter(letter); } - char pfx[MAXBUF]; - snprintf(pfx, MAXBUF, ":%s 961 %s %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), channel->name.c_str()); - user->SendText(std::string(pfx), items); + const std::string line = ":" + ServerInstance->Config->ServerName + " 961 " + user->nick + " " + channel->name; + user->SendText(line, items); user->WriteNumeric(960, "%s %s :End of mode list", user->nick.c_str(), channel->name.c_str()); } diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index b5b020d9d..87ab7d46f 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -23,20 +23,6 @@ /* $ModDesc: Allows storage of oper credentials in an SQL table */ -static bool OneOfMatches(const char* host, const char* ip, const std::string& hostlist) -{ - std::stringstream hl(hostlist); - std::string xhost; - while (hl >> xhost) - { - if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) - { - return true; - } - } - return false; -} - class OpMeQuery : public SQLQuery { public: @@ -106,7 +92,7 @@ class OpMeQuery : public SQLQuery hostname.append("@").append(user->host); - if (OneOfMatches(hostname.c_str(), user->GetIPString().c_str(), pattern.c_str())) + if (InspIRCd::MatchMask(pattern, hostname, user->GetIPString())) { /* Opertype and host match, looks like this is it. */ diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 7c8cc12f2..f0f4fc155 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -158,20 +158,6 @@ class ModuleSSLInfo : public Module } } - bool OneOfMatches(const char* host, const char* ip, const char* hostlist) - { - std::stringstream hl(hostlist); - std::string xhost; - while (hl >> xhost) - { - if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) - { - return true; - } - } - return false; - } - ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) { if ((command == "OPER") && (validated)) |