1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2015 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 |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file gline.c |
23 |
* \brief GLine global ban functions. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "list.h" |
29 |
#include "client.h" |
30 |
#include "irc_string.h" |
31 |
#include "ircd.h" |
32 |
#include "conf.h" |
33 |
#include "hostmask.h" |
34 |
#include "gline.h" |
35 |
#include "memory.h" |
36 |
|
37 |
|
38 |
dlink_list pending_glines[GLINE_PENDING_ADD_TYPE + 1]; |
39 |
|
40 |
struct MaskItem * |
41 |
find_is_glined(const char *host, const char *user) |
42 |
{ |
43 |
struct irc_ssaddr iphost, *piphost = NULL; |
44 |
int t = 0; |
45 |
int aftype = 0; |
46 |
|
47 |
if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) |
48 |
{ |
49 |
if (t == HM_IPV6) |
50 |
aftype = AF_INET6; |
51 |
else |
52 |
aftype = AF_INET; |
53 |
piphost = &iphost; |
54 |
} |
55 |
else |
56 |
piphost = NULL; |
57 |
|
58 |
return find_conf_by_address(host, piphost, CONF_GLINE, aftype, user, NULL, 0); |
59 |
} |
60 |
|
61 |
/* expire_pending_glines() |
62 |
* |
63 |
* inputs - NONE |
64 |
* output - NONE |
65 |
* side effects - |
66 |
* |
67 |
* Go through the pending gline list, expire any that haven't had |
68 |
* enough "votes" in the time period allowed |
69 |
*/ |
70 |
static void |
71 |
expire_pending_glines(struct gline_pending *in) |
72 |
{ |
73 |
dlink_node *node = NULL, *node_next = NULL; |
74 |
|
75 |
for (unsigned int i = 0; i < GLINE_PENDING_ADD_TYPE + 1; ++i) |
76 |
{ |
77 |
DLINK_FOREACH_SAFE(node, node_next, pending_glines[i].head) |
78 |
{ |
79 |
struct gline_pending *glp_ptr = node->data; |
80 |
|
81 |
if ((glp_ptr->last_gline_time + ConfigGeneral.gline_request_time) <= CurrentTime || |
82 |
glp_ptr == in) |
83 |
{ |
84 |
dlinkDelete(&glp_ptr->node, &pending_glines[i]); |
85 |
MyFree(glp_ptr); |
86 |
} |
87 |
} |
88 |
} |
89 |
} |
90 |
|
91 |
/* cleanup_glines() |
92 |
* |
93 |
* inputs - NONE |
94 |
* output - NONE |
95 |
* side effects - expire gline lists |
96 |
* This is an event started off in ircd.c |
97 |
*/ |
98 |
void |
99 |
cleanup_glines(void *unused) |
100 |
{ |
101 |
expire_pending_glines(unused); |
102 |
} |