]>
jfr.im git - solanum.git/blob - src/s_gline.c
2 * ircd-ratbox: A slightly useful ircd.
3 * s_gline.c: GLine global ban functions.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: s_gline.c 254 2005-09-21 23:35:12Z nenolod $
32 #include "irc_string.h"
46 static void expire_glines(void);
47 static void expire_pending_glines(void);
51 * inputs - pointer to struct ConfItem
53 * Side effects - links in given struct ConfItem into gline link list
56 add_gline(struct ConfItem
*aconf
)
58 rb_dlinkAddTailAlloc(aconf
, &glines
);
59 add_conf_by_address(aconf
->host
, CONF_GLINE
, aconf
->user
, aconf
);
66 * output - pointer to struct ConfItem if user@host glined
70 find_is_glined(const char *host
, const char *user
)
72 rb_dlink_node
*gline_node
;
73 struct ConfItem
*kill_ptr
;
75 RB_DLINK_FOREACH(gline_node
, glines
.head
)
77 kill_ptr
= gline_node
->data
;
78 if((kill_ptr
->user
&& (!user
|| match(kill_ptr
->user
, user
)))
79 && (kill_ptr
->host
&& (!host
|| match(kill_ptr
->host
, host
))))
93 * side effects - expire gline lists
94 * This is an event started off in ircd.c
97 cleanup_glines(void *unused
)
100 expire_pending_glines();
110 * Go through the gline list, expire any needed.
115 rb_dlink_node
*gline_node
;
116 rb_dlink_node
*next_node
;
117 struct ConfItem
*kill_ptr
;
119 RB_DLINK_FOREACH_SAFE(gline_node
, next_node
, glines
.head
)
121 kill_ptr
= gline_node
->data
;
123 /* these are in chronological order */
124 if(kill_ptr
->hold
> rb_current_time())
127 rb_dlinkDestroy(gline_node
, &glines
);
128 delete_one_address_conf(kill_ptr
->host
, kill_ptr
);
133 * expire_pending_glines
139 * Go through the pending gline list, expire any that haven't had
140 * enough "votes" in the time period allowed
143 expire_pending_glines()
145 rb_dlink_node
*pending_node
;
146 rb_dlink_node
*next_node
;
147 struct gline_pending
*glp_ptr
;
149 RB_DLINK_FOREACH_SAFE(pending_node
, next_node
, pending_glines
.head
)
151 glp_ptr
= pending_node
->data
;
153 if(((glp_ptr
->last_gline_time
+ GLINE_PENDING_EXPIRE
) <=
154 rb_current_time()) || find_is_glined(glp_ptr
->host
, glp_ptr
->user
))
157 rb_free(glp_ptr
->reason1
);
158 rb_free(glp_ptr
->reason2
);
160 rb_dlinkDestroy(pending_node
, &pending_glines
);