diff options
| author | 2025-03-03 14:58:58 +0000 | |
|---|---|---|
| committer | 2025-03-03 14:58:58 +0000 | |
| commit | d4d2293244c1845d2ca44708e82cad0bd38741e5 (patch) | |
| tree | e6c03e062dd5b2dc13f215169ab11455a2b89d88 /modules | |
| parent | Merge branch 'insp4' into master. (diff) | |
| parent | Use Duration::ToHuman instead of seconds in various messages. (diff) | |
Merge branch 'insp4' into master.
Diffstat (limited to 'modules')
34 files changed, 91 insertions, 56 deletions
diff --git a/modules/cban.cpp b/modules/cban.cpp index 5336226eb..2d7c44fa0 100644 --- a/modules/cban.cpp +++ b/modules/cban.cpp @@ -142,7 +142,7 @@ public: else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed CBan on {}, expires in {} (on {}): {}", - user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), r->reason); + user->nick, parameters[0], Duration::ToHuman(duration), Time::FromNow(duration), r->reason); } } else diff --git a/modules/chanhistory.cpp b/modules/chanhistory.cpp index 866b60190..d46bb1640 100644 --- a/modules/chanhistory.cpp +++ b/modules/chanhistory.cpp @@ -283,7 +283,7 @@ public: { auto message = FMT::format("Replaying up to {} lines of pre-join history", list->maxlen); if (list->maxtime > 0) - message += FMT::format(" from the last {}", Duration::ToString(list->maxtime)); + message += FMT::format(" from the last {}", Duration::ToHuman(list->maxtime)); memb->WriteNotice(message); } diff --git a/modules/connectban.cpp b/modules/connectban.cpp index 7ddccf345..99efe369e 100644 --- a/modules/connectban.cpp +++ b/modules/connectban.cpp @@ -159,7 +159,7 @@ public: } ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}", - zl->source, maskstr, Duration::ToString(zl->duration), + zl->source, maskstr, Duration::ToHuman(zl->duration), Time::ToString(zl->expiry), zl->reason); ServerInstance->SNO.WriteGlobalSno('a', "Connect flooding from IP range {} ({})", maskstr, threshold); connects.erase(i); diff --git a/modules/core/core_info/core_info.cpp b/modules/core/core_info/core_info.cpp index 11baf34f2..102a27cc9 100644 --- a/modules/core/core_info/core_info.cpp +++ b/modules/core/core_info/core_info.cpp @@ -62,6 +62,7 @@ struct ISupportAction final class CoreModInfo final : public Module + , public ISupport::EventListener { private: CommandAdmin cmdadmin; @@ -111,6 +112,7 @@ private: public: CoreModInfo() : Module(VF_CORE | VF_VENDOR, "Provides the ADMIN, COMMANDS, INFO, MODULES, MOTD, TIME, SERVLIST, and VERSION commands") + , ISupport::EventListener(this) , cmdadmin(this) , cmdcommands(this) , cmdinfo(this) @@ -237,6 +239,12 @@ public: { ServerInstance->Modules.SetPriority(this, I_OnUserConnect, PRIORITY_FIRST); } + + void OnBuildClassISupport(const std::shared_ptr<ConnectClass>& klass, ISupport::TokenMap& tokens) override + { + if (klass->fakelag) + tokens["FAKELAG"]; + } }; MODULE_INIT(CoreModInfo) diff --git a/modules/core/core_oper/core_oper.cpp b/modules/core/core_oper/core_oper.cpp index 6a442f000..712c51677 100644 --- a/modules/core/core_oper/core_oper.cpp +++ b/modules/core/core_oper/core_oper.cpp @@ -217,7 +217,7 @@ public: std::string extra; if (oper->IsAway()) { - const std::string awayperiod = Duration::ToString(ServerInstance->Time() - oper->away->time); + const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - oper->away->time); const std::string awaytime = Time::ToString(oper->away->time); extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message); @@ -226,7 +226,7 @@ public: auto* loper = IS_LOCAL(oper); if (loper) { - const std::string idleperiod = Duration::ToString(ServerInstance->Time() - loper->idle_lastmsg); + const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - loper->idle_lastmsg); const std::string idletime = Time::ToString(loper->idle_lastmsg); extra += FMT::format("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime); diff --git a/modules/core/core_xline/cmd_eline.cpp b/modules/core/core_xline/cmd_eline.cpp index c51081074..61e407ec2 100644 --- a/modules/core/core_xline/cmd_eline.cpp +++ b/modules/core/core_xline/cmd_eline.cpp @@ -83,7 +83,7 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters) else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed E-line on {}, expires in {} (on {}): {}", - user->nick, target, Duration::ToString(duration), Time::FromNow(duration), el->reason); + user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), el->reason); } } else diff --git a/modules/core/core_xline/cmd_gline.cpp b/modules/core/core_xline/cmd_gline.cpp index bf90946e0..59a393b5e 100644 --- a/modules/core/core_xline/cmd_gline.cpp +++ b/modules/core/core_xline/cmd_gline.cpp @@ -90,7 +90,7 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters) else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed G-line on {}, expires in {} (on {}): {}", - user->nick, target, Duration::ToString(duration), Time::FromNow(duration), gl->reason); + user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), gl->reason); } ServerInstance->XLines->ApplyLines(); diff --git a/modules/core/core_xline/cmd_kline.cpp b/modules/core/core_xline/cmd_kline.cpp index 46917d45f..68d5e8e62 100644 --- a/modules/core/core_xline/cmd_kline.cpp +++ b/modules/core/core_xline/cmd_kline.cpp @@ -90,7 +90,7 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters) else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed K-line on {}, expires in {} (on {}): {}", - user->nick, target, Duration::ToString(duration), Time::FromNow(duration), kl->reason); + user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), kl->reason); } ServerInstance->XLines->ApplyLines(); diff --git a/modules/core/core_xline/cmd_qline.cpp b/modules/core/core_xline/cmd_qline.cpp index 1b107d613..e8327d702 100644 --- a/modules/core/core_xline/cmd_qline.cpp +++ b/modules/core/core_xline/cmd_qline.cpp @@ -72,7 +72,7 @@ CmdResult CommandQline::Handle(User* user, const Params& parameters) else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Q-line on {}, expires in {} (on {}): {}", - user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), ql->reason); + user->nick, parameters[0], Duration::ToHuman(duration), Time::FromNow(duration), ql->reason); } ServerInstance->XLines->ApplyLines(); } diff --git a/modules/core/core_xline/cmd_zline.cpp b/modules/core/core_xline/cmd_zline.cpp index 54ce96c98..6bd909932 100644 --- a/modules/core/core_xline/cmd_zline.cpp +++ b/modules/core/core_xline/cmd_zline.cpp @@ -89,7 +89,7 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters) else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}", - user->nick, ipaddr, Duration::ToString(duration), Time::FromNow(duration), zl->reason); + user->nick, ipaddr, Duration::ToHuman(duration), Time::FromNow(duration), zl->reason); } ServerInstance->XLines->ApplyLines(); } diff --git a/modules/dccallow.cpp b/modules/dccallow.cpp index 02d53354f..3d3e71291 100644 --- a/modules/dccallow.cpp +++ b/modules/dccallow.cpp @@ -325,7 +325,7 @@ public: if (length > 0) { - user->WriteNumeric(RPL_DCCALLOWTIMED, user->nick, FMT::format("Added {} to DCCALLOW list for {}", target->nick, Duration::ToString(length))); + user->WriteNumeric(RPL_DCCALLOWTIMED, user->nick, FMT::format("Added {} to DCCALLOW list for {}", target->nick, Duration::ToHuman(length))); } else { diff --git a/modules/delaymsg.cpp b/modules/delaymsg.cpp index dc56cf210..3ed216ea7 100644 --- a/modules/delaymsg.cpp +++ b/modules/delaymsg.cpp @@ -25,6 +25,7 @@ #include "inspircd.h" #include "modules/ctctags.h" #include "modules/exemption.h" +#include "timeutils.h" #include "numerichelper.h" class DelayMsgMode final @@ -139,7 +140,8 @@ ModResult ModuleDelayMsg::HandleMessage(User* user, const MessageTarget& target) if (user->HasPrivPermission("channels/ignore-delaymsg")) return MOD_RES_PASSTHRU; - const std::string message = FMT::format("You cannot send messages to this channel until you have been a member for {} seconds.", len); + const std::string message = FMT::format("You cannot send messages to this channel until you have been a member for {}.", + Duration::ToHuman(len)); user->WriteNumeric(Numerics::CannotSendTo(channel, message)); return MOD_RES_DENY; } diff --git a/modules/dnsbl.cpp b/modules/dnsbl.cpp index 126cac398..3fe6d939a 100644 --- a/modules/dnsbl.cpp +++ b/modules/dnsbl.cpp @@ -259,7 +259,7 @@ private: } ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed {} on {}, expires in {} (on {}): {}", - line->source, type, line->Displayable(), Duration::ToString(line->duration), + line->source, type, line->Displayable(), Duration::ToHuman(line->duration), Time::ToString(line->expiry), line->reason); ServerInstance->XLines->ApplyLines(); } diff --git a/modules/extra/ssl_gnutls.cpp b/modules/extra/ssl_gnutls.cpp index a1b4104f7..f79496da4 100644 --- a/modules/extra/ssl_gnutls.cpp +++ b/modules/extra/ssl_gnutls.cpp @@ -736,7 +736,7 @@ private: else if (certinfo->activation >= ServerInstance->Time()) { certinfo->error = FMT::format("Certificate not active for {} (on {})", - Duration::ToString(certinfo->activation - ServerInstance->Time()), + Duration::ToHuman(certinfo->activation - ServerInstance->Time()), Time::ToString(certinfo->activation)); } @@ -749,7 +749,7 @@ private: else if (certinfo->expiration <= ServerInstance->Time()) { certinfo->error = FMT::format("Certificate expired {} ago (on {})", - Duration::ToString(ServerInstance->Time() - certinfo->expiration), + Duration::ToHuman(ServerInstance->Time() - certinfo->expiration), Time::ToString(certinfo->expiration)); } diff --git a/modules/extra/ssl_openssl.cpp b/modules/extra/ssl_openssl.cpp index edd8a9f68..8c459d9e0 100644 --- a/modules/extra/ssl_openssl.cpp +++ b/modules/extra/ssl_openssl.cpp @@ -577,7 +577,7 @@ private: if (activated != -1 && activated != 0) { certinfo->error = FMT::format("Certificate not active for {} (on {})", - Duration::ToString(certinfo->activation - ServerInstance->Time()), + Duration::ToHuman(certinfo->activation - ServerInstance->Time()), Time::ToString(certinfo->activation)); } @@ -585,7 +585,7 @@ private: if (expired != 0 && expired != 1) { certinfo->error = FMT::format("Certificate expired {} ago (on {})", - Duration::ToString(ServerInstance->Time() - certinfo->expiration), + Duration::ToHuman(ServerInstance->Time() - certinfo->expiration), Time::ToString(certinfo->expiration)); } diff --git a/modules/filter.cpp b/modules/filter.cpp index 9e7ffbd76..4ca8dfdc6 100644 --- a/modules/filter.cpp +++ b/modules/filter.cpp @@ -318,7 +318,7 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters) if (result.first) { const std::string message = FMT::format("'{}', type '{}'{}, flags '{}', reason: {}", freeform, parameters[1], - (duration ? FMT::format(", duration '{}'", Duration::ToString(duration)) : ""), + (duration ? FMT::format(", duration '{}'", Duration::ToHuman(duration)) : ""), flags, parameters[reasonindex]); user->WriteNotice("*** Added filter " + message); @@ -471,7 +471,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, M { auto* sh = new Shun(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their message to {} matched {} ({})", - user->nick, sh->Displayable(), Duration::ToString(f->duration), + user->nick, sh->Displayable(), Duration::ToHuman(f->duration), Time::FromNow(f->duration), msgtarget.GetName(), f->freeform, f->reason); if (ServerInstance->XLines->AddLine(sh, nullptr)) @@ -485,7 +485,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, M { auto* gl = new GLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their message to {} matched {} ({})", - user->nick, gl->Displayable(), Duration::ToString(f->duration), + user->nick, gl->Displayable(), Duration::ToHuman(f->duration), Time::FromNow(f->duration), msgtarget.GetName(), f->freeform, f->reason); if (ServerInstance->XLines->AddLine(gl, nullptr)) @@ -499,7 +499,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, M { auto* zl = new ZLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their message to {} matched {} ({})", - user->nick, zl->Displayable(), Duration::ToString(f->duration), + user->nick, zl->Displayable(), Duration::ToHuman(f->duration), Time::FromNow(f->duration), msgtarget.GetName(), f->freeform, f->reason); if (ServerInstance->XLines->AddLine(zl, nullptr)) @@ -577,7 +577,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& auto* gl = new GLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their {} message matched {} ({})", user->nick, gl->Displayable(), - Duration::ToString(f->duration), + Duration::ToHuman(f->duration), Time::FromNow(f->duration), command, f->freeform, f->reason); @@ -593,7 +593,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& auto* zl = new ZLine(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their {} message matched {} ({})", user->nick, zl->Displayable(), - Duration::ToString(f->duration), + Duration::ToHuman(f->duration), Time::FromNow(f->duration), command, f->freeform, f->reason); @@ -610,7 +610,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& auto* sh = new Shun(ServerInstance->Time(), f->duration, MODNAME "@" + ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their {} message matched {} ({})", user->nick, sh->Displayable(), - Duration::ToString(f->duration), + Duration::ToHuman(f->duration), Time::FromNow(f->duration), command, f->freeform, f->reason); @@ -975,7 +975,7 @@ bool ModuleFilter::Tick() // Back off a bit to avoid spamming opers. if (backoff > 1) SetInterval(std::min(GetInterval() * backoff, maxbackoff), false); - ServerInstance->Logs.Debug(MODNAME, "Trying again in {} seconds", GetInterval()); + ServerInstance->Logs.Debug(MODNAME, "Trying again in {}", Duration::ToHuman(GetInterval())); } } return true; diff --git a/modules/helpmode.cpp b/modules/helpmode.cpp index a4103f730..96304b477 100644 --- a/modules/helpmode.cpp +++ b/modules/helpmode.cpp @@ -91,7 +91,7 @@ public: std::string extra; if (helper->IsAway()) { - const std::string awayperiod = Duration::ToString(ServerInstance->Time() - helper->away->time); + const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - helper->away->time); const std::string awaytime = Time::ToString(helper->away->time); extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, helper->away->message); @@ -100,7 +100,7 @@ public: auto* lhelper = IS_LOCAL(helper); if (lhelper) { - const std::string idleperiod = Duration::ToString(ServerInstance->Time() - lhelper->idle_lastmsg); + const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - lhelper->idle_lastmsg); const std::string idletime = Time::ToString(lhelper->idle_lastmsg); extra += FMT::format("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime); diff --git a/modules/hideoper.cpp b/modules/hideoper.cpp index 8f51ddf2f..c076dbca5 100644 --- a/modules/hideoper.cpp +++ b/modules/hideoper.cpp @@ -157,7 +157,7 @@ public: std::string extra; if (oper->IsAway()) { - const std::string awayperiod = Duration::ToString(ServerInstance->Time() - oper->away->time); + const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - oper->away->time); const std::string awaytime = Time::ToString(oper->away->time); extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message); @@ -166,7 +166,7 @@ public: auto* loper = IS_LOCAL(oper); if (loper) { - const std::string idleperiod = Duration::ToString(ServerInstance->Time() - loper->idle_lastmsg); + const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - loper->idle_lastmsg); const std::string idletime = Time::ToString(loper->idle_lastmsg); extra += FMT::format("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime); diff --git a/modules/joinflood.cpp b/modules/joinflood.cpp index 654f74441..0e2f40f22 100644 --- a/modules/joinflood.cpp +++ b/modules/joinflood.cpp @@ -28,6 +28,7 @@ #include "extension.h" #include "modules/server.h" #include "numerichelper.h" +#include "timeutils.h" // The number of seconds the channel will be closed for. static unsigned int duration; @@ -201,8 +202,8 @@ public: f->lock(); PrefixMode* pm = ServerInstance->Modes.FindNearestPrefixMode(notifyrank); - memb->chan->WriteNotice(FMT::format("This channel has been closed to new users for {} seconds because there have been more than {} joins in {} seconds.", - duration, f->joins, f->secs), pm ? pm->GetPrefix() : 0); + memb->chan->WriteNotice(FMT::format("This channel has been closed to new users for {} because there have been more than {} joins in {}.", + Duration::ToHuman(duration), f->joins, Duration::ToHuman(f->secs)), pm ? pm->GetPrefix() : 0); } } } diff --git a/modules/kicknorejoin.cpp b/modules/kicknorejoin.cpp index c91636f7e..dc210e84b 100644 --- a/modules/kicknorejoin.cpp +++ b/modules/kicknorejoin.cpp @@ -28,6 +28,7 @@ #include "extension.h" #include "modules/invite.h" #include "numerichelper.h" +#include "timeutils.h" class KickRejoinData final { @@ -143,8 +144,8 @@ public: const KickRejoinData* data = kr.ext.Get(chan); if ((data) && !invapi->IsInvited(user, chan) && (!data->canjoin(user))) { - user->WriteNumeric(ERR_UNAVAILRESOURCE, chan->name, FMT::format("You must wait {} seconds after being kicked to rejoin (+{} is set)", - data->delay, kr.GetModeChar())); + user->WriteNumeric(ERR_UNAVAILRESOURCE, chan->name, FMT::format("You must wait for {} after being kicked to rejoin (+{} is set)", + Duration::ToHuman(data->delay), kr.GetModeChar())); return MOD_RES_DENY; } } diff --git a/modules/nickflood.cpp b/modules/nickflood.cpp index 1051861d2..91a81db55 100644 --- a/modules/nickflood.cpp +++ b/modules/nickflood.cpp @@ -26,6 +26,7 @@ #include "extension.h" #include "modules/exemption.h" #include "numerichelper.h" +#include "timeutils.h" // The number of seconds nickname changing will be blocked for. static unsigned int duration; @@ -159,8 +160,8 @@ public: if (f->islocked()) { - user->WriteNumeric(ERR_CANTCHANGENICK, FMT::format("{} has been locked for nickchanges for {} seconds because there have been more than {} nick changes in {} seconds", - memb->chan->name, duration, f->nicks, f->secs)); + user->WriteNumeric(ERR_CANTCHANGENICK, FMT::format("{} has been locked for nick changes for {} because there have been more than {} nick changes in {}", + memb->chan->name, Duration::ToHuman(duration), f->nicks, Duration::ToHuman(f->secs))); return MOD_RES_DENY; } @@ -168,8 +169,8 @@ public: { f->clear(); f->lock(); - memb->chan->WriteNotice(FMT::format("No nick changes are allowed for {} seconds because there have been more than {} nick changes in {} seconds.", - duration, f->nicks, f->secs)); + memb->chan->WriteNotice(FMT::format("No nick changes are allowed for {} because there have been more than {} nick changes in {}.", + Duration::ToHuman(duration), f->nicks, Duration::ToHuman(f->secs))); return MOD_RES_DENY; } } diff --git a/modules/permchannels.cpp b/modules/permchannels.cpp index 178c8f960..ec549b1fc 100644 --- a/modules/permchannels.cpp +++ b/modules/permchannels.cpp @@ -293,7 +293,7 @@ public: // Back off a bit to avoid spamming opers. if (backoff > 1) SetInterval(std::min(GetInterval() * backoff, maxbackoff), false); - ServerInstance->Logs.Debug(MODNAME, "Trying again in {} seconds", GetInterval()); + ServerInstance->Logs.Debug(MODNAME, "Trying again in {}", Duration::ToHuman(GetInterval())); } } return true; diff --git a/modules/rline.cpp b/modules/rline.cpp index 7366722e5..3116c39b7 100644 --- a/modules/rline.cpp +++ b/modules/rline.cpp @@ -79,7 +79,7 @@ public: else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}", - zl->source, u->GetAddress(), Duration::ToString(zl->duration), + zl->source, u->GetAddress(), Duration::ToHuman(zl->duration), Time::ToString(zl->duration), zl->reason); } added_zline = true; @@ -182,7 +182,7 @@ public: else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed R-line on {}, expires in {} (on {}): {}", - user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), r->reason); + user->nick, parameters[0], Duration::ToHuman(duration), Time::FromNow(duration), r->reason); } ServerInstance->XLines->ApplyLines(); diff --git a/modules/securelist.cpp b/modules/securelist.cpp index 06943ac57..c7cf3834a 100644 --- a/modules/securelist.cpp +++ b/modules/securelist.cpp @@ -122,7 +122,7 @@ public: { user->WriteNotice("*** You cannot view the channel list right now. Please {}try again in {}.", exemptregistered ? "log in to an account or " : "", - Duration::ToString(maxwaittime - ServerInstance->Time())); + Duration::ToHuman(maxwaittime - ServerInstance->Time())); } else { diff --git a/modules/setidle.cpp b/modules/setidle.cpp index eab34d76c..d0ef8f418 100644 --- a/modules/setidle.cpp +++ b/modules/setidle.cpp @@ -61,7 +61,7 @@ public: if (user->signon > user->idle_lastmsg) user->signon = user->idle_lastmsg; - ServerInstance->SNO.WriteToSnoMask('a', "{} used SETIDLE to set their idle time to {} seconds", user->nick, idle); + ServerInstance->SNO.WriteToSnoMask('a', "{} used SETIDLE to set their idle time to {}", user->nick, Duration::ToHuman(idle)); noterpl.SendIfCap(user, stdrplcap, this, "IDLE_TIME_SET", user->idle_lastmsg, "Idle time set."); return CmdResult::SUCCESS; } diff --git a/modules/shun.cpp b/modules/shun.cpp index 661cd8e57..7200483f4 100644 --- a/modules/shun.cpp +++ b/modules/shun.cpp @@ -128,7 +128,7 @@ public: else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed SHUN on {}, expires in {} (on {}): {}", - user->nick, target, Duration::ToString(duration), + user->nick, target, Duration::ToHuman(duration), Time::FromNow(duration), expr); } } diff --git a/modules/spanningtree/addline.cpp b/modules/spanningtree/addline.cpp index a82caf082..2b16dff23 100644 --- a/modules/spanningtree/addline.cpp +++ b/modules/spanningtree/addline.cpp @@ -59,7 +59,7 @@ CmdResult CommandAddLine::Handle(User* usr, Params& params) { ServerInstance->SNO.WriteToSnoMask('X', "{} added a timed {}{} on {}, expires in {} (on {}): {}", setter, params[0], params[0].length() <= 2 ? "-line" : "", - params[1], Duration::ToString(xl->duration), + params[1], Duration::ToHuman(xl->duration), Time::ToString(xl->expiry), params[5]); } else diff --git a/modules/spanningtree/main.cpp b/modules/spanningtree/main.cpp index 50ad39be9..87c353997 100644 --- a/modules/spanningtree/main.cpp +++ b/modules/spanningtree/main.cpp @@ -30,6 +30,7 @@ #include "clientprotocolmsg.h" #include "iohook.h" #include "socket.h" +#include "timeutils.h" #include "xline.h" #include "commands.h" @@ -302,7 +303,8 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime) } else if (curtime > s->age + (time_t)p.second) { - ServerInstance->SNO.WriteToSnoMask('l', "CONNECT: Error connecting \002{}\002 (timeout of {} seconds)", p.first, p.second); + ServerInstance->SNO.WriteToSnoMask('l', "CONNECT: Error connecting \002{}\002 (timeout of {})", + p.first, Duration::ToHuman(p.second)); Utils->timeoutlist.erase(me); s->Close(); } diff --git a/modules/spanningtree/pingtimer.cpp b/modules/spanningtree/pingtimer.cpp index c9535366c..a6d193bfb 100644 --- a/modules/spanningtree/pingtimer.cpp +++ b/modules/spanningtree/pingtimer.cpp @@ -19,6 +19,7 @@ #include "inspircd.h" +#include "timeutils.h" #include "pingtimer.h" #include "treeserver.h" @@ -48,7 +49,8 @@ PingTimer::State PingTimer::TickInternal() else if (state == PS_WARN) { // No pong arrived in PingWarnTime seconds, send a warning to opers - ServerInstance->SNO.WriteToSnoMask('l', "Server \002{}\002 has not responded to PING for {} seconds, high latency.", server->GetName(), GetInterval()); + ServerInstance->SNO.WriteToSnoMask('l', "Server \002{}\002 has not responded to PING for {}, high latency.", + server->GetName(), Duration::ToHuman(GetInterval())); return PS_TIMEOUT; } else // PS_TIMEOUT diff --git a/modules/spanningtree/server.cpp b/modules/spanningtree/server.cpp index 711bc3b9b..e9d8ebd19 100644 --- a/modules/spanningtree/server.cpp +++ b/modules/spanningtree/server.cpp @@ -23,6 +23,8 @@ */ +#include <filesystem> + #include "inspircd.h" #include "modules/ssl.h" @@ -33,6 +35,22 @@ #include "treesocket.h" #include "commands.h" +namespace +{ + bool RunningInContainer() + { + std::error_code ec; + if (std::filesystem::is_regular_file("/.dockerenv", ec)) + { + // We are running inside of Docker so all IP addresses are + // non-local and as far as I can see there isn't a way to + // reliably detect the Docker network. + return true; + } + return false; + } +} + /* * Some server somewhere in the network introducing another server. * -- w @@ -138,7 +156,7 @@ std::shared_ptr<Link> TreeSocket::AuthRemote(const CommandBase::Params& params) ssliohook->GetCiphersuite(ciphersuite); ServerInstance->SNO.WriteToSnoMask('l', "Negotiated ciphersuite {} on link {}", ciphersuite, x->Name); } - else if (!capab->remotesa.is_local()) + else if (!capab->remotesa.is_local() && !RunningInContainer()) { this->SendError("Non-local server connections MUST be linked with SSL!"); return nullptr; diff --git a/modules/spanningtree/treesocket2.cpp b/modules/spanningtree/treesocket2.cpp index 38bf333f7..bd667f0c8 100644 --- a/modules/spanningtree/treesocket2.cpp +++ b/modules/spanningtree/treesocket2.cpp @@ -164,13 +164,13 @@ void TreeSocket::ProcessLine(std::string& line) time_t delta = std::abs(them - ServerInstance->Time()); if (delta > 15) { - ServerInstance->SNO.WriteGlobalSno('l', "\002ERROR\002: Your clocks are off by {} seconds (this is more than fifteen seconds). Link aborted, \002PLEASE SYNC YOUR CLOCKS!\002", delta); - SendError(FMT::format("Your clocks are out by {} seconds (this is more than fifteen seconds). Link aborted, PLEASE SYNC YOUR CLOCKS!", delta)); + ServerInstance->SNO.WriteGlobalSno('l', "\002ERROR\002: Your clocks are off by {} (this is more than fifteen seconds). Link aborted, \002PLEASE SYNC YOUR CLOCKS!\002", Duration::ToHuman(delta)); + SendError(FMT::format("Your clocks are out by {} (this is more than fifteen seconds). Link aborted, PLEASE SYNC YOUR CLOCKS!", Duration::ToHuman(delta))); return; } - else if ((delta < -5) || (delta > 5)) + else if (delta > 5) { - ServerInstance->SNO.WriteGlobalSno('l', "\002WARNING\002: Your clocks are off by {} seconds. Please consider syncing your clocks.", labs((long)delta)); + ServerInstance->SNO.WriteGlobalSno('l', "\002WARNING\002: Your clocks are off by {}. Please consider syncing your clocks.", Duration::ToHuman(delta)); } } @@ -436,7 +436,7 @@ void TreeSocket::Close() time_t server_uptime = ServerInstance->Time() - this->age; if (server_uptime) { - std::string timestr = Duration::ToString(server_uptime); + std::string timestr = Duration::ToHuman(server_uptime); ServerInstance->SNO.WriteGlobalSno('l', "Connection to '\002{}\002' was established for {}", linkID, timestr); } } diff --git a/modules/sslinfo.cpp b/modules/sslinfo.cpp index d3b21296d..ed8aa3a1d 100644 --- a/modules/sslinfo.cpp +++ b/modules/sslinfo.cpp @@ -458,7 +458,7 @@ public: } else if (static_cast<time_t>(ServerInstance->Time() + warnexpiring) > cert->GetExpirationTime()) { - const std::string duration = Duration::ToString(cert->GetExpirationTime() - ServerInstance->Time()); + const std::string duration = Duration::ToHuman(cert->GetExpirationTime() - ServerInstance->Time()); user->WriteNotice("*** Your TLS client certificate expires in " + duration + "."); } } diff --git a/modules/timedbans.cpp b/modules/timedbans.cpp index 37e24ba77..7709e861f 100644 --- a/modules/timedbans.cpp +++ b/modules/timedbans.cpp @@ -152,7 +152,7 @@ public: if (sendnotice) { const std::string message = FMT::format("Timed ban {} added by {} on {} lasting for {}.", - mask, user->nick, channel->name, Duration::ToString(duration)); + mask, user->nick, channel->name, Duration::ToHuman(duration)); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); diff --git a/modules/xline_db.cpp b/modules/xline_db.cpp index 158a93363..7558f8bb3 100644 --- a/modules/xline_db.cpp +++ b/modules/xline_db.cpp @@ -109,7 +109,7 @@ public: // Back off a bit to avoid spamming opers. if (backoff > 1) SetInterval(std::min(GetInterval() * backoff, maxbackoff), false); - ServerInstance->Logs.Debug(MODNAME, "Trying again in {} seconds", GetInterval()); + ServerInstance->Logs.Debug(MODNAME, "Trying again in {}", Duration::ToHuman(GetInterval())); } } return true; @@ -252,7 +252,7 @@ public: { ServerInstance->SNO.WriteToSnoMask('x', "database: added a timed {}{} on {}, expires in {} (on {}): {}", xl->type, xl->type.length() <= 2 ? "-line" : "", xl->Displayable(), - Duration::ToString(xl->duration), Time::FromNow(xl->duration), xl->reason); + Duration::ToHuman(xl->duration), Time::FromNow(xl->duration), xl->reason); } else { |
