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**); |
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} |
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} |
53 |
> |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testgecos, m_ignore } |
54 |
|
}; |
55 |
|
|
56 |
– |
#ifndef STATIC_MODULES |
56 |
|
void |
57 |
|
_modinit(void) |
58 |
|
{ |
68 |
|
} |
69 |
|
|
70 |
|
const char *_version = "$Revision$"; |
72 |
– |
#endif |
71 |
|
|
72 |
|
/* mo_testline() |
73 |
|
* |
86 |
|
mo_testline(struct Client *client_p, struct Client *source_p, |
87 |
|
int parc, char *parv[]) |
88 |
|
{ |
89 |
< |
char *orig_parv1; |
90 |
< |
char *given_name; |
91 |
< |
char *given_host = NULL; |
89 |
> |
/* IRCD_BUFSIZE to allow things like *u*s*e*r*n*a*m*e* etc. */ |
90 |
> |
char given_name[IRCD_BUFSIZE]; |
91 |
> |
char given_host[IRCD_BUFSIZE]; |
92 |
> |
char parv1_copy[IRCD_BUFSIZE]; |
93 |
|
struct ConfItem *conf; |
94 |
|
struct AccessItem *aconf; |
95 |
|
struct irc_ssaddr ip; |
97 |
|
int t; |
98 |
|
int matches = 0; |
99 |
|
char userhost[HOSTLEN + USERLEN + 2]; |
100 |
+ |
struct split_nuh_item nuh; |
101 |
|
|
102 |
< |
if (parc < 2 || EmptyString(parv[1])) |
102 |
> |
if (EmptyString(parv[1])) |
103 |
|
{ |
104 |
|
sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip [password]", |
105 |
|
me.name, source_p->name); |
106 |
|
return; |
107 |
|
} |
108 |
|
|
109 |
< |
given_name = parv[1]; |
110 |
< |
|
111 |
< |
if (IsChanPrefix(*given_name)) /* Might be channel resv */ |
109 |
> |
if (IsChanPrefix(*parv[1])) /* Might be channel resv */ |
110 |
|
{ |
111 |
< |
struct ResvChannel *chptr; |
112 |
< |
|
113 |
< |
chptr = match_find_resv(given_name); |
116 |
< |
if (chptr != NULL) |
111 |
> |
const struct ResvChannel *chptr = NULL; |
112 |
> |
|
113 |
> |
if ((chptr = match_find_resv(parv[1]))) |
114 |
|
{ |
115 |
< |
sendto_one(source_p, |
116 |
< |
form_str(RPL_TESTLINE), |
117 |
< |
me.name, source_p->name, |
121 |
< |
'Q', 0, chptr->name, |
122 |
< |
chptr->reason ? chptr->reason : "No reason", "" ); |
115 |
> |
sendto_one(source_p, form_str(RPL_TESTLINE), |
116 |
> |
me.name, source_p->name, 'Q', 0, chptr->name, |
117 |
> |
chptr->reason ? chptr->reason : "No reason", ""); |
118 |
|
return; |
119 |
|
} |
120 |
|
} |
121 |
|
|
122 |
< |
DupString(orig_parv1,parv[1]); |
123 |
< |
split_nuh(given_name, NULL, &given_name, &given_host); |
122 |
> |
strlcpy(parv1_copy, parv[1], sizeof(parv1_copy)); |
123 |
> |
|
124 |
> |
nuh.nuhmask = parv[1]; |
125 |
> |
nuh.nickptr = NULL; |
126 |
> |
nuh.userptr = given_name; |
127 |
> |
nuh.hostptr = given_host; |
128 |
> |
|
129 |
> |
nuh.nicksize = 0; |
130 |
> |
nuh.usersize = sizeof(given_name); |
131 |
> |
nuh.hostsize = sizeof(given_host); |
132 |
> |
|
133 |
> |
split_nuh(&nuh); |
134 |
|
|
135 |
|
t = parse_netmask(given_host, &ip, &host_mask); |
136 |
|
|
138 |
|
{ |
139 |
|
aconf = find_dline_conf(&ip, |
140 |
|
#ifdef IPV6 |
141 |
< |
(t == HM_IPV6) ? AF_INET6 : AF_INET |
141 |
> |
(t == HM_IPV6) ? AF_INET6 : AF_INET |
142 |
|
#else |
143 |
< |
AF_INET |
143 |
> |
AF_INET |
144 |
|
#endif |
145 |
< |
); |
145 |
> |
); |
146 |
|
if (aconf != NULL) |
147 |
|
{ |
148 |
< |
conf = unmap_conf_item(aconf); |
144 |
< |
|
148 |
> |
++matches; |
149 |
|
if (aconf->status & CONF_EXEMPTDLINE) |
150 |
< |
{ |
151 |
< |
sendto_one(source_p, |
152 |
< |
":%s NOTICE %s :Exempt D-line host [%s] reason [%s]", |
149 |
< |
me.name, source_p->name, aconf->host, aconf->reason); |
150 |
< |
++matches; |
151 |
< |
} |
150 |
> |
sendto_one(source_p, |
151 |
> |
":%s NOTICE %s :Exempt D-line host [%s] reason [%s]", |
152 |
> |
me.name, source_p->name, aconf->host, aconf->reason); |
153 |
|
else |
154 |
< |
{ |
155 |
< |
sendto_one(source_p, |
156 |
< |
form_str(RPL_TESTLINE), |
157 |
< |
me.name, source_p->name, |
158 |
< |
IsConfTemporary(aconf) ? 'd' : 'D', |
159 |
< |
IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60) |
159 |
< |
: 0L, |
160 |
< |
aconf->host, aconf->reason, aconf->oper_reason); |
161 |
< |
++matches; |
162 |
< |
} |
154 |
> |
sendto_one(source_p, form_str(RPL_TESTLINE), |
155 |
> |
me.name, source_p->name, |
156 |
> |
IsConfTemporary(aconf) ? 'd' : 'D', |
157 |
> |
IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60) |
158 |
> |
: 0L, |
159 |
> |
aconf->host, aconf->reason, aconf->oper_reason); |
160 |
|
} |
161 |
|
} |
162 |
|
|
166 |
– |
aconf = find_kline_conf(given_host, given_name, &ip, t); |
167 |
– |
if ((aconf != NULL) && (aconf->status & CONF_KILL)) |
168 |
– |
{ |
169 |
– |
snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host); |
170 |
– |
sendto_one(source_p, form_str(RPL_TESTLINE), |
171 |
– |
me.name, source_p->name, |
172 |
– |
IsConfTemporary(aconf) ? 'k' : 'K', |
173 |
– |
IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60) |
174 |
– |
: 0L, |
175 |
– |
userhost, |
176 |
– |
aconf->passwd ? aconf->passwd : "No reason", |
177 |
– |
aconf->oper_reason ? aconf->oper_reason : ""); |
178 |
– |
++matches; |
179 |
– |
} |
180 |
– |
|
181 |
– |
|
163 |
|
if (t != HM_HOST) |
164 |
|
aconf = find_address_conf(given_host, given_name, &ip, |
165 |
|
#ifdef IPV6 |
173 |
|
|
174 |
|
if (aconf != NULL) |
175 |
|
{ |
195 |
– |
conf = unmap_conf_item(aconf); |
196 |
– |
|
176 |
|
snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host); |
177 |
|
|
178 |
|
if (aconf->status & CONF_CLIENT) |
179 |
|
{ |
180 |
|
sendto_one(source_p, form_str(RPL_TESTLINE), |
181 |
< |
me.name, source_p->name, |
182 |
< |
'I', 0L, userhost, |
183 |
< |
aconf->class_ptr ? aconf->class_ptr->name : "<default>", ""); |
181 |
> |
me.name, source_p->name, 'I', 0L, userhost, |
182 |
> |
aconf->class_ptr ? aconf->class_ptr->name : "<default>", ""); |
183 |
> |
++matches; |
184 |
> |
} |
185 |
> |
else if (aconf->status & CONF_KILL) |
186 |
> |
{ |
187 |
> |
sendto_one(source_p, form_str(RPL_TESTLINE), |
188 |
> |
me.name, source_p->name, |
189 |
> |
IsConfTemporary(aconf) ? 'k' : 'K', |
190 |
> |
IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60) |
191 |
> |
: 0L, |
192 |
> |
userhost, aconf->reason? aconf->reason : "No reason", |
193 |
> |
aconf->oper_reason ? aconf->oper_reason : ""); |
194 |
|
++matches; |
195 |
|
} |
196 |
|
} |
199 |
|
|
200 |
|
if (conf != NULL) |
201 |
|
{ |
202 |
< |
struct MatchItem *mconf; |
214 |
< |
mconf = (struct MatchItem *)map_to_conf(conf); |
202 |
> |
const struct MatchItem *mconf = map_to_conf(conf); |
203 |
|
|
204 |
|
sendto_one(source_p, form_str(RPL_TESTLINE), |
205 |
< |
me.name, source_p->name, |
206 |
< |
'Q', 0L, |
207 |
< |
conf->name, |
208 |
< |
mconf->reason ? mconf->reason : "No reason", |
221 |
< |
mconf->oper_reason ? mconf->oper_reason : ""); |
205 |
> |
me.name, source_p->name, 'Q', 0L, |
206 |
> |
conf->name, |
207 |
> |
mconf->reason ? mconf->reason : "No reason", |
208 |
> |
mconf->oper_reason ? mconf->oper_reason : ""); |
209 |
|
++matches; |
210 |
|
} |
211 |
|
|
212 |
|
if (matches == 0) |
213 |
|
sendto_one(source_p, form_str(RPL_NOTESTLINE), |
214 |
< |
me.name, source_p->name, orig_parv1); |
228 |
< |
|
229 |
< |
MyFree(given_host); |
230 |
< |
MyFree(given_name); |
231 |
< |
MyFree(orig_parv1); |
214 |
> |
me.name, source_p->name, parv1_copy); |
215 |
|
} |
216 |
|
|
217 |
|
/* mo_testgecos() |
229 |
|
*/ |
230 |
|
static void |
231 |
|
mo_testgecos(struct Client *client_p, struct Client *source_p, |
232 |
< |
int parc, char *parv[]) |
232 |
> |
int parc, char *parv[]) |
233 |
|
{ |
234 |
|
struct ConfItem *conf = NULL; |
252 |
– |
struct MatchItem *xconf = NULL; |
253 |
– |
const char *gecos_name = NULL; |
235 |
|
|
236 |
< |
if (parc < 2 || EmptyString(parv[1])) |
236 |
> |
if (EmptyString(parv[1])) |
237 |
|
{ |
238 |
|
sendto_one(source_p, ":%s NOTICE %s :usage: gecos", |
239 |
|
me.name, source_p->name); |
240 |
|
return; |
241 |
|
} |
242 |
|
|
243 |
< |
gecos_name = parv[1]; |
263 |
< |
|
264 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, gecos_name, NULL, NULL, 0)) |
265 |
< |
!= NULL) |
243 |
> |
if ((conf = find_matching_name_conf(XLINE_TYPE, parv[1], NULL, NULL, 0))) |
244 |
|
{ |
245 |
< |
xconf = (struct MatchItem *)map_to_conf(conf); |
245 |
> |
const struct MatchItem *xconf = map_to_conf(conf); |
246 |
|
sendto_one(source_p, form_str(RPL_TESTLINE), |
247 |
< |
me.name, source_p->name, 'X', 0L, |
248 |
< |
conf->name, xconf->reason ? xconf->reason : "X-lined", |
249 |
< |
xconf->oper_reason ? xconf->oper_reason : ""); |
247 |
> |
me.name, source_p->name, 'X', 0L, |
248 |
> |
conf->name, xconf->reason ? xconf->reason : "X-lined", |
249 |
> |
xconf->oper_reason ? xconf->oper_reason : ""); |
250 |
|
} |
251 |
|
else |
252 |
|
sendto_one(source_p, form_str(RPL_NOTESTLINE), |
253 |
< |
me.name, source_p->name, parv[1]); |
253 |
> |
me.name, source_p->name, parv[1]); |
254 |
|
} |