ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/modules/m_svinfo.c
Revision: 34
Committed: Sun Oct 2 21:05:51 2005 UTC (18 years, 5 months ago) by lusky
Content type: text/x-csrc
File size: 4418 byte(s)
Log Message:
create 7.2 branch, we can move/rename it as needed.


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

Properties

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