]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_svinfo.c
Removal of ancient SVN ID's part one
[irc/rqf/shadowircd.git] / modules / m_svinfo.c
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_svinfo.c: Sends TS information for clock & compatibility checks.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
212380e3 24 */
25#include "stdinc.h"
26#include "client.h"
27#include "common.h" /* TRUE bleah */
13ae2f4b 28#include "match.h"
212380e3 29#include "ircd.h"
30#include "numeric.h"
31#include "send.h"
32#include "s_conf.h"
6b2cf989 33#include "s_newconf.h"
d3455e2c 34#include "logger.h"
212380e3 35#include "msg.h"
36#include "parse.h"
37#include "modules.h"
38
39static int ms_svinfo(struct Client *, struct Client *, int, const char **);
40
41struct Message svinfo_msgtab = {
42 "SVINFO", 0, 0, 0, MFLG_SLOW,
43 {mg_unreg, mg_ignore, mg_ignore, {ms_svinfo, 5}, mg_ignore, mg_ignore}
44};
45
46mapi_clist_av1 svinfo_clist[] = { &svinfo_msgtab, NULL };
47DECLARE_MODULE_AV1(svinfo, NULL, NULL, svinfo_clist, NULL, NULL, "$Revision: 494 $");
48
49/*
50 * ms_svinfo - SVINFO message handler
212380e3 51 * parv[1] = TS_CURRENT for the server
52 * parv[2] = TS_MIN for the server
53 * parv[3] = unused, send 0
54 * parv[4] = server's idea of UTC time
55 */
56static int
57ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
58{
59 signed int deltat;
60 time_t theirtime;
55b5711c 61 char squitreason[120];
212380e3 62
63 /* SVINFO isnt remote. */
64 if(source_p != client_p)
65 return 0;
66
67 if(TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
68 {
69 /* TS version is too low on one of the sides, drop the link */
70 sendto_realops_snomask(SNO_GENERAL, L_ALL,
71 "Link %s dropped, wrong TS protocol version (%s,%s)",
715b28fe 72 source_p->name, parv[1], parv[2]);
5b0a5279 73 rb_snprintf(squitreason, sizeof squitreason, "Incompatible TS version (%s,%s)",
55b5711c
JT
74 parv[1], parv[2]);
75 exit_client(source_p, source_p, source_p, squitreason);
212380e3 76 return 0;
77 }
78
79 /*
9f6bbe3c 80 * since we're here, might as well set rb_current_time() while we're at it
212380e3 81 */
6336c1bf 82 rb_set_time();
212380e3 83 theirtime = atol(parv[4]);
9f6bbe3c 84 deltat = abs(theirtime - rb_current_time());
212380e3 85
86 if(deltat > ConfigFileEntry.ts_max_delta)
87 {
88 sendto_realops_snomask(SNO_GENERAL, L_ALL,
89 "Link %s dropped, excessive TS delta"
90 " (my TS=%ld, their TS=%ld, delta=%d)",
715b28fe 91 source_p->name,
9f6bbe3c 92 (long) rb_current_time(), (long) theirtime, deltat);
212380e3 93 ilog(L_SERVER,
94 "Link %s dropped, excessive TS delta"
95 " (my TS=%ld, their TS=%ld, delta=%d)",
9f6bbe3c 96 log_client_name(source_p, SHOW_IP), (long) rb_current_time(), (long) theirtime, deltat);
5b0a5279 97 rb_snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%d)",
9f6bbe3c 98 (long) rb_current_time(), (long) theirtime, deltat);
6b2cf989 99 disable_server_conf_autoconn(source_p->name);
55b5711c 100 exit_client(source_p, source_p, source_p, squitreason);
212380e3 101 return 0;
102 }
103
104 if(deltat > ConfigFileEntry.ts_warn_delta)
105 {
757f5aa8 106 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
212380e3 107 "Link %s notable TS delta"
108 " (my TS=%ld, their TS=%ld, delta=%d)",
9f6bbe3c 109 source_p->name, (long) rb_current_time(), (long) theirtime, deltat);
212380e3 110 }
111
112 return 0;
113}
114