ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_svinfo.c
Revision: 470
Committed: Fri Feb 17 05:07:43 2006 UTC (18 years, 1 month ago) by db
Content type: text/x-csrc
File size: 4321 byte(s)
Log Message:
- fix compile errors with moved modules.h
- fix a few missing includes, msg.h and parse.h


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 "handlers.h"
26 #include "client.h"
27 #include "common.h" /* TRUE bleah */
28 #include "ircd.h"
29 #include "numeric.h"
30 #include "send.h"
31 #include "s_conf.h"
32 #include "msg.h"
33 #include "parse.h"
34 #include "conf/modules.h"
35
36 static void ms_svinfo(struct Client*, struct Client*, int, char**);
37
38 struct Message svinfo_msgtab = {
39 "SVINFO", 0, 0, 4, 0, MFLG_SLOW, 0,
40 {m_unregistered, m_ignore, ms_svinfo, m_ignore, m_ignore, m_ignore}
41 };
42
43 INIT_MODULE(m_svinfo, "$Revision$")
44 {
45 mod_add_cmd(&svinfo_msgtab);
46 }
47
48 CLEANUP_MODULE
49 {
50 mod_del_cmd(&svinfo_msgtab);
51 }
52
53 /*
54 * ms_svinfo - SVINFO message handler
55 * parv[0] = sender prefix
56 * parv[1] = TS_CURRENT for the server
57 * parv[2] = TS_MIN for the server
58 * parv[3] = server is standalone or connected to non-TS only
59 * parv[4] = server's idea of UTC time
60 */
61 static void
62 ms_svinfo(struct Client *client_p, struct Client *source_p,
63 int parc, char *parv[])
64 {
65 time_t deltat;
66 time_t theirtime;
67
68 if (MyConnect(source_p) && IsUnknown(source_p))
69 {
70 exit_client(source_p, source_p, "Need SERVER before SVINFO");
71 return;
72 }
73
74 if (!IsServer(source_p) || !MyConnect(source_p) || parc < 5)
75 return;
76
77 if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
78 {
79 /*
80 * a server with the wrong TS version connected; since we're
81 * TS_ONLY we can't fall back to the non-TS protocol so
82 * we drop the link -orabidoo
83 */
84 sendto_realops_flags(UMODE_ALL, L_ADMIN,
85 "Link %s dropped, wrong TS protocol version (%s,%s)",
86 get_client_name(source_p, SHOW_IP), parv[1], parv[2]);
87 sendto_realops_flags(UMODE_ALL, L_OPER,
88 "Link %s dropped, wrong TS protocol version (%s,%s)",
89 get_client_name(source_p, MASK_IP), parv[1], parv[2]);
90 exit_client(source_p, source_p, "Incompatible TS version");
91 return;
92 }
93
94 /*
95 * since we're here, might as well set CurrentTime while we're at it
96 */
97 set_time();
98 theirtime = atol(parv[4]);
99 deltat = abs(theirtime - CurrentTime);
100
101 if (deltat > ConfigFileEntry.ts_max_delta)
102 {
103 sendto_realops_flags(UMODE_ALL, L_ADMIN,
104 "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
105 get_client_name(source_p, SHOW_IP),
106 (unsigned long) CurrentTime,
107 (unsigned long) theirtime,
108 (int) deltat);
109 sendto_realops_flags(UMODE_ALL, L_OPER,
110 "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
111 get_client_name(source_p, MASK_IP),
112 (unsigned long) CurrentTime,
113 (unsigned long) theirtime,
114 (int) deltat);
115 ilog(L_NOTICE,
116 "Link %s dropped, excessive TS delta (my TS=%lu, their TS=%lu, delta=%d)",
117 get_client_name(source_p, SHOW_IP),
118 (unsigned long) CurrentTime,
119 (unsigned long) theirtime,
120 (int) deltat);
121 exit_client(source_p, source_p, "Excessive TS delta");
122 return;
123 }
124
125 if (deltat > ConfigFileEntry.ts_warn_delta)
126 {
127 sendto_realops_flags(UMODE_ALL, L_ALL,
128 "Link %s notable TS delta (my TS=%lu, their TS=%lu, delta=%d)",
129 source_p->name,
130 (unsigned long) CurrentTime,
131 (unsigned long) theirtime,
132 (int) deltat);
133 }
134 }

Properties

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