/[svn]/ircd-hybrid-7.2/modules/m_testline.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/modules/m_testline.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 138 - (show annotations)
Sun Oct 16 01:20:07 2005 UTC (14 years, 4 months ago) by db
File MIME type: text/x-chdr
File size: 7155 byte(s)
- fix compile warning


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

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26