ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_svinfo.c
Revision: 8976
Committed: Sat May 18 18:44:09 2019 UTC (6 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 4897 byte(s)
Log Message:
- m_svinfo.c: intmax_t -> uintmax_t

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 8751 * Copyright (c) 1997-2019 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 4564 * 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 michael 6872 * - parv[3] = unused
50 michael 3294 * - 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 3172 if (!IsServer(source_p) || !MyConnect(source_p))
56 michael 2820 return 0;
57 adx 30
58     if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
59 michael 1298 {
60     /*
61 michael 3294 * A server with the wrong TS version connected; since we're
62 michael 1298 * TS_ONLY we can't fall back to the non-TS protocol so
63     * we drop the link -orabidoo
64     */
65 michael 6317 sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
66 michael 6862 "Link %s dropped, wrong TS protocol version (%s,%s)",
67 michael 7996 client_get_name(source_p, SHOW_IP), parv[1], parv[2]);
68 michael 6317 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
69 michael 6862 "Link %s dropped, wrong TS protocol version (%s,%s)",
70 michael 7996 client_get_name(source_p, MASK_IP), parv[1], parv[2]);
71 michael 6862 ilog(LOG_TYPE_IRCD,
72     "Link %s dropped, wrong TS protocol version (%s,%s)",
73 michael 7996 client_get_name(source_p, SHOW_IP), parv[1], parv[2]);
74 michael 6797
75 michael 3171 exit_client(source_p, "Incompatible TS version");
76 michael 2820 return 0;
77 michael 1298 }
78 adx 30
79     /*
80 michael 8927 * Since we're here, might as well set event_base->time.sec_real while we're at it
81 adx 30 */
82 michael 8901 event_time_set();
83 michael 3294
84 michael 8976 uintmax_t theirtime = strtoumax(parv[4], NULL, 10);
85 michael 8927 intmax_t deltat = imaxabs(theirtime - event_base->time.sec_real);
86 adx 30
87 michael 4341 if (deltat > ConfigGeneral.ts_max_delta)
88 michael 1298 {
89 michael 6317 sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
90 michael 8976 "Link %s dropped, excessive TS delta (my TS=%ju, their TS=%ju, delta=%ji)",
91 michael 8927 client_get_name(source_p, SHOW_IP), event_base->time.sec_real, theirtime, deltat);
92 michael 6317 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
93 michael 8976 "Link %s dropped, excessive TS delta (my TS=%ju, their TS=%ju, delta=%ji)",
94 michael 8927 client_get_name(source_p, MASK_IP), event_base->time.sec_real, theirtime, deltat);
95 michael 1298 ilog(LOG_TYPE_IRCD,
96 michael 8976 "Link %s dropped, excessive TS delta (my TS=%ju, their TS=%ju, delta=%ji)",
97 michael 8927 client_get_name(source_p, SHOW_IP), event_base->time.sec_real, theirtime, deltat);
98 michael 6797
99 michael 3171 exit_client(source_p, "Excessive TS delta");
100 michael 2820 return 0;
101 michael 1298 }
102 adx 30
103 michael 4341 if (deltat > ConfigGeneral.ts_warn_delta)
104 michael 6859 {
105     sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
106 michael 8976 "Link %s notable TS delta (my TS=%ju, their TS=%ju, delta=%ji)",
107 michael 8927 client_get_name(source_p, SHOW_IP), event_base->time.sec_real, theirtime, deltat);
108 michael 6859 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
109 michael 8976 "Link %s notable TS delta (my TS=%ju, their TS=%ju, delta=%ji)",
110 michael 8927 client_get_name(source_p, MASK_IP), event_base->time.sec_real, theirtime, deltat);
111 michael 6859 }
112    
113 michael 2820 return 0;
114 adx 30 }
115 michael 1230
116 michael 2820 static struct Message svinfo_msgtab =
117     {
118 michael 5880 .cmd = "SVINFO",
119     .args_min = 5,
120     .args_max = MAXPARA,
121     .handlers[UNREGISTERED_HANDLER] = m_unregistered,
122     .handlers[CLIENT_HANDLER] = m_ignore,
123     .handlers[SERVER_HANDLER] = ms_svinfo,
124     .handlers[ENCAP_HANDLER] = m_ignore,
125     .handlers[OPER_HANDLER] = m_ignore
126 michael 1230 };
127    
128     static void
129     module_init(void)
130     {
131     mod_add_cmd(&svinfo_msgtab);
132     }
133    
134     static void
135     module_exit(void)
136     {
137     mod_del_cmd(&svinfo_msgtab);
138     }
139    
140 michael 2820 struct module module_entry =
141     {
142 michael 1230 .version = "$Revision$",
143     .modinit = module_init,
144     .modexit = module_exit,
145     };

Properties

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