From: Peter Powell Date: Sun, 15 Dec 2013 05:34:00 +0000 (+0000) Subject: Make various self contained methods static. X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;ds=sidebyside;h=ad47ea662698e72ff8f79b03512b1e7fe81bdf53;p=user%2Fhenk%2Fcode%2Finspircd.git Make various self contained methods static. - InspIRCd::IsValidMask - InspIRCd::TimeString --- diff --git a/include/inspircd.h b/include/inspircd.h index e02a5deb5..d045b347b 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -565,7 +565,7 @@ class CoreExport InspIRCd * @param mask A nick!user\@host masak to match against * @return True i the mask is valid */ - bool IsValidMask(const std::string &mask); + static bool IsValidMask(const std::string& mask); /** Strips all color codes from the given string * @param sentence The string to strip from @@ -685,7 +685,7 @@ class CoreExport InspIRCd /** Return a time_t as a human-readable string. */ - std::string TimeString(time_t curtime); + static std::string TimeString(time_t curtime); /** Begin execution of the server. * NOTE: this function NEVER returns. Internally, diff --git a/src/channels.cpp b/src/channels.cpp index 4e266fb7c..563bc2704 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -849,7 +849,7 @@ Invitation* Invitation::Find(Channel* c, LocalUser* u, bool check_expired) if ((check_expired) && (inv->expiry != 0) && (inv->expiry <= ServerInstance->Time())) { /* Expired invite, remove it. */ - std::string expiration = ServerInstance->TimeString(inv->expiry); + std::string expiration = InspIRCd::TimeString(inv->expiry); ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Find ecountered expired entry: %p expired %s", (void*) inv, expiration.c_str()); i = locallist.erase(i); inv->cull(); diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp index 67f67e9f0..8025ba15a 100644 --- a/src/commands/cmd_eline.cpp +++ b/src/commands/cmd_eline.cpp @@ -80,7 +80,7 @@ CmdResult CommandEline::Handle (const std::vector& parameters, User else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(), timestr.c_str(), parameters[2].c_str()); } diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp index bdb5c26b2..bc81172d3 100644 --- a/src/commands/cmd_gline.cpp +++ b/src/commands/cmd_gline.cpp @@ -87,7 +87,7 @@ CmdResult CommandGline::Handle (const std::vector& parameters, User else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(), timestr.c_str(), parameters[2].c_str()); } diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp index 20afae2a9..e95a7ca66 100644 --- a/src/commands/cmd_kline.cpp +++ b/src/commands/cmd_kline.cpp @@ -87,7 +87,7 @@ CmdResult CommandKline::Handle (const std::vector& parameters, User else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed K-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(), timestr.c_str(), parameters[2].c_str()); } diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp index bfc9e4519..06b0e74f1 100644 --- a/src/commands/cmd_qline.cpp +++ b/src/commands/cmd_qline.cpp @@ -63,7 +63,7 @@ CmdResult CommandQline::Handle (const std::vector& parameters, User else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s: %s",user->nick.c_str(),parameters[0].c_str(), timestr.c_str(), parameters[2].c_str()); } diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index bdd16b520..fab65aae3 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -62,7 +62,7 @@ CmdResult CommandWhowas::Handle (const std::vector& parameters, Use user->WriteNumeric(RPL_WHOWASIP, "%s :was connecting from *@%s", parameters[0].c_str(), u->host.c_str()); - std::string signon = ServerInstance->TimeString(u->signon); + std::string signon = InspIRCd::TimeString(u->signon); bool hide_server = (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")); user->WriteNumeric(RPL_WHOISSERVER, "%s %s :%s", parameters[0].c_str(), (hide_server ? ServerInstance->Config->HideWhoisServer.c_str() : u->server.c_str()), signon.c_str()); } diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp index fdb156e0a..2c5997558 100644 --- a/src/commands/cmd_zline.cpp +++ b/src/commands/cmd_zline.cpp @@ -83,7 +83,7 @@ CmdResult CommandZline::Handle (const std::vector& parameters, User else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s: %s",user->nick.c_str(),ipaddr, timestr.c_str(), parameters[2].c_str()); } diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 5f3f1c7f1..4fb0653a9 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -121,7 +121,7 @@ class CommandCBan : public Command else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), reason); } } diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 39639927c..0b61ec668 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -80,7 +80,7 @@ class ModuleConnectBan : public Module } ServerInstance->XLines->ApplyLines(); std::string maskstr = mask.str(); - std::string timestr = ServerInstance->TimeString(zl->expiry); + std::string timestr = InspIRCd::TimeString(zl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"Module m_connectban added Z:line on *@%s to expire on %s: Connect flooding", maskstr.c_str(), timestr.c_str()); ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", maskstr.c_str(), threshold); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index e5c8df6aa..487e4a7ed 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -168,7 +168,7 @@ class CommandDccallow : public Command length = InspIRCd::Duration(parameters[1]); } - if (!ServerInstance->IsValidMask(mask)) + if (!InspIRCd::IsValidMask(mask)) { return CMD_FAILURE; } diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index fa9e73bd4..48ce1d791 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -136,7 +136,7 @@ class DNSBLResolver : public DNS::Request "*", them->GetIPString()); if (ServerInstance->XLines->AddLine(kl,NULL)) { - std::string timestr = ServerInstance->TimeString(kl->expiry); + std::string timestr = InspIRCd::TimeString(kl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s", them->GetIPString().c_str(), timestr.c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); @@ -151,7 +151,7 @@ class DNSBLResolver : public DNS::Request "*", them->GetIPString()); if (ServerInstance->XLines->AddLine(gl,NULL)) { - std::string timestr = ServerInstance->TimeString(gl->expiry); + std::string timestr = InspIRCd::TimeString(gl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s", them->GetIPString().c_str(), timestr.c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); @@ -166,7 +166,7 @@ class DNSBLResolver : public DNS::Request them->GetIPString()); if (ServerInstance->XLines->AddLine(zl,NULL)) { - std::string timestr = ServerInstance->TimeString(zl->expiry); + std::string timestr = InspIRCd::TimeString(zl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s", them->GetIPString().c_str(), timestr.c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 0bfdc3565..35f88ea93 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -78,7 +78,7 @@ class RLine : public XLine ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString()); if (ServerInstance->XLines->AddLine(zl, NULL)) { - std::string timestr = ServerInstance->TimeString(zl->expiry); + std::string timestr = InspIRCd::TimeString(zl->expiry); ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on *@%s%s%s: %s", zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? timestr.c_str() : "", zl->reason.c_str()); added_zline = true; @@ -168,7 +168,7 @@ class CommandRLine : public Command else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s to expire on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str()); } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index f0524435b..075b80eb7 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -140,7 +140,7 @@ class CommandShun : public Command else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s", user->nick.c_str(), target.c_str(), timestr.c_str(), expr.c_str()); } diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp index d06317674..f4485030a 100644 --- a/src/modules/m_spanningtree/addline.cpp +++ b/src/modules/m_spanningtree/addline.cpp @@ -50,7 +50,7 @@ CmdResult CommandAddLine::Handle(User* usr, std::vector& params) { if (xl->duration) { - std::string timestr = ServerInstance->TimeString(xl->expiry); + std::string timestr = InspIRCd::TimeString(xl->expiry); ServerInstance->SNO->WriteToSnoMask('X',"%s added %s%s on %s to expire on %s: %s",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "-line" : "", params[1].c_str(), timestr.c_str(), params[5].c_str()); } diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index 7d40f0cc0..bb2fcdbc0 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -123,7 +123,7 @@ class CommandSvshold : public Command else { time_t c_requires_crap = duration + ServerInstance->Time(); - std::string timestr = ServerInstance->TimeString(c_requires_crap); + std::string timestr = InspIRCd::TimeString(c_requires_crap); ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str()); } } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 2441f1aa8..40cc162c1 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -75,7 +75,7 @@ class CommandTban : public Command setban.push_back(parameters[0]); setban.push_back("+b"); bool isextban = ((mask.size() > 2) && (mask[1] == ':')); - if (!isextban && !ServerInstance->IsValidMask(mask)) + if (!isextban && !InspIRCd::IsValidMask(mask)) mask.append("!*@*"); setban.push_back(mask);