ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/modules/m_testline.c
Revision: 32
Committed: Sun Oct 2 20:41:23 2005 UTC (19 years, 10 months ago) by knight
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_testline.c
File size: 7227 byte(s)
Log Message:
- svn:keywords

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
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 knight 31 const char *_version = "$Revision$";
72 adx 30 #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, *p;
92     const 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     if ((p = strchr(given_name, '@')) != NULL)
127     {
128     *p++ = '\0';
129     given_host = p;
130     }
131     else
132     given_host = "*";
133    
134     t = parse_netmask(given_name, &ip, &host_mask);
135    
136     if (t != HM_HOST)
137     {
138     aconf = find_dline_conf(&ip,
139     #ifdef IPV6
140     (t == HM_IPV6) ? AF_INET6 : AF_INET
141     #else
142     AF_INET
143     #endif
144     );
145     if (aconf != NULL)
146     {
147     conf = unmap_conf_item(aconf);
148    
149     if (aconf->status & CONF_EXEMPTDLINE)
150     {
151     sendto_one(source_p,
152     ":%s NOTICE %s :Exempt D-line host [%s] reason [%s]",
153     me.name, source_p->name, aconf->host, aconf->reason);
154     ++matches;
155     }
156     else
157     {
158     sendto_one(source_p,
159     form_str(RPL_TESTLINE),
160     me.name, source_p->name,
161     IsConfTemporary(aconf) ? 'd' : 'D',
162     IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
163     : 0L,
164     aconf->host, aconf->reason, aconf->oper_reason);
165     ++matches;
166     }
167     }
168     }
169    
170     aconf = find_kline_conf(given_host, given_name, &ip, t);
171     if ((aconf != NULL) && (aconf->status & CONF_KILL))
172     {
173     snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
174     sendto_one(source_p, form_str(RPL_TESTLINE),
175     me.name, source_p->name,
176     IsConfTemporary(aconf) ? 'k' : 'K',
177     IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
178     : 0L,
179     userhost,
180     aconf->passwd ? aconf->passwd : "No reason",
181     aconf->oper_reason ? aconf->oper_reason : "");
182     ++matches;
183     }
184    
185    
186     if (t != HM_HOST)
187     aconf = find_address_conf(given_host, given_name, &ip,
188     #ifdef IPV6
189     (t == HM_IPV6) ? AF_INET6 : AF_INET,
190     #else
191     AF_INET,
192     #endif
193     parv[2]);
194     else
195     aconf = find_address_conf(given_host, given_name, NULL, 0, parv[2]);
196    
197     if (aconf != NULL)
198     {
199     conf = unmap_conf_item(aconf);
200    
201     snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
202    
203     if (aconf->status & CONF_CLIENT)
204     {
205     sendto_one(source_p, form_str(RPL_TESTLINE),
206     me.name, source_p->name,
207     'I', 0L, userhost,
208     aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
209     ++matches;
210     }
211     }
212    
213     conf = find_matching_name_conf(NRESV_TYPE, given_name, NULL, NULL, 0);
214    
215     if (conf != NULL)
216     {
217     struct MatchItem *mconf;
218     mconf = (struct MatchItem *)map_to_conf(conf);
219    
220     sendto_one(source_p, form_str(RPL_TESTLINE),
221     me.name, source_p->name,
222     'Q', 0L,
223     conf->name,
224     mconf->reason ? mconf->reason : "No reason",
225     mconf->oper_reason ? mconf->oper_reason : "");
226     ++matches;
227     }
228    
229     if (matches == 0)
230     sendto_one(source_p, form_str(RPL_NOTESTLINE),
231     me.name, source_p->name, parv[1]);
232     }
233    
234     /* mo_testgecos()
235     *
236     * inputs - pointer to physical connection request is coming from
237     * - pointer to source connection request is coming from
238     * - parc arg count
239     * - parv actual arguments
240     *
241     * output - always 0
242     * side effects - command to test X lines on server
243     *
244     * i.e. /quote testgecos gecos
245     *
246     */
247     static void
248     mo_testgecos(struct Client *client_p, struct Client *source_p,
249     int parc, char *parv[])
250     {
251     struct ConfItem *conf = NULL;
252     struct MatchItem *xconf = NULL;
253     const char *gecos_name = NULL;
254    
255     if (parc < 2 || EmptyString(parv[1]))
256     {
257     sendto_one(source_p, ":%s NOTICE %s :usage: gecos",
258     me.name, source_p->name);
259     return;
260     }
261    
262     gecos_name = parv[1];
263    
264     if ((conf = find_matching_name_conf(XLINE_TYPE, gecos_name, NULL, NULL, 0))
265     != NULL)
266     {
267     xconf = (struct MatchItem *)map_to_conf(conf);
268     sendto_one(source_p, form_str(RPL_TESTLINE),
269     me.name, source_p->name, 'X', 0L,
270     conf->name, xconf->reason ? xconf->reason : "X-lined",
271     xconf->oper_reason ? xconf->oper_reason : "");
272     }
273     else
274     sendto_one(source_p, form_str(RPL_NOTESTLINE),
275     me.name, source_p->name, parv[1]);
276     }

Properties

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