ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_testline.c
Revision: 141
Committed: Sun Oct 16 06:29:10 2005 UTC (20 years, 9 months ago) by db
Content type: text/x-csrc
File size: 7085 byte(s)
Log Message:
- Make ->conf conf_ptr to be consistent in all places.


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

Properties

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