1 |
adx |
30 |
/* |
2 |
michael |
2916 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2916 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
adx |
30 |
* |
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 |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
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 |
|
|
|
22 |
michael |
3321 |
/*! \file gline.c |
23 |
michael |
2916 |
* \brief GLine global ban functions. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
|
|
|
27 |
adx |
30 |
#include "stdinc.h" |
28 |
michael |
1011 |
#include "list.h" |
29 |
adx |
30 |
#include "client.h" |
30 |
|
|
#include "irc_string.h" |
31 |
|
|
#include "ircd.h" |
32 |
michael |
1632 |
#include "conf.h" |
33 |
adx |
30 |
#include "hostmask.h" |
34 |
michael |
3321 |
#include "gline.h" |
35 |
adx |
30 |
#include "memory.h" |
36 |
|
|
|
37 |
|
|
|
38 |
michael |
3250 |
dlink_list pending_glines[GLINE_PENDING_ADD_TYPE + 1]; |
39 |
adx |
30 |
|
40 |
michael |
1632 |
struct MaskItem * |
41 |
adx |
30 |
find_is_glined(const char *host, const char *user) |
42 |
|
|
{ |
43 |
michael |
1644 |
struct irc_ssaddr iphost, *piphost = NULL; |
44 |
|
|
int t = 0; |
45 |
|
|
int aftype = 0; |
46 |
adx |
30 |
|
47 |
michael |
1644 |
if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) |
48 |
adx |
30 |
{ |
49 |
|
|
#ifdef IPV6 |
50 |
|
|
if (t == HM_IPV6) |
51 |
michael |
1644 |
aftype = AF_INET6; |
52 |
adx |
30 |
else |
53 |
|
|
#endif |
54 |
michael |
1644 |
aftype = AF_INET; |
55 |
adx |
30 |
piphost = &iphost; |
56 |
|
|
} |
57 |
|
|
else |
58 |
|
|
piphost = NULL; |
59 |
|
|
|
60 |
michael |
2870 |
return find_conf_by_address(host, piphost, CONF_GLINE, aftype, user, NULL, 0); |
61 |
adx |
30 |
} |
62 |
|
|
|
63 |
|
|
/* expire_pending_glines() |
64 |
|
|
* |
65 |
|
|
* inputs - NONE |
66 |
|
|
* output - NONE |
67 |
|
|
* side effects - |
68 |
|
|
* |
69 |
|
|
* Go through the pending gline list, expire any that haven't had |
70 |
|
|
* enough "votes" in the time period allowed |
71 |
|
|
*/ |
72 |
|
|
static void |
73 |
michael |
957 |
expire_pending_glines(struct gline_pending *in) |
74 |
adx |
30 |
{ |
75 |
michael |
3250 |
dlink_node *ptr = NULL, *ptr_next = NULL; |
76 |
adx |
30 |
|
77 |
michael |
3250 |
for (unsigned int i = 0; i < GLINE_PENDING_ADD_TYPE + 1; ++i) |
78 |
adx |
30 |
{ |
79 |
michael |
3250 |
DLINK_FOREACH_SAFE(ptr, ptr_next, pending_glines[i].head) |
80 |
michael |
957 |
{ |
81 |
|
|
struct gline_pending *glp_ptr = ptr->data; |
82 |
adx |
30 |
|
83 |
michael |
1459 |
if ((glp_ptr->last_gline_time + ConfigFileEntry.gline_request_time) <= CurrentTime || |
84 |
michael |
957 |
glp_ptr == in) |
85 |
|
|
{ |
86 |
michael |
3250 |
dlinkDelete(&glp_ptr->node, &pending_glines[i]); |
87 |
michael |
957 |
MyFree(glp_ptr); |
88 |
|
|
} |
89 |
adx |
30 |
} |
90 |
|
|
} |
91 |
|
|
} |
92 |
michael |
1997 |
|
93 |
|
|
/* cleanup_glines() |
94 |
|
|
* |
95 |
|
|
* inputs - NONE |
96 |
|
|
* output - NONE |
97 |
|
|
* side effects - expire gline lists |
98 |
|
|
* This is an event started off in ircd.c |
99 |
|
|
*/ |
100 |
|
|
void |
101 |
|
|
cleanup_glines(void *unused) |
102 |
|
|
{ |
103 |
|
|
expire_pending_glines(unused); |
104 |
|
|
} |