44 |
#include "modules.h" |
#include "modules.h" |
45 |
|
|
46 |
|
|
|
static int remove_tdline_match(const char *); |
|
|
|
|
47 |
/* apply_tdline() |
/* apply_tdline() |
48 |
* |
* |
49 |
* inputs - |
* inputs - |
74 |
rehashed_klines = 1; |
rehashed_klines = 1; |
75 |
} |
} |
76 |
|
|
77 |
|
/* static int remove_tdline_match(const char *host, const char *user) |
78 |
|
* Input: An ip to undline. |
79 |
|
* Output: returns YES on success, NO if no tdline removed. |
80 |
|
* Side effects: Any matching tdlines are removed. |
81 |
|
*/ |
82 |
|
static int |
83 |
|
remove_tdline_match(const char *host) |
84 |
|
{ |
85 |
|
struct AccessItem *td_conf; |
86 |
|
dlink_node *td_node; |
87 |
|
struct irc_ssaddr addr, caddr; |
88 |
|
int nm_t, cnm_t, bits, cbits; |
89 |
|
|
90 |
|
nm_t = parse_netmask(host, &addr, &bits); |
91 |
|
|
92 |
|
DLINK_FOREACH(td_node, temporary_dlines.head) |
93 |
|
{ |
94 |
|
td_conf = map_to_conf(td_node->data); |
95 |
|
cnm_t = parse_netmask(td_conf->host, &caddr, &cbits); |
96 |
|
|
97 |
|
if (cnm_t != nm_t) |
98 |
|
continue; |
99 |
|
|
100 |
|
if ((nm_t == HM_HOST && !irccmp(td_conf->host, host)) || |
101 |
|
(nm_t == HM_IPV4 && bits == cbits && match_ipv4(&addr, &caddr, bits)) |
102 |
|
#ifdef IPV6 |
103 |
|
|| (nm_t == HM_IPV6 && bits == cbits && match_ipv6(&addr, &caddr, bits)) |
104 |
|
#endif |
105 |
|
) |
106 |
|
{ |
107 |
|
dlinkDelete(td_node, &temporary_dlines); |
108 |
|
delete_one_address_conf(td_conf->host, td_conf); |
109 |
|
return 1; |
110 |
|
} |
111 |
|
} |
112 |
|
|
113 |
|
return 0; |
114 |
|
} |
115 |
|
|
116 |
/* mo_dline() |
/* mo_dline() |
117 |
* |
* |
118 |
* inputs - pointer to server |
* inputs - pointer to server |
248 |
rehashed_klines = 1; |
rehashed_klines = 1; |
249 |
} |
} |
250 |
|
|
|
/* static int remove_tdline_match(const char *host, const char *user) |
|
|
* Input: An ip to undline. |
|
|
* Output: returns YES on success, NO if no tdline removed. |
|
|
* Side effects: Any matching tdlines are removed. |
|
|
*/ |
|
|
static int |
|
|
remove_tdline_match(const char *cidr) |
|
|
{ |
|
|
struct AccessItem *td_conf; |
|
|
dlink_node *td_node; |
|
|
struct irc_ssaddr addr, caddr; |
|
|
int nm_t, cnm_t, bits, cbits; |
|
|
nm_t = parse_netmask(cidr, &addr, &bits); |
|
|
|
|
|
DLINK_FOREACH(td_node, temporary_dlines.head) |
|
|
{ |
|
|
td_conf = map_to_conf(td_node->data); |
|
|
cnm_t = parse_netmask(td_conf->host, &caddr, &cbits); |
|
|
|
|
|
if (cnm_t != nm_t) |
|
|
continue; |
|
|
|
|
|
if((nm_t==HM_HOST && !irccmp(td_conf->host, cidr)) || |
|
|
(nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits)) |
|
|
#ifdef IPV6 |
|
|
|| (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits)) |
|
|
#endif |
|
|
) |
|
|
{ |
|
|
dlinkDelete(td_node, &temporary_dlines); |
|
|
delete_one_address_conf(td_conf->host, td_conf); |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
251 |
/* |
/* |
252 |
** m_undline |
** m_undline |
253 |
** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk> |
** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk> |
261 |
mo_undline(struct Client *client_p, struct Client *source_p, |
mo_undline(struct Client *client_p, struct Client *source_p, |
262 |
int parc, char *parv[]) |
int parc, char *parv[]) |
263 |
{ |
{ |
264 |
const char *cidr = NULL; |
const char *addr = NULL; |
265 |
|
|
266 |
if (!HasOFlag(source_p, OPER_FLAG_UNKLINE)) |
if (!HasOFlag(source_p, OPER_FLAG_UNKLINE)) |
267 |
{ |
{ |
270 |
return; |
return; |
271 |
} |
} |
272 |
|
|
273 |
cidr = parv[1]; |
addr = parv[1]; |
274 |
|
|
275 |
if (remove_tdline_match(cidr)) |
if (remove_tdline_match(addr)) |
276 |
{ |
{ |
277 |
sendto_one(source_p, |
sendto_one(source_p, |
278 |
":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines", |
":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines", |
279 |
me.name, source_p->name, cidr); |
me.name, source_p->name, addr); |
280 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
sendto_realops_flags(UMODE_ALL, L_ALL, |
281 |
"%s has removed the temporary D-Line for: [%s]", |
"%s has removed the temporary D-Line for: [%s]", |
282 |
get_oper_name(source_p), cidr); |
get_oper_name(source_p), addr); |
283 |
ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]", source_p->name, cidr); |
ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]", source_p->name, addr); |
284 |
return; |
return; |
285 |
} |
} |
286 |
|
|
287 |
if (remove_conf_line(DLINE_TYPE, source_p, cidr, NULL) > 0) |
if (remove_conf_line(DLINE_TYPE, source_p, addr, NULL) > 0) |
288 |
{ |
{ |
289 |
sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", |
sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", |
290 |
me.name, source_p->name, cidr); |
me.name, source_p->name, addr); |
291 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
sendto_realops_flags(UMODE_ALL, L_ALL, |
292 |
"%s has removed the D-Line for: [%s]", |
"%s has removed the D-Line for: [%s]", |
293 |
get_oper_name(source_p), cidr); |
get_oper_name(source_p), addr); |
294 |
ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]", |
ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]", |
295 |
get_oper_name(source_p), cidr); |
get_oper_name(source_p), addr); |
296 |
} |
} |
297 |
else |
else |
298 |
sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found", |
sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found", |
299 |
me.name, source_p->name, cidr); |
me.name, source_p->name, addr); |
300 |
} |
} |
301 |
|
|
302 |
static struct Message dline_msgtab = { |
static struct Message dline_msgtab = { |