ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svinfo.c
Revision: 1309
Committed: Sun Mar 25 11:24:18 2012 UTC (14 years, 4 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_svinfo.c
File size: 4388 byte(s)
Log Message:
- renaming files:

  ircd_parser.y -> conf_parser.y
  ircd_lexer.l  -> conf_lexer.l
  s_conf.c      -> conf.c
  s_conf.h      -> conf.h
  s_log.c       -> log.c
  s_log.h       -> log.h

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 michael 1309 #include "conf.h"
32     #include "log.h"
33 adx 30 #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 michael 1309 int parc, char *parv[])
48 adx 30 {
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 michael 1298 {
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 adx 30 "Link %s dropped, wrong TS protocol version (%s,%s)",
70     get_client_name(source_p, SHOW_IP), parv[1], parv[2]);
71 michael 1298 sendto_realops_flags(UMODE_ALL, L_OPER,
72 adx 30 "Link %s dropped, wrong TS protocol version (%s,%s)",
73     get_client_name(source_p, MASK_IP), parv[1], parv[2]);
74 michael 1298 exit_client(source_p, source_p, "Incompatible TS version");
75     return;
76     }
77 adx 30
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 michael 1298 {
87     sendto_realops_flags(UMODE_ALL, L_ADMIN,
88 adx 30 "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 michael 1298 sendto_realops_flags(UMODE_ALL, L_OPER,
94 adx 30 "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 1298 ilog(LOG_TYPE_IRCD,
100     "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 adx 30
109     if (deltat > ConfigFileEntry.ts_warn_delta)
110 michael 1298 sendto_realops_flags(UMODE_ALL, L_ALL,
111 adx 30 "Link %s notable TS delta (my TS=%lu, their TS=%lu, delta=%d)",
112     source_p->name,
113     (unsigned long) CurrentTime,
114     (unsigned long) theirtime,
115     (int) deltat);
116     }
117 michael 1230
118     static struct Message svinfo_msgtab = {
119     "SVINFO", 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
120     {m_unregistered, m_ignore, ms_svinfo, m_ignore, m_ignore, m_ignore}
121     };
122    
123     static void
124     module_init(void)
125     {
126     mod_add_cmd(&svinfo_msgtab);
127     }
128    
129     static void
130     module_exit(void)
131     {
132     mod_del_cmd(&svinfo_msgtab);
133     }
134    
135     struct module module_entry = {
136     .node = { NULL, NULL, NULL },
137     .name = NULL,
138     .version = "$Revision$",
139     .handle = NULL,
140     .modinit = module_init,
141     .modexit = module_exit,
142     .flags = 0
143     };

Properties

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