ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.0.x/modules/m_testline.c
Revision: 1871
Committed: Fri Apr 26 08:53:04 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 7414 byte(s)
Log Message:
- Reverted to -r1820; libGeoIP support is sheduled for  8.1

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 : CONF_NOREASON, "");
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,
129 aconf->oper_reason ? aconf->oper_reason : "");
130 }
131 }
132
133 if (t != HM_HOST)
134 aconf = find_address_conf(given_host, given_name, &ip,
135 #ifdef IPV6
136 (t == HM_IPV6) ? AF_INET6 : AF_INET,
137 #else
138 AF_INET,
139 #endif
140 parv[2]);
141 else
142 aconf = find_address_conf(given_host, given_name, NULL, 0, parv[2]);
143
144 if (aconf != NULL)
145 {
146 snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
147
148 if (aconf->status & CONF_CLIENT)
149 {
150 sendto_one(source_p, form_str(RPL_TESTLINE),
151 me.name, source_p->name, 'I', 0L, userhost,
152 aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
153 ++matches;
154 }
155 else if (aconf->status & CONF_KLINE)
156 {
157 sendto_one(source_p, form_str(RPL_TESTLINE),
158 me.name, source_p->name,
159 IsConfTemporary(aconf) ? 'k' : 'K',
160 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
161 : 0L,
162 userhost, aconf->reason? aconf->reason : CONF_NOREASON,
163 aconf->oper_reason ? aconf->oper_reason : "");
164 ++matches;
165 }
166 }
167
168 conf = find_matching_name_conf(NRESV_TYPE, given_name, NULL, NULL, 0);
169
170 if (conf != NULL)
171 {
172 const struct MatchItem *mconf = map_to_conf(conf);
173
174 sendto_one(source_p, form_str(RPL_TESTLINE),
175 me.name, source_p->name, 'Q', 0L,
176 conf->name,
177 mconf->reason ? mconf->reason : CONF_NOREASON,
178 mconf->oper_reason ? mconf->oper_reason : "");
179 ++matches;
180 }
181
182 if (matches == 0)
183 sendto_one(source_p, form_str(RPL_NOTESTLINE),
184 me.name, source_p->name, parv1_copy);
185 }
186
187 /* mo_testgecos()
188 *
189 * inputs - pointer to physical connection request is coming from
190 * - pointer to source connection request is coming from
191 * - parc arg count
192 * - parv actual arguments
193 *
194 * output - always 0
195 * side effects - command to test X lines on server
196 *
197 * i.e. /quote testgecos gecos
198 *
199 */
200 static void
201 mo_testgecos(struct Client *client_p, struct Client *source_p,
202 int parc, char *parv[])
203 {
204 struct ConfItem *conf = NULL;
205
206 if (EmptyString(parv[1]))
207 {
208 sendto_one(source_p, ":%s NOTICE %s :usage: gecos",
209 me.name, source_p->name);
210 return;
211 }
212
213 if ((conf = find_matching_name_conf(XLINE_TYPE, parv[1], NULL, NULL, 0)))
214 {
215 const struct MatchItem *xconf = map_to_conf(conf);
216 sendto_one(source_p, form_str(RPL_TESTLINE),
217 me.name, source_p->name, 'X', 0L,
218 conf->name, xconf->reason ? xconf->reason : "X-lined",
219 xconf->oper_reason ? xconf->oper_reason : "");
220 }
221 else
222 sendto_one(source_p, form_str(RPL_NOTESTLINE),
223 me.name, source_p->name, parv[1]);
224 }
225
226 static struct Message testline_msgtab = {
227 "TESTLINE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
228 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testline, m_ignore }
229 };
230
231 struct Message testgecos_msgtab = {
232 "TESTGECOS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
233 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testgecos, m_ignore }
234 };
235
236 static void
237 module_init(void)
238 {
239 mod_add_cmd(&testline_msgtab);
240 mod_add_cmd(&testgecos_msgtab);
241 }
242
243 static void
244 module_exit(void)
245 {
246 mod_del_cmd(&testline_msgtab);
247 mod_del_cmd(&testgecos_msgtab);
248 }
249
250 struct module module_entry = {
251 .node = { NULL, NULL, NULL },
252 .name = NULL,
253 .version = "$Revision$",
254 .handle = NULL,
255 .modinit = module_init,
256 .modexit = module_exit,
257 .flags = 0
258 };

Properties

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