1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* s_gline.c: GLine global ban functions. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file s_gline.c |
23 |
> |
* \brief GLine global ban functions. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
29 |
|
#include "client.h" |
30 |
|
#include "irc_string.h" |
31 |
|
#include "ircd.h" |
32 |
+ |
#include "conf.h" |
33 |
|
#include "hostmask.h" |
31 |
– |
#include "s_conf.h" |
34 |
|
#include "s_misc.h" |
35 |
|
#include "send.h" |
36 |
|
#include "s_serv.h" |
38 |
|
#include "event.h" |
39 |
|
#include "memory.h" |
40 |
|
|
39 |
– |
dlink_list pending_glines[GLINE_PENDING_ADD_TYPE + 1] = { { NULL, NULL, 0 }, |
40 |
– |
{ NULL, NULL, 0 } }; |
41 |
– |
|
42 |
– |
static void expire_pending_glines(struct gline_pending *); |
41 |
|
|
42 |
+ |
dlink_list pending_glines[GLINE_PENDING_ADD_TYPE + 1]; |
43 |
|
|
44 |
< |
struct AccessItem * |
44 |
> |
struct MaskItem * |
45 |
|
find_is_glined(const char *host, const char *user) |
46 |
|
{ |
47 |
< |
struct irc_ssaddr iphost, *piphost; |
48 |
< |
struct AccessItem *aconf; |
49 |
< |
int t; |
47 |
> |
struct irc_ssaddr iphost, *piphost = NULL; |
48 |
> |
int t = 0; |
49 |
> |
int aftype = 0; |
50 |
|
|
51 |
< |
if ((t = parse_netmask(host, &iphost, &t)) != HM_HOST) |
51 |
> |
if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) |
52 |
|
{ |
53 |
|
#ifdef IPV6 |
54 |
|
if (t == HM_IPV6) |
55 |
< |
t = AF_INET6; |
55 |
> |
aftype = AF_INET6; |
56 |
|
else |
57 |
|
#endif |
58 |
< |
t = AF_INET; |
58 |
> |
aftype = AF_INET; |
59 |
|
piphost = &iphost; |
60 |
|
} |
61 |
|
else |
63 |
– |
{ |
64 |
– |
t = 0; |
62 |
|
piphost = NULL; |
66 |
– |
} |
63 |
|
|
64 |
< |
aconf = find_conf_by_address(host, piphost, CONF_GLINE, t, user, NULL); |
69 |
< |
return aconf; |
70 |
< |
} |
71 |
< |
|
72 |
< |
/* cleanup_glines() |
73 |
< |
* |
74 |
< |
* inputs - NONE |
75 |
< |
* output - NONE |
76 |
< |
* side effects - expire gline lists |
77 |
< |
* This is an event started off in ircd.c |
78 |
< |
*/ |
79 |
< |
void |
80 |
< |
cleanup_glines(void *unused) |
81 |
< |
{ |
82 |
< |
expire_pending_glines(unused); |
64 |
> |
return find_conf_by_address(host, piphost, CONF_GLINE, aftype, user, NULL, 0); |
65 |
|
} |
66 |
|
|
67 |
|
/* expire_pending_glines() |
76 |
|
static void |
77 |
|
expire_pending_glines(struct gline_pending *in) |
78 |
|
{ |
79 |
< |
dlink_node *ptr = NULL, *next_ptr = NULL; |
98 |
< |
int idx = 0; |
79 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
80 |
|
|
81 |
< |
for (; idx < GLINE_PENDING_ADD_TYPE + 1; ++idx) |
81 |
> |
for (unsigned int i = 0; i < GLINE_PENDING_ADD_TYPE + 1; ++i) |
82 |
|
{ |
83 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, pending_glines[idx].head) |
83 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, pending_glines[i].head) |
84 |
|
{ |
85 |
|
struct gline_pending *glp_ptr = ptr->data; |
86 |
|
|
87 |
< |
if ((glp_ptr->last_gline_time + GLINE_PENDING_EXPIRE) <= CurrentTime || |
87 |
> |
if ((glp_ptr->last_gline_time + ConfigFileEntry.gline_request_time) <= CurrentTime || |
88 |
|
glp_ptr == in) |
89 |
|
{ |
90 |
< |
dlinkDelete(&glp_ptr->node, &pending_glines[idx]); |
90 |
> |
dlinkDelete(&glp_ptr->node, &pending_glines[i]); |
91 |
|
MyFree(glp_ptr); |
92 |
|
} |
93 |
|
} |
113 |
– |
|
114 |
– |
ptr = NULL, next_ptr = NULL; |
94 |
|
} |
95 |
|
} |
96 |
+ |
|
97 |
+ |
/* cleanup_glines() |
98 |
+ |
* |
99 |
+ |
* inputs - NONE |
100 |
+ |
* output - NONE |
101 |
+ |
* side effects - expire gline lists |
102 |
+ |
* This is an event started off in ircd.c |
103 |
+ |
*/ |
104 |
+ |
void |
105 |
+ |
cleanup_glines(void *unused) |
106 |
+ |
{ |
107 |
+ |
expire_pending_glines(unused); |
108 |
+ |
} |