ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_svinfo.c
Revision: 1155
Committed: Tue Aug 9 20:27:45 2011 UTC (12 years, 8 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_svinfo.c
File size: 4393 byte(s)
Log Message:
- recreate "trunk"

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

Properties

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