ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.0beta2/modules/m_testline.c
Revision: 1576
Committed: Thu Oct 18 14:41:13 2012 UTC (13 years, 9 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_testline.c
File size: 7408 byte(s)
Log Message:
- Fixed bug in stats_klines() showing oper_reason to unopered clients
- Fixed /stats d|D showing "(null)" if there's no oper_reason

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 "client.h"
27     #include "irc_string.h"
28     #include "ircd_defs.h"
29     #include "ircd.h"
30     #include "restart.h"
31 michael 1309 #include "conf.h"
32 adx 30 #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 michael 593 /* 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 michael 808 char parv1_copy[IRCD_BUFSIZE];
62 adx 30 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 michael 593 struct split_nuh_item nuh;
70 adx 30
71 michael 593 if (EmptyString(parv[1]))
72 adx 30 {
73     sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip [password]",
74     me.name, source_p->name);
75     return;
76     }
77    
78 michael 593 if (IsChanPrefix(*parv[1])) /* Might be channel resv */
79     {
80     const struct ResvChannel *chptr = NULL;
81 adx 30
82 michael 593 if ((chptr = match_find_resv(parv[1])))
83 adx 30 {
84 michael 593 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 adx 30 return;
88     }
89     }
90    
91 michael 808 strlcpy(parv1_copy, parv[1], sizeof(parv1_copy));
92 adx 30
93 michael 593 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 db 136 t = parse_netmask(given_host, &ip, &host_mask);
105 adx 30
106     if (t != HM_HOST)
107     {
108     aconf = find_dline_conf(&ip,
109     #ifdef IPV6
110 michael 593 (t == HM_IPV6) ? AF_INET6 : AF_INET
111 adx 30 #else
112 michael 593 AF_INET
113 adx 30 #endif
114 michael 593 );
115 adx 30 if (aconf != NULL)
116     {
117 michael 808 ++matches;
118 adx 30 if (aconf->status & CONF_EXEMPTDLINE)
119 michael 593 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 adx 30 else
123 michael 593 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 michael 1576 aconf->host, aconf->reason,
129     aconf->oper_reason ? aconf->oper_reason : "");
130 adx 30 }
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 michael 808 me.name, source_p->name, 'I', 0L, userhost,
152 michael 593 aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
153 adx 30 ++matches;
154     }
155 michael 1369 else if (aconf->status & CONF_KLINE)
156 db 150 {
157     sendto_one(source_p, form_str(RPL_TESTLINE),
158 michael 593 me.name, source_p->name,
159     IsConfTemporary(aconf) ? 'k' : 'K',
160     IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
161     : 0L,
162 michael 808 userhost, aconf->reason? aconf->reason : "No reason",
163 michael 593 aconf->oper_reason ? aconf->oper_reason : "");
164 db 150 ++matches;
165     }
166 adx 30 }
167    
168     conf = find_matching_name_conf(NRESV_TYPE, given_name, NULL, NULL, 0);
169    
170     if (conf != NULL)
171     {
172 michael 808 const struct MatchItem *mconf = map_to_conf(conf);
173 adx 30
174     sendto_one(source_p, form_str(RPL_TESTLINE),
175 michael 808 me.name, source_p->name, 'Q', 0L,
176 michael 593 conf->name,
177     mconf->reason ? mconf->reason : "No reason",
178     mconf->oper_reason ? mconf->oper_reason : "");
179 adx 30 ++matches;
180     }
181    
182     if (matches == 0)
183     sendto_one(source_p, form_str(RPL_NOTESTLINE),
184 michael 808 me.name, source_p->name, parv1_copy);
185 adx 30 }
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 michael 808 int parc, char *parv[])
203 adx 30 {
204     struct ConfItem *conf = NULL;
205    
206 michael 593 if (EmptyString(parv[1]))
207 adx 30 {
208     sendto_one(source_p, ":%s NOTICE %s :usage: gecos",
209     me.name, source_p->name);
210     return;
211     }
212    
213 michael 593 if ((conf = find_matching_name_conf(XLINE_TYPE, parv[1], NULL, NULL, 0)))
214 adx 30 {
215 michael 808 const struct MatchItem *xconf = map_to_conf(conf);
216 adx 30 sendto_one(source_p, form_str(RPL_TESTLINE),
217 michael 593 me.name, source_p->name, 'X', 0L,
218     conf->name, xconf->reason ? xconf->reason : "X-lined",
219     xconf->oper_reason ? xconf->oper_reason : "");
220 adx 30 }
221     else
222     sendto_one(source_p, form_str(RPL_NOTESTLINE),
223 michael 593 me.name, source_p->name, parv[1]);
224 adx 30 }
225 michael 1230
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