26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
|
#include "list.h" |
29 |
< |
#include "ircd_defs.h" |
30 |
< |
#include "balloc.h" |
29 |
> |
#include "ircd.h" |
30 |
|
#include "conf.h" |
32 |
– |
#include "s_serv.h" |
33 |
– |
#include "resv.h" |
34 |
– |
#include "channel.h" |
31 |
|
#include "client.h" |
36 |
– |
#include "event.h" |
37 |
– |
#include "hook.h" |
38 |
– |
#include "irc_string.h" |
39 |
– |
#include "s_bsd.h" |
40 |
– |
#include "ircd.h" |
41 |
– |
#include "listener.h" |
32 |
|
#include "hostmask.h" |
33 |
< |
#include "modules.h" |
44 |
< |
#include "numeric.h" |
45 |
< |
#include "fdlist.h" |
46 |
< |
#include "log.h" |
47 |
< |
#include "send.h" |
48 |
< |
#include "s_gline.h" |
33 |
> |
#include "irc_string.h" |
34 |
|
#include "memory.h" |
50 |
– |
#include "irc_res.h" |
51 |
– |
#include "userhost.h" |
52 |
– |
#include "s_user.h" |
53 |
– |
#include "channel_mode.h" |
54 |
– |
#include "parse.h" |
55 |
– |
#include "s_misc.h" |
56 |
– |
#include "conf_db.h" |
35 |
|
|
36 |
|
|
37 |
|
struct ClassItem *class_default; |
50 |
|
{ |
51 |
|
struct ClassItem *class = MyMalloc(sizeof(*class)); |
52 |
|
|
53 |
+ |
class->active = 1; |
54 |
+ |
class->con_freq = DEFAULT_CONNECTFREQUENCY; |
55 |
+ |
class->ping_freq = DEFAULT_PINGFREQUENCY; |
56 |
+ |
class->max_total = MAXIMUM_LINKS_DEFAULT; |
57 |
+ |
class->max_sendq = DEFAULT_SENDQ; |
58 |
+ |
class->max_recvq = DEFAULT_RECVQ; |
59 |
+ |
|
60 |
|
dlinkAdd(class, &class->node, &class_list); |
61 |
|
|
62 |
|
return class; |
77 |
|
void |
78 |
|
class_init(void) |
79 |
|
{ |
80 |
< |
class_default = class_make(); |
96 |
< |
|
97 |
< |
DupString(class_default->name, "default"); |
98 |
< |
|
99 |
< |
class_default->active = 1; |
100 |
< |
class_default->con_freq = DEFAULT_CONNECTFREQUENCY; |
101 |
< |
class_default->ping_freq = DEFAULT_PINGFREQUENCY; |
102 |
< |
class_default->max_total = MAXIMUM_LINKS_DEFAULT; |
103 |
< |
class_default->max_sendq = DEFAULT_SENDQ; |
104 |
< |
class_default->max_recvq = DEFAULT_RECVQ; |
105 |
< |
|
106 |
< |
client_check_cb = register_callback("check_client", check_client); |
80 |
> |
(class_default = class_make())->name = xstrdup("default"); |
81 |
|
} |
82 |
|
|
83 |
|
const char * |
89 |
|
const struct MaskItem *conf = ptr->data; |
90 |
|
|
91 |
|
assert(conf->class); |
92 |
< |
assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER)); |
92 |
> |
assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER)); |
93 |
|
|
94 |
|
return conf->class->name; |
95 |
|
} |
98 |
|
} |
99 |
|
|
100 |
|
unsigned int |
101 |
< |
get_client_ping(const dlink_list *const list, int *pingwarn) |
101 |
> |
get_client_ping(const dlink_list *const list) |
102 |
|
{ |
103 |
|
const dlink_node *ptr = NULL; |
130 |
– |
int ping = 0; |
104 |
|
|
105 |
|
if ((ptr = list->head)) { |
106 |
|
const struct MaskItem *conf = ptr->data; |
107 |
|
|
108 |
< |
assert(aconf->class); |
109 |
< |
assert(aconf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER)); |
108 |
> |
assert(conf->class); |
109 |
> |
assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER)); |
110 |
|
|
111 |
< |
ping = get_conf_ping(conf, pingwarn); |
139 |
< |
if (ping > 0) |
140 |
< |
return ping; |
111 |
> |
return conf->class->ping_freq; |
112 |
|
} |
113 |
|
|
114 |
|
return class_default->ping_freq; |
123 |
|
const struct MaskItem *conf = ptr->data; |
124 |
|
|
125 |
|
assert(conf->class); |
126 |
< |
assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER)); |
126 |
> |
assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER)); |
127 |
|
|
128 |
|
return conf->class->max_sendq; |
129 |
|
} |
140 |
|
const struct MaskItem *conf = ptr->data; |
141 |
|
|
142 |
|
assert(conf->class); |
143 |
< |
assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER)); |
143 |
> |
assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER)); |
144 |
|
|
145 |
|
return conf->class->max_recvq; |
146 |
|
} |
177 |
|
{ |
178 |
|
dlink_node *ptr = NULL; |
179 |
|
|
180 |
< |
DLINK_FOREACH(ptr, class_list.head) |
181 |
< |
{ |
211 |
< |
struct ClassItem *class = ptr->data; |
212 |
< |
|
213 |
< |
if (class != class_default) |
214 |
< |
class->active = 0; |
215 |
< |
} |
180 |
> |
DLINK_FOREACH_PREV(ptr, class_list.tail->prev) |
181 |
> |
((struct ClassItem *)ptr->data)->active = 0; |
182 |
|
} |
183 |
|
|
184 |
|
void |
214 |
|
dlink_node *ptr = NULL; |
215 |
|
struct CidrItem *cidr = NULL; |
216 |
|
|
217 |
< |
if (class->number_per_cidr <= 0) |
217 |
> |
if (class->number_per_cidr == 0) |
218 |
|
return 0; |
219 |
|
|
220 |
|
if (ip->ss.ss_family == AF_INET) |
221 |
|
{ |
222 |
< |
if (class->cidr_bitlen_ipv4 <= 0) |
222 |
> |
if (class->cidr_bitlen_ipv4 == 0) |
223 |
|
return 0; |
224 |
|
|
225 |
|
DLINK_FOREACH(ptr, class->list_ipv4.head) |
283 |
|
|
284 |
|
if (ip->ss.ss_family == AF_INET) |
285 |
|
{ |
286 |
< |
if (aclass->cidr_bitlen_ipv4 <= 0) |
286 |
> |
if (aclass->cidr_bitlen_ipv4 == 0) |
287 |
|
return; |
288 |
|
|
289 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
322 |
|
#endif |
323 |
|
} |
324 |
|
|
325 |
< |
static void |
326 |
< |
rebuild_cidr_list(int aftype, struct ClassItem *oldcl, struct ClassItem *newcl, |
361 |
< |
dlink_list *old_list, dlink_list *new_list, int changed) |
325 |
> |
void |
326 |
> |
rebuild_cidr_list(struct ClassItem *class) |
327 |
|
{ |
328 |
|
dlink_node *ptr; |
364 |
– |
struct Client *client_p; |
365 |
– |
struct MaskItem *conf; |
329 |
|
|
330 |
< |
if (!changed) |
368 |
< |
{ |
369 |
< |
*new_list = *old_list; |
370 |
< |
old_list->head = old_list->tail = NULL; |
371 |
< |
old_list->length = 0; |
372 |
< |
return; |
373 |
< |
} |
330 |
> |
destroy_cidr_class(class); |
331 |
|
|
332 |
|
DLINK_FOREACH(ptr, local_client_list.head) |
333 |
|
{ |
334 |
< |
client_p = ptr->data; |
335 |
< |
if (client_p->localClient->aftype != aftype) |
379 |
< |
continue; |
380 |
< |
if (dlink_list_length(&client_p->localClient->confs) == 0) |
381 |
< |
continue; |
382 |
< |
|
383 |
< |
conf = client_p->localClient->confs.tail->data; |
384 |
< |
if (conf->type == CONF_CLIENT) |
385 |
< |
if (conf->class == oldcl) |
386 |
< |
cidr_limit_reached(1, &client_p->localClient->ip, newcl); |
387 |
< |
} |
388 |
< |
} |
389 |
< |
|
390 |
< |
/* |
391 |
< |
* rebuild_cidr_class |
392 |
< |
* |
393 |
< |
* inputs - pointer to old conf |
394 |
< |
* - pointer to new_class |
395 |
< |
* output - none |
396 |
< |
* side effects - rebuilds the class link list of cidr blocks |
397 |
< |
*/ |
398 |
< |
void |
399 |
< |
rebuild_cidr_class(struct ClassItem *old_class, struct ClassItem *new_class) |
400 |
< |
{ |
401 |
< |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
402 |
< |
{ |
403 |
< |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
404 |
< |
rebuild_cidr_list(AF_INET, old_class, new_class, |
405 |
< |
&old_class->list_ipv4, &new_class->list_ipv4, |
406 |
< |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
334 |
> |
struct Client *client_p = ptr->data; |
335 |
> |
struct MaskItem *conf = client_p->localClient->confs.tail->data; |
336 |
|
|
337 |
< |
#ifdef IPV6 |
338 |
< |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
339 |
< |
rebuild_cidr_list(AF_INET6, old_class, new_class, |
411 |
< |
&old_class->list_ipv6, &new_class->list_ipv6, |
412 |
< |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
413 |
< |
#endif |
337 |
> |
if (conf && (conf->type == CONF_CLIENT)) |
338 |
> |
if (conf->class == class) |
339 |
> |
cidr_limit_reached(1, &client_p->localClient->ip, class); |
340 |
|
} |
415 |
– |
|
416 |
– |
destroy_cidr_class(old_class); |
341 |
|
} |
342 |
|
|
343 |
|
/* |