1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 13:43:13 +02:00

Bounce links that have their clock too far out of sync (#4214). Currently set at 1 minute. TODO: make configurable.

This only works with newer servers as it relies on PROTOCTL TS=xyz very early in the synch.
This commit is contained in:
Bram Matthys
2015-05-24 16:16:31 +02:00
parent c2ca896dea
commit 0a42cedf77
3 changed files with 38 additions and 2 deletions
+31
View File
@@ -348,6 +348,37 @@ CMD_FUNC(m_protoctl)
if (!IsHandshake(cptr) && aconf && !BadPtr(aconf->connpwd)) /* Send PASS early... */
sendto_one(sptr, "PASS :%s", aconf->connpwd);
}
else if ((strncmp(s, "TS=",3) == 0) && (IsServer(sptr) || IsEAuth(sptr)))
{
long t = atol(s+3);
char msg[512], linkerr[512];
if (t < 10000)
continue; /* ignore */
*msg = *linkerr = '\0';
#define MAX_SERVER_TIME_OFFSET 60
if ((TStime() - t) > MAX_SERVER_TIME_OFFSET)
{
snprintf(linkerr, sizeof(linkerr), "Your clock is %ld seconds behind my clock. Please verify both your clock and mine, fix it and try linking again.", TStime() - t);
snprintf(msg, sizeof(msg), "Rejecting link %s: our clock is %ld seconds ahead. Correct time is very important in IRC. Please verify the clock on both %s (them) and %s (us), fix it and then try linking again",
get_client_name(cptr, TRUE), TStime() - t, sptr->name, me.name);
} else
if ((t - TStime()) > MAX_SERVER_TIME_OFFSET)
{
snprintf(linkerr, sizeof(linkerr), "Your clock is %ld seconds ahead of my clock. Please verify both your clock and mine, fix it, and try linking again.", t - TStime());
snprintf(msg, sizeof(msg), "Rejecting link %s: our clock is %ld seconds behind. Correct time is very important in IRC. Please verify the clock on both %s (them) and %s (us), fix it and then try linking again",
get_client_name(cptr, TRUE), t - TStime(), sptr->name, me.name);
}
if (*msg)
{
sendto_realops("%s", msg);
ircd_log(LOG_ERROR, "%s", msg);
return exit_client(sptr, sptr, sptr, linkerr);
}
}
else if ((strcmp(s, "MLOCK")) == 0)
{
#ifdef PROTOCTL_MADNESS