]>
jfr.im git - irc/rqf/shadowircd.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 $
33 #include "irc_string.h"
50 static void expire_glines(void);
51 static void expire_pending_glines(void);
55 * inputs - pointer to struct ConfItem
57 * Side effects - links in given struct ConfItem into gline link list
60 add_gline(struct ConfItem
*aconf
)
62 dlinkAddTailAlloc(aconf
, &glines
);
63 add_conf_by_address(aconf
->host
, CONF_GLINE
, aconf
->user
, aconf
);
70 * output - pointer to struct ConfItem if user@host glined
74 find_is_glined(const char *host
, const char *user
)
76 dlink_node
*gline_node
;
77 struct ConfItem
*kill_ptr
;
79 DLINK_FOREACH(gline_node
, glines
.head
)
81 kill_ptr
= gline_node
->data
;
82 if((kill_ptr
->user
&& (!user
|| match(kill_ptr
->user
, user
)))
83 && (kill_ptr
->host
&& (!host
|| match(kill_ptr
->host
, host
))))
97 * side effects - expire gline lists
98 * This is an event started off in ircd.c
101 cleanup_glines(void *unused
)
104 expire_pending_glines();
114 * Go through the gline list, expire any needed.
119 dlink_node
*gline_node
;
120 dlink_node
*next_node
;
121 struct ConfItem
*kill_ptr
;
123 DLINK_FOREACH_SAFE(gline_node
, next_node
, glines
.head
)
125 kill_ptr
= gline_node
->data
;
127 /* these are in chronological order */
128 if(kill_ptr
->hold
> CurrentTime
)
131 dlinkDestroy(gline_node
, &glines
);
132 delete_one_address_conf(kill_ptr
->host
, kill_ptr
);
137 * expire_pending_glines
143 * Go through the pending gline list, expire any that haven't had
144 * enough "votes" in the time period allowed
147 expire_pending_glines()
149 dlink_node
*pending_node
;
150 dlink_node
*next_node
;
151 struct gline_pending
*glp_ptr
;
153 DLINK_FOREACH_SAFE(pending_node
, next_node
, pending_glines
.head
)
155 glp_ptr
= pending_node
->data
;
157 if(((glp_ptr
->last_gline_time
+ GLINE_PENDING_EXPIRE
) <=
158 CurrentTime
) || find_is_glined(glp_ptr
->host
, glp_ptr
->user
))
161 MyFree(glp_ptr
->reason1
);
162 MyFree(glp_ptr
->reason2
);
164 dlinkDestroy(pending_node
, &pending_glines
);