ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svinfo.c
Revision: 3156
Committed: Fri Mar 14 19:57:38 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4442 byte(s)
Log Message:
- Removed client_p pointers from everywhere

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_svinfo.c
23 * \brief Includes required functions for processing the SVINFO command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "irc_string.h"
30 #include "ircd.h"
31 #include "send.h"
32 #include "conf.h"
33 #include "log.h"
34 #include "parse.h"
35 #include "modules.h"
36
37
38 /*
39 * ms_svinfo - SVINFO message handler
40 * parv[0] = command
41 * parv[1] = TS_CURRENT for the server
42 * parv[2] = TS_MIN for the server
43 * parv[3] = server is standalone or connected to non-TS only
44 * parv[4] = server's idea of UTC time
45 */
46 static int
47 ms_svinfo(struct Client *source_p, 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 0;
56 }
57
58 if (!IsServer(source_p) || !MyConnect(source_p) || parc < 5)
59 return 0;
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, SEND_NOTICE,
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, SEND_NOTICE,
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 0;
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, SEND_NOTICE,
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, SEND_NOTICE,
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 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 0;
107 }
108
109 if (deltat > ConfigFileEntry.ts_warn_delta)
110 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
111 "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 return 0;
117 }
118
119 static struct Message svinfo_msgtab =
120 {
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 {
139 .node = { NULL, NULL, NULL },
140 .name = NULL,
141 .version = "$Revision$",
142 .handle = NULL,
143 .modinit = module_init,
144 .modexit = module_exit,
145 .flags = 0
146 };

Properties

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