ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_svinfo.c
Revision: 1247
Committed: Sat Oct 1 07:54:24 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
File size: 4441 byte(s)
Log Message:
- Rewrite and cleanup half-broken logging subsystem.
  Logfile rotating is not working yet

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

Properties

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