ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/ircd-hybrid-newconf/modules/m_svinfo.c
Revision: 1027
Committed: Sun Nov 8 13:01:13 2009 UTC (16 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 4282 byte(s)
Log Message:
- Move old 7.3 sources to branches/ircd-hybrid-newconf

File Contents

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

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision