ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svinfo.c
Revision: 2274
Committed: Tue Jun 18 16:01:57 2013 UTC (13 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 4432 byte(s)
Log Message:
- Sort out unused header includes

File Contents

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

Properties

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