ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_testline.c
Revision: 1369
Committed: Wed Apr 25 19:04:19 2012 UTC (11 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 7363 byte(s)
Log Message:
- cleanup temporary k/d/g line code

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_testline.c: Tests a hostmask to see what will happen to it.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "client.h"
27 #include "irc_string.h"
28 #include "ircd_defs.h"
29 #include "ircd.h"
30 #include "restart.h"
31 #include "conf.h"
32 #include "send.h"
33 #include "hostmask.h"
34 #include "numeric.h"
35 #include "parse.h"
36 #include "resv.h"
37 #include "hash.h"
38 #include "modules.h"
39
40
41 /* mo_testline()
42 *
43 * inputs - pointer to physical connection request is coming from
44 * - pointer to source connection request is coming from
45 * - parc arg count
46 * - parv actual arguments
47 *
48 * output - NONE
49 * side effects - command to test I/K lines on server
50 *
51 * i.e. /quote testline user@host,ip [password]
52 *
53 */
54 static void
55 mo_testline(struct Client *client_p, struct Client *source_p,
56 int parc, char *parv[])
57 {
58 /* IRCD_BUFSIZE to allow things like *u*s*e*r*n*a*m*e* etc. */
59 char given_name[IRCD_BUFSIZE];
60 char given_host[IRCD_BUFSIZE];
61 char parv1_copy[IRCD_BUFSIZE];
62 struct ConfItem *conf;
63 struct AccessItem *aconf;
64 struct irc_ssaddr ip;
65 int host_mask;
66 int t;
67 int matches = 0;
68 char userhost[HOSTLEN + USERLEN + 2];
69 struct split_nuh_item nuh;
70
71 if (EmptyString(parv[1]))
72 {
73 sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip [password]",
74 me.name, source_p->name);
75 return;
76 }
77
78 if (IsChanPrefix(*parv[1])) /* Might be channel resv */
79 {
80 const struct ResvChannel *chptr = NULL;
81
82 if ((chptr = match_find_resv(parv[1])))
83 {
84 sendto_one(source_p, form_str(RPL_TESTLINE),
85 me.name, source_p->name, 'Q', 0, chptr->name,
86 chptr->reason ? chptr->reason : "No reason", "");
87 return;
88 }
89 }
90
91 strlcpy(parv1_copy, parv[1], sizeof(parv1_copy));
92
93 nuh.nuhmask = parv[1];
94 nuh.nickptr = NULL;
95 nuh.userptr = given_name;
96 nuh.hostptr = given_host;
97
98 nuh.nicksize = 0;
99 nuh.usersize = sizeof(given_name);
100 nuh.hostsize = sizeof(given_host);
101
102 split_nuh(&nuh);
103
104 t = parse_netmask(given_host, &ip, &host_mask);
105
106 if (t != HM_HOST)
107 {
108 aconf = find_dline_conf(&ip,
109 #ifdef IPV6
110 (t == HM_IPV6) ? AF_INET6 : AF_INET
111 #else
112 AF_INET
113 #endif
114 );
115 if (aconf != NULL)
116 {
117 ++matches;
118 if (aconf->status & CONF_EXEMPTDLINE)
119 sendto_one(source_p,
120 ":%s NOTICE %s :Exempt D-line host [%s] reason [%s]",
121 me.name, source_p->name, aconf->host, aconf->reason);
122 else
123 sendto_one(source_p, form_str(RPL_TESTLINE),
124 me.name, source_p->name,
125 IsConfTemporary(aconf) ? 'd' : 'D',
126 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
127 : 0L,
128 aconf->host, aconf->reason, aconf->oper_reason);
129 }
130 }
131
132 if (t != HM_HOST)
133 aconf = find_address_conf(given_host, given_name, &ip,
134 #ifdef IPV6
135 (t == HM_IPV6) ? AF_INET6 : AF_INET,
136 #else
137 AF_INET,
138 #endif
139 parv[2]);
140 else
141 aconf = find_address_conf(given_host, given_name, NULL, 0, parv[2]);
142
143 if (aconf != NULL)
144 {
145 snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
146
147 if (aconf->status & CONF_CLIENT)
148 {
149 sendto_one(source_p, form_str(RPL_TESTLINE),
150 me.name, source_p->name, 'I', 0L, userhost,
151 aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
152 ++matches;
153 }
154 else if (aconf->status & CONF_KLINE)
155 {
156 sendto_one(source_p, form_str(RPL_TESTLINE),
157 me.name, source_p->name,
158 IsConfTemporary(aconf) ? 'k' : 'K',
159 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
160 : 0L,
161 userhost, aconf->reason? aconf->reason : "No reason",
162 aconf->oper_reason ? aconf->oper_reason : "");
163 ++matches;
164 }
165 }
166
167 conf = find_matching_name_conf(NRESV_TYPE, given_name, NULL, NULL, 0);
168
169 if (conf != NULL)
170 {
171 const struct MatchItem *mconf = map_to_conf(conf);
172
173 sendto_one(source_p, form_str(RPL_TESTLINE),
174 me.name, source_p->name, 'Q', 0L,
175 conf->name,
176 mconf->reason ? mconf->reason : "No reason",
177 mconf->oper_reason ? mconf->oper_reason : "");
178 ++matches;
179 }
180
181 if (matches == 0)
182 sendto_one(source_p, form_str(RPL_NOTESTLINE),
183 me.name, source_p->name, parv1_copy);
184 }
185
186 /* mo_testgecos()
187 *
188 * inputs - pointer to physical connection request is coming from
189 * - pointer to source connection request is coming from
190 * - parc arg count
191 * - parv actual arguments
192 *
193 * output - always 0
194 * side effects - command to test X lines on server
195 *
196 * i.e. /quote testgecos gecos
197 *
198 */
199 static void
200 mo_testgecos(struct Client *client_p, struct Client *source_p,
201 int parc, char *parv[])
202 {
203 struct ConfItem *conf = NULL;
204
205 if (EmptyString(parv[1]))
206 {
207 sendto_one(source_p, ":%s NOTICE %s :usage: gecos",
208 me.name, source_p->name);
209 return;
210 }
211
212 if ((conf = find_matching_name_conf(XLINE_TYPE, parv[1], NULL, NULL, 0)))
213 {
214 const struct MatchItem *xconf = map_to_conf(conf);
215 sendto_one(source_p, form_str(RPL_TESTLINE),
216 me.name, source_p->name, 'X', 0L,
217 conf->name, xconf->reason ? xconf->reason : "X-lined",
218 xconf->oper_reason ? xconf->oper_reason : "");
219 }
220 else
221 sendto_one(source_p, form_str(RPL_NOTESTLINE),
222 me.name, source_p->name, parv[1]);
223 }
224
225 static struct Message testline_msgtab = {
226 "TESTLINE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
227 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testline, m_ignore }
228 };
229
230 struct Message testgecos_msgtab = {
231 "TESTGECOS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
232 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testgecos, m_ignore }
233 };
234
235 static void
236 module_init(void)
237 {
238 mod_add_cmd(&testline_msgtab);
239 mod_add_cmd(&testgecos_msgtab);
240 }
241
242 static void
243 module_exit(void)
244 {
245 mod_del_cmd(&testline_msgtab);
246 mod_del_cmd(&testgecos_msgtab);
247 }
248
249 struct module module_entry = {
250 .node = { NULL, NULL, NULL },
251 .name = NULL,
252 .version = "$Revision$",
253 .handle = NULL,
254 .modinit = module_init,
255 .modexit = module_exit,
256 .flags = 0
257 };

Properties

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