1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* s_gline.c: GLine global ban functions. |
4 |
* |
5 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
* |
22 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "tools.h" |
27 |
#include "handlers.h" |
28 |
#include "client.h" |
29 |
#include "common.h" |
30 |
#include "irc_string.h" |
31 |
#include "ircd.h" |
32 |
#include "hostmask.h" |
33 |
#include "fdlist.h" |
34 |
#include "s_bsd.h" |
35 |
#include "s_conf.h" |
36 |
#include "s_misc.h" |
37 |
#include "send.h" |
38 |
#include "msg.h" |
39 |
#include "fileio.h" |
40 |
#include "s_serv.h" |
41 |
#include "s_gline.h" |
42 |
#include "event.h" |
43 |
#include "list.h" |
44 |
#include "memory.h" |
45 |
|
46 |
dlink_list pending_glines = { NULL, NULL, 0 }; |
47 |
|
48 |
static void expire_pending_glines(void); |
49 |
|
50 |
|
51 |
struct AccessItem * |
52 |
find_is_glined(const char *host, const char *user) |
53 |
{ |
54 |
struct irc_ssaddr iphost, *piphost; |
55 |
struct AccessItem *aconf; |
56 |
int t; |
57 |
|
58 |
if ((t = parse_netmask(host, &iphost, &t)) != HM_HOST) |
59 |
{ |
60 |
#ifdef IPV6 |
61 |
if (t == HM_IPV6) |
62 |
t = AF_INET6; |
63 |
else |
64 |
#endif |
65 |
t = AF_INET; |
66 |
piphost = &iphost; |
67 |
} |
68 |
else |
69 |
{ |
70 |
t = 0; |
71 |
piphost = NULL; |
72 |
} |
73 |
|
74 |
aconf = find_conf_by_address(host, piphost, CONF_GLINE, t, user, NULL); |
75 |
return(aconf); |
76 |
} |
77 |
|
78 |
/* cleanup_glines() |
79 |
* |
80 |
* inputs - NONE |
81 |
* output - NONE |
82 |
* side effects - expire gline lists |
83 |
* This is an event started off in ircd.c |
84 |
*/ |
85 |
void |
86 |
cleanup_glines(void *unused) |
87 |
{ |
88 |
expire_pending_glines(); |
89 |
} |
90 |
|
91 |
/* expire_pending_glines() |
92 |
* |
93 |
* inputs - NONE |
94 |
* output - NONE |
95 |
* side effects - |
96 |
* |
97 |
* Go through the pending gline list, expire any that haven't had |
98 |
* enough "votes" in the time period allowed |
99 |
*/ |
100 |
static void |
101 |
expire_pending_glines(void) |
102 |
{ |
103 |
dlink_node *ptr; |
104 |
dlink_node *next_ptr; |
105 |
struct gline_pending *glp_ptr; |
106 |
|
107 |
DLINK_FOREACH_SAFE(ptr, next_ptr, pending_glines.head) |
108 |
{ |
109 |
glp_ptr = ptr->data; |
110 |
|
111 |
if (((glp_ptr->last_gline_time + GLINE_PENDING_EXPIRE) <= CurrentTime) || |
112 |
find_is_glined(glp_ptr->host, glp_ptr->user)) |
113 |
{ |
114 |
dlinkDelete(&glp_ptr->node, &pending_glines); |
115 |
MyFree(glp_ptr); |
116 |
} |
117 |
} |
118 |
} |