diff options
author | Peter Powell <petpow@saberuk.com> | 2018-12-04 19:04:09 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-12-04 19:04:09 +0000 |
commit | a4c1b1f4fcfd9cd967bf326afbbada3d91f9da34 (patch) | |
tree | a6bd890d53163c6d02b122198e06e2d35d319d43 /src | |
parent | ec6955f28ba9423828ac24ef83caee09ffa6b52c (diff) |
Add an option for changing the allowed server clock drift.
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 1 | ||||
-rw-r--r-- | src/inspircd.cpp | 15 |
2 files changed, 9 insertions, 7 deletions
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; |