ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svinfo.c
Revision: 5864
Committed: Tue Apr 28 12:23:30 2015 UTC (10 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4576 byte(s)
Log Message:
- Removed useless zero initializers from the module_entry as suggested by Adam

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 5347 * Copyright (c) 1997-2015 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21 michael 1230
22 michael 2820 /*! \file m_svinfo.c
23     * \brief Includes required functions for processing the SVINFO command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "send.h"
32 michael 1309 #include "conf.h"
33     #include "log.h"
34 adx 30 #include "parse.h"
35     #include "modules.h"
36    
37    
38 michael 3294 /*! \brief SVINFO command handler
39     *
40     * \param source_p Pointer to allocated Client struct from which the message
41     * originally comes from. This can be a local or remote client.
42     * \param parc Integer holding the number of supplied arguments.
43     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
44     * pointers.
45     * \note Valid arguments for this command are:
46     * - parv[0] = command
47     * - parv[1] = TS_CURRENT for the server
48     * - parv[2] = TS_MIN for the server
49     * - parv[3] = server is standalone or connected to non-TS only
50     * - parv[4] = server's idea of UTC time
51 adx 30 */
52 michael 2820 static int
53 michael 3156 ms_svinfo(struct Client *source_p, int parc, char *parv[])
54 adx 30 {
55 michael 3171 time_t deltat = 0, theirtime = 0;
56 adx 30
57 michael 3172 if (!IsServer(source_p) || !MyConnect(source_p))
58 michael 2820 return 0;
59 adx 30
60     if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
61 michael 1298 {
62     /*
63 michael 3294 * A server with the wrong TS version connected; since we're
64 michael 1298 * 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 3171 exit_client(source_p, "Incompatible TS version");
74 michael 2820 return 0;
75 michael 1298 }
76 adx 30
77     /*
78 michael 3294 * Since we're here, might as well set CurrentTime while we're at it
79 adx 30 */
80 michael 2820 set_time();
81 michael 3294
82 adx 30 theirtime = atol(parv[4]);
83     deltat = abs(theirtime - CurrentTime);
84    
85 michael 4340 if (deltat > ConfigGeneral.ts_max_delta)
86 michael 1298 {
87 michael 1618 sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
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 1618 sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
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 michael 3171 exit_client(source_p, "Excessive TS delta");
106 michael 2820 return 0;
107 michael 1298 }
108 adx 30
109 michael 4340 if (deltat > ConfigGeneral.ts_warn_delta)
110 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
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 michael 2820 return 0;
117 adx 30 }
118 michael 1230
119 michael 2820 static struct Message svinfo_msgtab =
120     {
121 michael 4545 "SVINFO", NULL, 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
122 michael 2820 { m_unregistered, m_ignore, ms_svinfo, m_ignore, m_ignore, m_ignore }
123 michael 1230 };
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 michael 2820 struct module module_entry =
138     {
139 michael 1230 .version = "$Revision$",
140     .modinit = module_init,
141     .modexit = module_exit,
142     };

Properties

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