ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_testline.c
Revision: 1309
Committed: Sun Mar 25 11:24:18 2012 UTC (14 years, 6 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_testline.c
File size: 7362 byte(s)
Log Message:
- renaming files:

  ircd_parser.y -> conf_parser.y
  ircd_lexer.l  -> conf_lexer.l
  s_conf.c      -> conf.c
  s_conf.h      -> conf.h
  s_log.c       -> log.c
  s_log.h       -> log.h

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

Properties

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