ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/s_gline.c
Revision: 1644
Committed: Tue Nov 6 22:20:16 2012 UTC (12 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 2877 byte(s)
Log Message:
- More config subsystem cleanups

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "client.h"
28     #include "irc_string.h"
29     #include "ircd.h"
30 michael 1632 #include "conf.h"
31 adx 30 #include "hostmask.h"
32     #include "s_misc.h"
33     #include "send.h"
34     #include "s_serv.h"
35     #include "s_gline.h"
36     #include "event.h"
37     #include "memory.h"
38    
39 michael 957 dlink_list pending_glines[GLINE_PENDING_ADD_TYPE + 1] = { { NULL, NULL, 0 },
40     { NULL, NULL, 0 } };
41 adx 30
42 michael 957 static void expire_pending_glines(struct gline_pending *);
43 adx 30
44    
45 michael 1632 struct MaskItem *
46 adx 30 find_is_glined(const char *host, const char *user)
47     {
48 michael 1644 struct irc_ssaddr iphost, *piphost = NULL;
49 michael 1632 struct MaskItem *conf = NULL;
50 michael 1644 int t = 0;
51     int aftype = 0;
52 adx 30
53 michael 1644 if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
54 adx 30 {
55     #ifdef IPV6
56     if (t == HM_IPV6)
57 michael 1644 aftype = AF_INET6;
58 adx 30 else
59     #endif
60 michael 1644 aftype = AF_INET;
61 adx 30 piphost = &iphost;
62     }
63     else
64     piphost = NULL;
65    
66 michael 1644 conf = find_conf_by_address(host, piphost, CONF_GLINE, aftype, user, NULL, 0);
67 michael 1632 return conf;
68 adx 30 }
69    
70     /* cleanup_glines()
71     *
72     * inputs - NONE
73     * output - NONE
74     * side effects - expire gline lists
75     * This is an event started off in ircd.c
76     */
77     void
78     cleanup_glines(void *unused)
79     {
80 michael 957 expire_pending_glines(unused);
81 adx 30 }
82    
83     /* expire_pending_glines()
84     *
85     * inputs - NONE
86     * output - NONE
87     * side effects -
88     *
89     * Go through the pending gline list, expire any that haven't had
90     * enough "votes" in the time period allowed
91     */
92     static void
93 michael 957 expire_pending_glines(struct gline_pending *in)
94 adx 30 {
95 michael 957 dlink_node *ptr = NULL, *next_ptr = NULL;
96 michael 1376 unsigned int idx = 0;
97 adx 30
98 michael 957 for (; idx < GLINE_PENDING_ADD_TYPE + 1; ++idx)
99 adx 30 {
100 michael 957 DLINK_FOREACH_SAFE(ptr, next_ptr, pending_glines[idx].head)
101     {
102     struct gline_pending *glp_ptr = ptr->data;
103 adx 30
104 michael 1459 if ((glp_ptr->last_gline_time + ConfigFileEntry.gline_request_time) <= CurrentTime ||
105 michael 957 glp_ptr == in)
106     {
107     dlinkDelete(&glp_ptr->node, &pending_glines[idx]);
108     MyFree(glp_ptr);
109     }
110 adx 30 }
111     }
112     }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision