diff options
-rw-r--r-- | docs/conf/inspircd.conf.example | 4 | ||||
-rw-r--r-- | include/configreader.h | 3 | ||||
-rw-r--r-- | src/configreader.cpp | 1 | ||||
-rw-r--r-- | src/inspircd.cpp | 15 |
4 files changed, 16 insertions, 7 deletions
diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example index 04100ec2a..713dc0cb8 100644 --- a/docs/conf/inspircd.conf.example +++ b/docs/conf/inspircd.conf.example @@ -695,6 +695,10 @@ # Default value is true clonesonconnect="true" + # timeskipwarn: The time period that a server clock can jump by before + # operators will be warned that the server is having performance issues. + timeskipwarn="2s" + # quietbursts: When syncing or splitting from a network, a server # can generate a lot of connect and quit messages to opers with # +C and +Q snomasks. Setting this to yes squelches those messages, diff --git a/include/configreader.h b/include/configreader.h index 1db64ae5a..4360b8661 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -376,6 +376,9 @@ class CoreExport ServerConfig */ unsigned int MaxTargets; + /** The number of seconds that the server clock can skip by before server operators are warned. */ + time_t TimeSkipWarn; + /** True if we're going to hide ban reasons for non-opers (e.g. G-Lines, * K-Lines, Z-Lines) */ diff --git a/src/configreader.cpp b/src/configreader.cpp index 52217722c..f5a8abb00 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -373,6 +373,7 @@ void ServerConfig::Fill() SoftLimit = ConfValue("performance")->getUInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true); MaxConn = ConfValue("performance")->getUInt("somaxconn", SOMAXCONN); + TimeSkipWarn = ConfValue("performance")->getDuration("timeskipwarn", 2, 0, 30); XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!")); ServerDesc = server->getString("description", "Configure Me"); Network = server->getString("network", "Network"); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index aa3fb9612..7e299700b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -644,14 +644,15 @@ void InspIRCd::Run() } #endif - /* Allow a buffer of two seconds drift on this so that ntpdate etc dont harass admins */ - if (TIME.tv_sec < OLDTIME - 2) + if (Config->TimeSkipWarn) { - SNO->WriteToSnoMask('a', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)(OLDTIME-TIME.tv_sec)); - } - else if (TIME.tv_sec > OLDTIME + 2) - { - SNO->WriteToSnoMask('a', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)(TIME.tv_sec - OLDTIME)); + time_t timediff = TIME.tv_sec - OLDTIME; + + if (timediff > Config->TimeSkipWarn) + SNO->WriteToSnoMask('a', "\002Performance warning!\002 Server clock jumped forwards by %lu seconds!", timediff); + + else if (timediff < -Config->TimeSkipWarn) + SNO->WriteToSnoMask('a', "\002Performance warning!\002 Server clock jumped backwards by %lu seconds!", labs(timediff)); } OLDTIME = TIME.tv_sec; |