1 |
adx |
30 |
/* |
2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2820 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
adx |
30 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
|
* USA |
20 |
|
|
*/ |
21 |
michael |
1230 |
|
22 |
michael |
2820 |
/*! \file m_svinfo.c |
23 |
|
|
* \brief Includes required functions for processing the SVINFO command. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
|
|
|
27 |
adx |
30 |
#include "stdinc.h" |
28 |
|
|
#include "client.h" |
29 |
|
|
#include "irc_string.h" |
30 |
|
|
#include "ircd.h" |
31 |
|
|
#include "send.h" |
32 |
michael |
1309 |
#include "conf.h" |
33 |
|
|
#include "log.h" |
34 |
adx |
30 |
#include "parse.h" |
35 |
|
|
#include "modules.h" |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
/* |
39 |
|
|
* ms_svinfo - SVINFO message handler |
40 |
michael |
3096 |
* parv[0] = command |
41 |
adx |
30 |
* parv[1] = TS_CURRENT for the server |
42 |
|
|
* parv[2] = TS_MIN for the server |
43 |
|
|
* parv[3] = server is standalone or connected to non-TS only |
44 |
|
|
* parv[4] = server's idea of UTC time |
45 |
|
|
*/ |
46 |
michael |
2820 |
static int |
47 |
michael |
3156 |
ms_svinfo(struct Client *source_p, int parc, char *parv[]) |
48 |
adx |
30 |
{ |
49 |
michael |
3171 |
time_t deltat = 0, theirtime = 0; |
50 |
adx |
30 |
|
51 |
michael |
3172 |
if (!IsServer(source_p) || !MyConnect(source_p)) |
52 |
michael |
2820 |
return 0; |
53 |
adx |
30 |
|
54 |
|
|
if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN) |
55 |
michael |
1298 |
{ |
56 |
|
|
/* |
57 |
|
|
* a server with the wrong TS version connected; since we're |
58 |
|
|
* TS_ONLY we can't fall back to the non-TS protocol so |
59 |
|
|
* we drop the link -orabidoo |
60 |
|
|
*/ |
61 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
62 |
adx |
30 |
"Link %s dropped, wrong TS protocol version (%s,%s)", |
63 |
|
|
get_client_name(source_p, SHOW_IP), parv[1], parv[2]); |
64 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
65 |
adx |
30 |
"Link %s dropped, wrong TS protocol version (%s,%s)", |
66 |
|
|
get_client_name(source_p, MASK_IP), parv[1], parv[2]); |
67 |
michael |
3171 |
exit_client(source_p, "Incompatible TS version"); |
68 |
michael |
2820 |
return 0; |
69 |
michael |
1298 |
} |
70 |
adx |
30 |
|
71 |
|
|
/* |
72 |
|
|
* since we're here, might as well set CurrentTime while we're at it |
73 |
|
|
*/ |
74 |
michael |
2820 |
set_time(); |
75 |
adx |
30 |
theirtime = atol(parv[4]); |
76 |
|
|
deltat = abs(theirtime - CurrentTime); |
77 |
|
|
|
78 |
|
|
if (deltat > ConfigFileEntry.ts_max_delta) |
79 |
michael |
1298 |
{ |
80 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
81 |
adx |
30 |
"Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)", |
82 |
|
|
get_client_name(source_p, SHOW_IP), |
83 |
|
|
(unsigned long) CurrentTime, |
84 |
|
|
(unsigned long) theirtime, |
85 |
|
|
(int) deltat); |
86 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
87 |
adx |
30 |
"Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)", |
88 |
|
|
get_client_name(source_p, MASK_IP), |
89 |
|
|
(unsigned long) CurrentTime, |
90 |
|
|
(unsigned long) theirtime, |
91 |
|
|
(int) deltat); |
92 |
michael |
1298 |
ilog(LOG_TYPE_IRCD, |
93 |
|
|
"Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)", |
94 |
|
|
get_client_name(source_p, SHOW_IP), |
95 |
|
|
(unsigned long) CurrentTime, |
96 |
|
|
(unsigned long) theirtime, |
97 |
|
|
(int) deltat); |
98 |
michael |
3171 |
exit_client(source_p, "Excessive TS delta"); |
99 |
michael |
2820 |
return 0; |
100 |
michael |
1298 |
} |
101 |
adx |
30 |
|
102 |
|
|
if (deltat > ConfigFileEntry.ts_warn_delta) |
103 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
104 |
adx |
30 |
"Link %s notable TS delta (my TS=%lu, their TS=%lu, delta=%d)", |
105 |
|
|
source_p->name, |
106 |
|
|
(unsigned long) CurrentTime, |
107 |
|
|
(unsigned long) theirtime, |
108 |
|
|
(int) deltat); |
109 |
michael |
2820 |
return 0; |
110 |
adx |
30 |
} |
111 |
michael |
1230 |
|
112 |
michael |
2820 |
static struct Message svinfo_msgtab = |
113 |
|
|
{ |
114 |
michael |
3172 |
"SVINFO", 0, 0, 5, MAXPARA, MFLG_SLOW, 0, |
115 |
michael |
2820 |
{ m_unregistered, m_ignore, ms_svinfo, m_ignore, m_ignore, m_ignore } |
116 |
michael |
1230 |
}; |
117 |
|
|
|
118 |
|
|
static void |
119 |
|
|
module_init(void) |
120 |
|
|
{ |
121 |
|
|
mod_add_cmd(&svinfo_msgtab); |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
static void |
125 |
|
|
module_exit(void) |
126 |
|
|
{ |
127 |
|
|
mod_del_cmd(&svinfo_msgtab); |
128 |
|
|
} |
129 |
|
|
|
130 |
michael |
2820 |
struct module module_entry = |
131 |
|
|
{ |
132 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
133 |
|
|
.name = NULL, |
134 |
|
|
.version = "$Revision$", |
135 |
|
|
.handle = NULL, |
136 |
|
|
.modinit = module_init, |
137 |
|
|
.modexit = module_exit, |
138 |
|
|
.flags = 0 |
139 |
|
|
}; |