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