2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_svinfo.c: Sends TS information for clock & compatibility checks.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-07 09:05:28 +01:00
|
|
|
static const char svinfo_desc[] =
|
|
|
|
"Provides TS6 SVINFO command to ensure version and clock synchronisation";
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void ms_svinfo(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2007-01-25 07:40:21 +01:00
|
|
|
struct Message svinfo_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"SVINFO", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_unreg, mg_ignore, mg_ignore, {ms_svinfo, 5}, mg_ignore, mg_ignore}
|
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 svinfo_clist[] = { &svinfo_msgtab, NULL };
|
2016-03-07 09:05:28 +01:00
|
|
|
DECLARE_MODULE_AV2(svinfo, NULL, NULL, svinfo_clist, NULL, NULL, NULL, NULL, svinfo_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ms_svinfo - SVINFO message handler
|
|
|
|
* parv[1] = TS_CURRENT for the server
|
|
|
|
* parv[2] = TS_MIN for the server
|
|
|
|
* parv[3] = unused, send 0
|
|
|
|
* parv[4] = server's idea of UTC time
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
ms_svinfo(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2015-04-20 07:55:20 +02:00
|
|
|
signed long deltat;
|
2007-01-25 07:40:21 +01:00
|
|
|
time_t theirtime;
|
2007-12-25 00:16:26 +01:00
|
|
|
char squitreason[120];
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* SVINFO isnt remote. */
|
2016-08-23 02:37:07 +02:00
|
|
|
if(&source != &client)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
|
|
|
|
{
|
|
|
|
/* TS version is too low on one of the sides, drop the link */
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
|
|
|
"Link %s dropped, wrong TS protocol version (%s,%s)",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, parv[1], parv[2]);
|
2016-02-10 02:25:32 +01:00
|
|
|
snprintf(squitreason, sizeof squitreason, "Incompatible TS version (%s,%s)",
|
2007-12-25 00:16:26 +01:00
|
|
|
parv[1], parv[2]);
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(&source, &source, &source, squitreason);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-04-02 01:53:20 +02:00
|
|
|
* since we're here, might as well set rb_current_time() while we're at it
|
2007-01-25 07:40:21 +01:00
|
|
|
*/
|
2008-04-03 22:01:59 +02:00
|
|
|
rb_set_time();
|
2007-01-25 07:40:21 +01:00
|
|
|
theirtime = atol(parv[4]);
|
2015-04-20 07:55:20 +02:00
|
|
|
deltat = labs(theirtime - rb_current_time());
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(deltat > ConfigFileEntry.ts_max_delta)
|
|
|
|
{
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
|
|
|
"Link %s dropped, excessive TS delta"
|
2015-04-20 07:55:20 +02:00
|
|
|
" (my TS=%ld, their TS=%ld, delta=%ld)",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name,
|
2008-04-02 01:53:20 +02:00
|
|
|
(long) rb_current_time(), (long) theirtime, deltat);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_SERVER,
|
|
|
|
"Link %s dropped, excessive TS delta"
|
2015-04-20 07:55:20 +02:00
|
|
|
" (my TS=%ld, their TS=%ld, delta=%ld)",
|
2016-08-23 02:37:07 +02:00
|
|
|
log_client_name(&source, SHOW_IP), (long) rb_current_time(), (long) theirtime, deltat);
|
2016-02-10 02:25:32 +01:00
|
|
|
snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%ld)",
|
2008-04-02 01:53:20 +02:00
|
|
|
(long) rb_current_time(), (long) theirtime, deltat);
|
2016-08-23 02:37:07 +02:00
|
|
|
disable_server_conf_autoconn(source.name);
|
|
|
|
exit_client(&source, &source, &source, squitreason);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(deltat > ConfigFileEntry.ts_warn_delta)
|
|
|
|
{
|
2007-12-25 00:18:34 +01:00
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Link %s notable TS delta"
|
2015-04-20 07:55:20 +02:00
|
|
|
" (my TS=%ld, their TS=%ld, delta=%ld)",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, (long) rb_current_time(), (long) theirtime, deltat);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|