32 |
|
#include "channel.h" |
33 |
|
#include "client.h" |
34 |
|
#include "event.h" |
35 |
– |
#include "hash.h" |
35 |
|
#include "hook.h" |
36 |
|
#include "irc_string.h" |
38 |
– |
#include "sprintf_irc.h" |
37 |
|
#include "s_bsd.h" |
38 |
|
#include "ircd.h" |
39 |
|
#include "listener.h" |
59 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
60 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
61 |
|
dlink_list cluster_items = { NULL, NULL, 0 }; |
64 |
– |
dlink_list hub_items = { NULL, NULL, 0 }; |
65 |
– |
dlink_list leaf_items = { NULL, NULL, 0 }; |
62 |
|
dlink_list oconf_items = { NULL, NULL, 0 }; |
63 |
|
dlink_list uconf_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list xconf_items = { NULL, NULL, 0 }; |
66 |
|
dlink_list rkconf_items = { NULL, NULL, 0 }; |
67 |
|
dlink_list nresv_items = { NULL, NULL, 0 }; |
68 |
|
dlink_list class_items = { NULL, NULL, 0 }; |
73 |
– |
dlink_list gdeny_items = { NULL, NULL, 0 }; |
69 |
|
|
75 |
– |
dlink_list temporary_klines = { NULL, NULL, 0 }; |
76 |
– |
dlink_list temporary_dlines = { NULL, NULL, 0 }; |
70 |
|
dlink_list temporary_xlines = { NULL, NULL, 0 }; |
78 |
– |
dlink_list temporary_rklines = { NULL, NULL, 0 }; |
79 |
– |
dlink_list temporary_glines = { NULL, NULL, 0 }; |
80 |
– |
dlink_list temporary_rxlines = { NULL, NULL, 0 }; |
71 |
|
dlink_list temporary_resv = { NULL, NULL, 0 }; |
72 |
|
|
73 |
|
extern unsigned int lineno; |
74 |
|
extern char linebuf[]; |
75 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
86 |
– |
extern char yytext[]; |
76 |
|
extern int yyparse(); /* defined in y.tab.c */ |
77 |
|
|
78 |
|
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
79 |
|
|
80 |
|
/* internally defined functions */ |
92 |
– |
static void lookup_confhost(struct ConfItem *); |
93 |
– |
static void set_default_conf(void); |
94 |
– |
static void validate_conf(void); |
81 |
|
static void read_conf(FILE *); |
82 |
|
static void clear_out_old_conf(void); |
83 |
|
static void flush_deleted_I_P(void); |
160 |
|
aconf->dns_pending = 0; |
161 |
|
|
162 |
|
if (addr != NULL) |
163 |
< |
memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum)); |
163 |
> |
memcpy(&aconf->addr, addr, sizeof(aconf->addr)); |
164 |
|
else |
165 |
|
aconf->dns_failed = 1; |
166 |
|
} |
248 |
|
aconf->status = status; |
249 |
|
break; |
250 |
|
|
265 |
– |
case LEAF_TYPE: |
266 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
267 |
– |
sizeof(struct MatchItem)); |
268 |
– |
dlinkAdd(conf, &conf->node, &leaf_items); |
269 |
– |
break; |
270 |
– |
|
271 |
– |
case HUB_TYPE: |
272 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
273 |
– |
sizeof(struct MatchItem)); |
274 |
– |
dlinkAdd(conf, &conf->node, &hub_items); |
275 |
– |
break; |
276 |
– |
|
251 |
|
case ULINE_TYPE: |
252 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
253 |
|
sizeof(struct MatchItem)); |
254 |
|
dlinkAdd(conf, &conf->node, &uconf_items); |
255 |
|
break; |
256 |
|
|
283 |
– |
case GDENY_TYPE: |
284 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
285 |
– |
sizeof(struct AccessItem)); |
286 |
– |
dlinkAdd(conf, &conf->node, &gdeny_items); |
287 |
– |
break; |
288 |
– |
|
257 |
|
case XLINE_TYPE: |
258 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
259 |
|
sizeof(struct MatchItem)); |
303 |
|
|
304 |
|
aclass = map_to_conf(conf); |
305 |
|
aclass->active = 1; |
306 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
307 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
308 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
309 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
306 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
307 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
308 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
309 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
310 |
> |
aclass->max_recvq = DEFAULT_RECVQ; |
311 |
|
|
312 |
|
break; |
313 |
|
|
325 |
|
void |
326 |
|
delete_conf_item(struct ConfItem *conf) |
327 |
|
{ |
328 |
< |
dlink_node *m = NULL; |
328 |
> |
dlink_node *m = NULL, *m_next = NULL; |
329 |
|
struct MatchItem *match_item; |
330 |
|
struct AccessItem *aconf; |
331 |
|
ConfType type = conf->type; |
358 |
|
MyFree(aconf->oper_reason); |
359 |
|
MyFree(aconf->user); |
360 |
|
MyFree(aconf->host); |
392 |
– |
MyFree(aconf->cipher_list); |
361 |
|
#ifdef HAVE_LIBCRYPTO |
362 |
+ |
MyFree(aconf->cipher_list); |
363 |
+ |
|
364 |
|
if (aconf->rsa_public_key) |
365 |
|
RSA_free(aconf->rsa_public_key); |
366 |
|
MyFree(aconf->rsa_public_key_file); |
386 |
|
|
387 |
|
case SERVER_TYPE: |
388 |
|
aconf = map_to_conf(conf); |
389 |
+ |
|
390 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head) |
391 |
+ |
{ |
392 |
+ |
MyFree(m->data); |
393 |
+ |
free_dlink_node(m); |
394 |
+ |
} |
395 |
+ |
|
396 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head) |
397 |
+ |
{ |
398 |
+ |
MyFree(m->data); |
399 |
+ |
free_dlink_node(m); |
400 |
+ |
} |
401 |
+ |
|
402 |
|
if (!IsConfIllegal(aconf)) |
403 |
|
dlinkDelete(&conf->node, &server_items); |
404 |
|
MyFree(conf); |
409 |
|
} |
410 |
|
break; |
411 |
|
|
429 |
– |
case HUB_TYPE: |
430 |
– |
match_item = map_to_conf(conf); |
431 |
– |
MyFree(match_item->user); |
432 |
– |
MyFree(match_item->host); |
433 |
– |
MyFree(match_item->reason); |
434 |
– |
MyFree(match_item->oper_reason); |
435 |
– |
/* If marked illegal, its already been pulled off of the hub_items list */ |
436 |
– |
if (!match_item->illegal) |
437 |
– |
dlinkDelete(&conf->node, &hub_items); |
438 |
– |
MyFree(conf); |
439 |
– |
break; |
440 |
– |
|
441 |
– |
case LEAF_TYPE: |
442 |
– |
match_item = map_to_conf(conf); |
443 |
– |
MyFree(match_item->user); |
444 |
– |
MyFree(match_item->host); |
445 |
– |
MyFree(match_item->reason); |
446 |
– |
MyFree(match_item->oper_reason); |
447 |
– |
/* If marked illegal, its already been pulled off of the leaf_items list */ |
448 |
– |
if (!match_item->illegal) |
449 |
– |
dlinkDelete(&conf->node, &leaf_items); |
450 |
– |
MyFree(conf); |
451 |
– |
break; |
452 |
– |
|
412 |
|
case ULINE_TYPE: |
413 |
|
match_item = map_to_conf(conf); |
414 |
|
MyFree(match_item->user); |
467 |
|
MyFree(conf); |
468 |
|
break; |
469 |
|
|
511 |
– |
case GDENY_TYPE: |
512 |
– |
aconf = map_to_conf(conf); |
513 |
– |
MyFree(aconf->user); |
514 |
– |
MyFree(aconf->host); |
515 |
– |
dlinkDelete(&conf->node, &gdeny_items); |
516 |
– |
MyFree(conf); |
517 |
– |
break; |
518 |
– |
|
470 |
|
case CLUSTER_TYPE: |
471 |
|
dlinkDelete(&conf->node, &cluster_items); |
472 |
|
MyFree(conf); |
523 |
|
* side effects - |
524 |
|
*/ |
525 |
|
void |
526 |
< |
report_confitem_types(struct Client *source_p, ConfType type, int temp) |
526 |
> |
report_confitem_types(struct Client *source_p, ConfType type) |
527 |
|
{ |
528 |
< |
dlink_node *ptr = NULL; |
528 |
> |
dlink_node *ptr = NULL, *dptr = NULL; |
529 |
|
struct ConfItem *conf = NULL; |
530 |
|
struct AccessItem *aconf = NULL; |
531 |
|
struct MatchItem *matchitem = NULL; |
532 |
|
struct ClassItem *classitem = NULL; |
533 |
|
char buf[12]; |
534 |
|
char *p = NULL; |
584 |
– |
const char *pfx = NULL; |
535 |
|
|
536 |
|
switch (type) |
537 |
|
{ |
588 |
– |
case GDENY_TYPE: |
589 |
– |
DLINK_FOREACH(ptr, gdeny_items.head) |
590 |
– |
{ |
591 |
– |
conf = ptr->data; |
592 |
– |
aconf = map_to_conf(conf); |
593 |
– |
|
594 |
– |
p = buf; |
595 |
– |
|
596 |
– |
if (aconf->flags & GDENY_BLOCK) |
597 |
– |
*p++ = 'B'; |
598 |
– |
else |
599 |
– |
*p++ = 'b'; |
600 |
– |
|
601 |
– |
if (aconf->flags & GDENY_REJECT) |
602 |
– |
*p++ = 'R'; |
603 |
– |
else |
604 |
– |
*p++ = 'r'; |
605 |
– |
|
606 |
– |
*p = '\0'; |
607 |
– |
|
608 |
– |
sendto_one(source_p, ":%s %d %s V %s@%s %s %s", |
609 |
– |
me.name, RPL_STATSDEBUG, source_p->name, |
610 |
– |
aconf->user, aconf->host, conf->name, buf); |
611 |
– |
} |
612 |
– |
break; |
613 |
– |
|
538 |
|
case XLINE_TYPE: |
539 |
|
DLINK_FOREACH(ptr, xconf_items.head) |
540 |
|
{ |
557 |
|
|
558 |
|
sendto_one(source_p, form_str(RPL_STATSXLINE), |
559 |
|
me.name, source_p->name, |
560 |
< |
matchitem->hold ? "xR": "XR", matchitem->count, |
560 |
> |
"XR", matchitem->count, |
561 |
|
conf->name, matchitem->reason); |
562 |
|
} |
563 |
|
break; |
564 |
|
|
565 |
|
case RKLINE_TYPE: |
642 |
– |
pfx = temp ? "kR" : "KR"; |
643 |
– |
|
566 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
567 |
|
{ |
568 |
|
aconf = map_to_conf((conf = ptr->data)); |
569 |
|
|
648 |
– |
if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY)) |
649 |
– |
continue; |
650 |
– |
|
570 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
571 |
< |
source_p->name, pfx, aconf->host, aconf->user, |
571 |
> |
source_p->name, "KR", aconf->host, aconf->user, |
572 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
573 |
|
} |
574 |
|
break; |
637 |
|
classitem = map_to_conf(conf); |
638 |
|
sendto_one(source_p, form_str(RPL_STATSYLINE), |
639 |
|
me.name, source_p->name, 'Y', |
640 |
< |
conf->name, PingFreq(classitem), |
641 |
< |
ConFreq(classitem), |
642 |
< |
MaxTotal(classitem), MaxSendq(classitem), |
643 |
< |
CurrUserCount(classitem), |
640 |
> |
conf->name, classitem->ping_freq, |
641 |
> |
classitem->con_freq, |
642 |
> |
classitem->max_total, classitem->max_sendq, |
643 |
> |
classitem->max_recvq, |
644 |
> |
classitem->curr_user_count, |
645 |
> |
classitem->number_per_cidr, classitem->cidr_bitlen_ipv4, |
646 |
> |
classitem->number_per_cidr, classitem->cidr_bitlen_ipv6, |
647 |
|
classitem->active ? "active" : "disabled"); |
648 |
|
} |
649 |
|
break; |
675 |
|
*p++ = 'A'; |
676 |
|
if (IsConfSSL(aconf)) |
677 |
|
*p++ = 'S'; |
756 |
– |
if (IsConfTopicBurst(aconf)) |
757 |
– |
*p++ = 'T'; |
678 |
|
if (buf[0] == '\0') |
679 |
|
*p++ = '*'; |
680 |
|
|
697 |
|
break; |
698 |
|
|
699 |
|
case HUB_TYPE: |
700 |
< |
DLINK_FOREACH(ptr, hub_items.head) |
700 |
> |
DLINK_FOREACH(ptr, server_items.head) |
701 |
|
{ |
702 |
|
conf = ptr->data; |
703 |
< |
matchitem = map_to_conf(conf); |
704 |
< |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
705 |
< |
source_p->name, 'H', matchitem->host, conf->name, 0, "*"); |
703 |
> |
aconf = map_to_conf(conf); |
704 |
> |
|
705 |
> |
DLINK_FOREACH(dptr, aconf->hub_list.head) |
706 |
> |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
707 |
> |
source_p->name, 'H', dptr->data, conf->name, 0, "*"); |
708 |
|
} |
709 |
|
break; |
710 |
|
|
711 |
|
case LEAF_TYPE: |
712 |
< |
DLINK_FOREACH(ptr, leaf_items.head) |
712 |
> |
DLINK_FOREACH(ptr, server_items.head) |
713 |
|
{ |
714 |
|
conf = ptr->data; |
715 |
< |
matchitem = map_to_conf(conf); |
716 |
< |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
717 |
< |
source_p->name, 'L', matchitem->host, conf->name, 0, "*"); |
715 |
> |
aconf = map_to_conf(conf); |
716 |
> |
|
717 |
> |
DLINK_FOREACH(dptr, aconf->leaf_list.head) |
718 |
> |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
719 |
> |
source_p->name, 'L', dptr->data, conf->name, 0, "*"); |
720 |
|
} |
721 |
|
break; |
722 |
|
|
955 |
|
* setting a_limit_reached if any limit is reached. |
956 |
|
* - Dianora |
957 |
|
*/ |
958 |
< |
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
958 |
> |
if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total) |
959 |
|
a_limit_reached = 1; |
960 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
960 |
> |
else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip) |
961 |
|
a_limit_reached = 1; |
962 |
< |
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
962 |
> |
else if (aclass->max_local != 0 && local >= aclass->max_local) |
963 |
|
a_limit_reached = 1; |
964 |
< |
else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass)) |
964 |
> |
else if (aclass->max_global != 0 && global >= aclass->max_global) |
965 |
|
a_limit_reached = 1; |
966 |
< |
else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) && |
966 |
> |
else if (aclass->max_ident != 0 && ident >= aclass->max_ident && |
967 |
|
client_p->username[0] != '~') |
968 |
|
a_limit_reached = 1; |
969 |
|
|
1246 |
|
|
1247 |
|
assert(aconf->clients > 0); |
1248 |
|
|
1249 |
< |
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1249 |
> |
if ((aclass_conf = aconf->class_ptr) != NULL) |
1250 |
|
{ |
1251 |
|
aclass = map_to_conf(aclass_conf); |
1252 |
|
|
1262 |
|
delete_conf_item(conf); |
1263 |
|
|
1264 |
|
break; |
1341 |
– |
|
1342 |
– |
case LEAF_TYPE: |
1343 |
– |
case HUB_TYPE: |
1344 |
– |
match_item = map_to_conf(conf); |
1345 |
– |
if (match_item->ref_count == 0 && match_item->illegal) |
1346 |
– |
delete_conf_item(conf); |
1347 |
– |
break; |
1265 |
|
default: |
1266 |
|
break; |
1267 |
|
} |
1287 |
|
int |
1288 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1289 |
|
{ |
1290 |
+ |
struct AccessItem *aconf = map_to_conf(conf); |
1291 |
+ |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1292 |
+ |
|
1293 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1294 |
|
return 1; |
1295 |
|
|
1296 |
< |
if (conf->type == CLIENT_TYPE || |
1297 |
< |
conf->type == SERVER_TYPE || |
1378 |
< |
conf->type == OPER_TYPE) |
1379 |
< |
{ |
1380 |
< |
struct AccessItem *aconf = map_to_conf(conf); |
1381 |
< |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1382 |
< |
|
1383 |
< |
if (IsConfIllegal(aconf)) |
1384 |
< |
return NOT_AUTHORIZED; |
1296 |
> |
if (IsConfIllegal(aconf)) /* TBV: can't happen */ |
1297 |
> |
return NOT_AUTHORIZED; |
1298 |
|
|
1299 |
< |
if (conf->type == CLIENT_TYPE) |
1300 |
< |
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1301 |
< |
&client_p->localClient->ip, aclass)) |
1302 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1299 |
> |
if (conf->type == CLIENT_TYPE) |
1300 |
> |
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1301 |
> |
&client_p->localClient->ip, aclass)) |
1302 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1303 |
|
|
1304 |
< |
CurrUserCount(aclass)++; |
1305 |
< |
aconf->clients++; |
1393 |
< |
} |
1394 |
< |
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1395 |
< |
{ |
1396 |
< |
struct MatchItem *match_item = map_to_conf(conf); |
1397 |
< |
match_item->ref_count++; |
1398 |
< |
} |
1304 |
> |
aclass->curr_user_count++; |
1305 |
> |
aconf->clients++; |
1306 |
|
|
1307 |
|
dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs); |
1308 |
|
|
1391 |
|
{ |
1392 |
|
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1393 |
|
|
1394 |
< |
if (aconf->clients >= MaxTotal(aclass)) |
1394 |
> |
if (aconf->clients >= aclass->max_total) |
1395 |
|
continue; |
1396 |
|
} |
1397 |
|
|
1640 |
|
break; |
1641 |
|
case HM_IPV4: |
1642 |
|
if (who->localClient->aftype == AF_INET) |
1643 |
< |
if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
1643 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits)) |
1644 |
|
return conf; |
1645 |
|
break; |
1646 |
|
#ifdef IPV6 |
1647 |
|
case HM_IPV6: |
1648 |
|
if (who->localClient->aftype == AF_INET6) |
1649 |
< |
if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
1649 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits)) |
1650 |
|
return conf; |
1651 |
|
break; |
1652 |
|
#endif |
1784 |
|
|
1785 |
|
ConfigChannel.disable_fake_channels = 0; |
1786 |
|
ConfigChannel.restrict_channels = 0; |
1880 |
– |
ConfigChannel.disable_local_channels = 0; |
1881 |
– |
ConfigChannel.use_invex = 1; |
1882 |
– |
ConfigChannel.use_except = 1; |
1883 |
– |
ConfigChannel.use_knock = 1; |
1787 |
|
ConfigChannel.knock_delay = 300; |
1788 |
|
ConfigChannel.knock_delay_channel = 60; |
1789 |
< |
ConfigChannel.max_chans_per_user = 15; |
1789 |
> |
ConfigChannel.max_chans_per_user = 25; |
1790 |
> |
ConfigChannel.max_chans_per_oper = 50; |
1791 |
|
ConfigChannel.quiet_on_ban = 1; |
1792 |
|
ConfigChannel.max_bans = 25; |
1793 |
|
ConfigChannel.default_split_user_count = 0; |
1794 |
|
ConfigChannel.default_split_server_count = 0; |
1795 |
|
ConfigChannel.no_join_on_split = 0; |
1796 |
|
ConfigChannel.no_create_on_split = 0; |
1893 |
– |
ConfigChannel.burst_topicwho = 1; |
1797 |
|
|
1798 |
|
ConfigServerHide.flatten_links = 0; |
1799 |
|
ConfigServerHide.links_delay = 300; |
1800 |
|
ConfigServerHide.hidden = 0; |
1898 |
– |
ConfigServerHide.disable_hidden = 0; |
1801 |
|
ConfigServerHide.hide_servers = 0; |
1802 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
1803 |
|
ConfigServerHide.hide_server_ips = 0; |
1805 |
|
|
1806 |
|
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1807 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1808 |
+ |
ConfigFileEntry.glines = 0; |
1809 |
+ |
ConfigFileEntry.gline_time = 12 * 3600; |
1810 |
+ |
ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
1811 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1812 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1813 |
|
ConfigFileEntry.invisible_on_connect = 1; |
1909 |
– |
ConfigFileEntry.burst_away = 0; |
1814 |
|
ConfigFileEntry.use_whois_actually = 1; |
1815 |
|
ConfigFileEntry.tkline_expire_notices = 1; |
1816 |
|
ConfigFileEntry.hide_spoof_ips = 1; |
1846 |
|
ConfigFileEntry.no_oper_flood = 0; |
1847 |
|
ConfigFileEntry.true_no_oper_flood = 0; |
1848 |
|
ConfigFileEntry.oper_pass_resv = 1; |
1945 |
– |
ConfigFileEntry.glines = 0; |
1946 |
– |
ConfigFileEntry.gline_time = 12 * 3600; |
1849 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1948 |
– |
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1850 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1851 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1852 |
|
UMODE_OPERWALL | UMODE_WALLOP; |
1855 |
|
ConfigFileEntry.throttle_time = 10; |
1856 |
|
} |
1857 |
|
|
1858 |
+ |
static void |
1859 |
+ |
validate_conf(void) |
1860 |
+ |
{ |
1861 |
+ |
if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN) |
1862 |
+ |
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1863 |
+ |
|
1864 |
+ |
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
1865 |
+ |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1866 |
+ |
|
1867 |
+ |
if (ServerInfo.network_name == NULL) |
1868 |
+ |
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
1869 |
+ |
|
1870 |
+ |
if (ServerInfo.network_desc == NULL) |
1871 |
+ |
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
1872 |
+ |
|
1873 |
+ |
if (ConfigFileEntry.service_name == NULL) |
1874 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1875 |
+ |
|
1876 |
+ |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1877 |
+ |
} |
1878 |
+ |
|
1879 |
|
/* read_conf() |
1880 |
|
* |
1881 |
|
* inputs - file descriptor pointing to config file to use |
1900 |
|
check_class(); /* Make sure classes are valid */ |
1901 |
|
} |
1902 |
|
|
1981 |
– |
static void |
1982 |
– |
validate_conf(void) |
1983 |
– |
{ |
1984 |
– |
if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN) |
1985 |
– |
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1986 |
– |
|
1987 |
– |
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
1988 |
– |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1989 |
– |
|
1990 |
– |
if (ServerInfo.network_name == NULL) |
1991 |
– |
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
1992 |
– |
|
1993 |
– |
if (ServerInfo.network_desc == NULL) |
1994 |
– |
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
1995 |
– |
|
1996 |
– |
if (ConfigFileEntry.service_name == NULL) |
1997 |
– |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1998 |
– |
|
1999 |
– |
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
2000 |
– |
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
2001 |
– |
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
2002 |
– |
|
2003 |
– |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
2004 |
– |
} |
2005 |
– |
|
1903 |
|
/* lookup_confhost() |
1904 |
|
* |
1905 |
|
* start DNS lookups of all hostnames in the conf |
1913 |
|
|
1914 |
|
aconf = map_to_conf(conf); |
1915 |
|
|
1916 |
< |
if (EmptyString(aconf->host) || |
2020 |
< |
EmptyString(aconf->user)) |
1916 |
> |
if (has_wildcards(aconf->host)) |
1917 |
|
{ |
1918 |
|
ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)", |
1919 |
|
aconf->host, conf->name); |
1920 |
|
return; |
1921 |
|
} |
1922 |
|
|
2027 |
– |
if (strchr(aconf->host, '*') || |
2028 |
– |
strchr(aconf->host, '?')) |
2029 |
– |
return; |
2030 |
– |
|
1923 |
|
/* Do name lookup now on hostnames given and store the |
1924 |
|
* ip numbers in conf structure. |
1925 |
|
*/ |
1939 |
|
|
1940 |
|
assert(res != NULL); |
1941 |
|
|
1942 |
< |
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
1943 |
< |
aconf->ipnum.ss_len = res->ai_addrlen; |
1944 |
< |
aconf->ipnum.ss.ss_family = res->ai_family; |
1942 |
> |
memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen); |
1943 |
> |
aconf->addr.ss_len = res->ai_addrlen; |
1944 |
> |
aconf->addr.ss.ss_family = res->ai_family; |
1945 |
|
freeaddrinfo(res); |
1946 |
|
} |
1947 |
|
|
2019 |
|
|
2020 |
|
assert(client_p != NULL); |
2021 |
|
|
2022 |
< |
aconf = find_kline_conf(client_p->host, client_p->username, |
2023 |
< |
&client_p->localClient->ip, |
2024 |
< |
client_p->localClient->aftype); |
2022 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
2023 |
> |
CONF_KLINE, client_p->localClient->aftype, |
2024 |
> |
client_p->username, NULL, 1); |
2025 |
|
if (aconf == NULL) |
2026 |
|
aconf = find_regexp_kline(uhi); |
2027 |
|
|
2028 |
< |
if (aconf && (aconf->status & CONF_KLINE)) |
2137 |
< |
return aconf; |
2138 |
< |
|
2139 |
< |
return NULL; |
2028 |
> |
return aconf; |
2029 |
|
} |
2030 |
|
|
2031 |
|
struct AccessItem * |
2035 |
|
|
2036 |
|
assert(client_p != NULL); |
2037 |
|
|
2038 |
< |
aconf = find_gline_conf(client_p->host, client_p->username, |
2039 |
< |
&client_p->localClient->ip, |
2040 |
< |
client_p->localClient->aftype); |
2041 |
< |
|
2153 |
< |
if (aconf && (aconf->status & CONF_GLINE)) |
2154 |
< |
return aconf; |
2155 |
< |
|
2156 |
< |
return NULL; |
2038 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
2039 |
> |
CONF_GLINE, client_p->localClient->aftype, |
2040 |
> |
client_p->username, NULL, 1); |
2041 |
> |
return aconf; |
2042 |
|
} |
2043 |
|
|
2044 |
|
/* add_temp_line() |
2051 |
|
void |
2052 |
|
add_temp_line(struct ConfItem *conf) |
2053 |
|
{ |
2054 |
< |
struct AccessItem *aconf; |
2170 |
< |
|
2171 |
< |
if (conf->type == DLINE_TYPE) |
2172 |
< |
{ |
2173 |
< |
aconf = map_to_conf(conf); |
2174 |
< |
SetConfTemporary(aconf); |
2175 |
< |
dlinkAdd(conf, &conf->node, &temporary_dlines); |
2176 |
< |
MyFree(aconf->user); |
2177 |
< |
aconf->user = NULL; |
2178 |
< |
add_conf_by_address(CONF_DLINE, aconf); |
2179 |
< |
} |
2180 |
< |
else if (conf->type == KLINE_TYPE) |
2181 |
< |
{ |
2182 |
< |
aconf = map_to_conf(conf); |
2183 |
< |
SetConfTemporary(aconf); |
2184 |
< |
dlinkAdd(conf, &conf->node, &temporary_klines); |
2185 |
< |
add_conf_by_address(CONF_KILL, aconf); |
2186 |
< |
} |
2187 |
< |
else if (conf->type == GLINE_TYPE) |
2188 |
< |
{ |
2189 |
< |
aconf = map_to_conf(conf); |
2190 |
< |
SetConfTemporary(aconf); |
2191 |
< |
dlinkAdd(conf, &conf->node, &temporary_glines); |
2192 |
< |
add_conf_by_address(CONF_GLINE, aconf); |
2193 |
< |
} |
2194 |
< |
else if (conf->type == XLINE_TYPE) |
2054 |
> |
if (conf->type == XLINE_TYPE) |
2055 |
|
{ |
2056 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
2057 |
|
dlinkAdd(conf, make_dlink_node(), &temporary_xlines); |
2058 |
|
} |
2199 |
– |
else if (conf->type == RXLINE_TYPE) |
2200 |
– |
{ |
2201 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
2202 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rxlines); |
2203 |
– |
} |
2204 |
– |
else if (conf->type == RKLINE_TYPE) |
2205 |
– |
{ |
2206 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
2207 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rklines); |
2208 |
– |
} |
2059 |
|
else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE)) |
2060 |
|
{ |
2061 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
2073 |
|
void |
2074 |
|
cleanup_tklines(void *notused) |
2075 |
|
{ |
2076 |
< |
expire_tklines(&temporary_glines); |
2227 |
< |
expire_tklines(&temporary_klines); |
2228 |
< |
expire_tklines(&temporary_dlines); |
2076 |
> |
hostmask_expire_temporary(); |
2077 |
|
expire_tklines(&temporary_xlines); |
2230 |
– |
expire_tklines(&temporary_rxlines); |
2231 |
– |
expire_tklines(&temporary_rklines); |
2078 |
|
expire_tklines(&temporary_resv); |
2079 |
|
} |
2080 |
|
|
2092 |
|
struct ConfItem *conf; |
2093 |
|
struct MatchItem *xconf; |
2094 |
|
struct MatchItem *nconf; |
2249 |
– |
struct AccessItem *aconf; |
2095 |
|
struct ResvChannel *cconf; |
2096 |
|
|
2097 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
2098 |
|
{ |
2099 |
|
conf = ptr->data; |
2255 |
– |
if (conf->type == GLINE_TYPE || |
2256 |
– |
conf->type == KLINE_TYPE || |
2257 |
– |
conf->type == DLINE_TYPE) |
2258 |
– |
{ |
2259 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
2260 |
– |
if (aconf->hold <= CurrentTime) |
2261 |
– |
{ |
2262 |
– |
/* XXX - Do we want GLINE expiry notices?? */ |
2263 |
– |
/* Alert opers that a TKline expired - Hwy */ |
2264 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
2265 |
– |
{ |
2266 |
– |
if (aconf->status & CONF_KILL) |
2267 |
– |
{ |
2268 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2269 |
– |
"Temporary K-line for [%s@%s] expired", |
2270 |
– |
(aconf->user) ? aconf->user : "*", |
2271 |
– |
(aconf->host) ? aconf->host : "*"); |
2272 |
– |
} |
2273 |
– |
else if (conf->type == DLINE_TYPE) |
2274 |
– |
{ |
2275 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2276 |
– |
"Temporary D-line for [%s] expired", |
2277 |
– |
(aconf->host) ? aconf->host : "*"); |
2278 |
– |
} |
2279 |
– |
} |
2100 |
|
|
2101 |
< |
dlinkDelete(ptr, tklist); |
2282 |
< |
delete_one_address_conf(aconf->host, aconf); |
2283 |
< |
} |
2284 |
< |
} |
2285 |
< |
else if (conf->type == XLINE_TYPE || |
2286 |
< |
conf->type == RXLINE_TYPE) |
2101 |
> |
if (conf->type == XLINE_TYPE) |
2102 |
|
{ |
2103 |
|
xconf = (struct MatchItem *)map_to_conf(conf); |
2104 |
|
if (xconf->hold <= CurrentTime) |
2105 |
|
{ |
2106 |
|
if (ConfigFileEntry.tkline_expire_notices) |
2107 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2108 |
< |
"Temporary X-line for [%s] %sexpired", conf->name, |
2294 |
< |
conf->type == RXLINE_TYPE ? "(REGEX) " : ""); |
2108 |
> |
"Temporary X-line for [%s] sexpired", conf->name); |
2109 |
|
dlinkDelete(ptr, tklist); |
2110 |
|
free_dlink_node(ptr); |
2111 |
|
delete_conf_item(conf); |
2112 |
|
} |
2113 |
|
} |
2300 |
– |
else if (conf->type == RKLINE_TYPE) |
2301 |
– |
{ |
2302 |
– |
aconf = map_to_conf(conf); |
2303 |
– |
if (aconf->hold <= CurrentTime) |
2304 |
– |
{ |
2305 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
2306 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2307 |
– |
"Temporary K-line for [%s@%s] (REGEX) expired", |
2308 |
– |
(aconf->user) ? aconf->user : "*", |
2309 |
– |
(aconf->host) ? aconf->host : "*"); |
2310 |
– |
dlinkDelete(ptr, tklist); |
2311 |
– |
free_dlink_node(ptr); |
2312 |
– |
delete_conf_item(conf); |
2313 |
– |
} |
2314 |
– |
} |
2114 |
|
else if (conf->type == NRESV_TYPE) |
2115 |
|
{ |
2116 |
|
nconf = (struct MatchItem *)map_to_conf(conf); |
2191 |
|
* "oper" is server name for remote opers |
2192 |
|
* Side effects: None. |
2193 |
|
*/ |
2194 |
< |
char * |
2194 |
> |
const char * |
2195 |
|
get_oper_name(const struct Client *client_p) |
2196 |
|
{ |
2197 |
< |
dlink_node *cnode; |
2399 |
< |
struct ConfItem *conf; |
2400 |
< |
struct AccessItem *aconf; |
2401 |
< |
|
2197 |
> |
dlink_node *cnode = NULL; |
2198 |
|
/* +5 for !,@,{,} and null */ |
2199 |
|
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
2200 |
|
|
2201 |
|
if (MyConnect(client_p)) |
2202 |
|
{ |
2203 |
< |
DLINK_FOREACH(cnode, client_p->localClient->confs.head) |
2203 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2204 |
|
{ |
2205 |
< |
conf = cnode->data; |
2206 |
< |
aconf = map_to_conf(conf); |
2205 |
> |
struct ConfItem *conf = cnode->data; |
2206 |
> |
const struct AccessItem *aconf = map_to_conf(conf); |
2207 |
|
|
2208 |
|
if (IsConfOperator(aconf)) |
2209 |
|
{ |
2272 |
|
fclose(conf_parser_ctx.conf_file); |
2273 |
|
|
2274 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
2275 |
< |
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
2276 |
< |
ConfigChannel.use_except ? "e" : "", |
2481 |
< |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2275 |
> |
snprintf(chanmodes, sizeof(chanmodes), "beI:%d", |
2276 |
> |
ConfigChannel.max_bans); |
2277 |
|
add_isupport("MAXLIST", chanmodes, -1); |
2278 |
|
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
2279 |
|
|
2280 |
< |
if (ConfigChannel.disable_local_channels) |
2486 |
< |
add_isupport("CHANTYPES", "#", -1); |
2487 |
< |
else |
2488 |
< |
add_isupport("CHANTYPES", "#&", -1); |
2280 |
> |
add_isupport("CHANTYPES", "#", -1); |
2281 |
|
|
2282 |
< |
snprintf(chanlimit, sizeof(chanlimit), "%s:%d", |
2491 |
< |
ConfigChannel.disable_local_channels ? "#" : "#&", |
2282 |
> |
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
2283 |
|
ConfigChannel.max_chans_per_user); |
2284 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2285 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s%s%s", |
2286 |
< |
ConfigChannel.use_except ? "e" : "", |
2496 |
< |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS"); |
2285 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", |
2286 |
> |
"beI,k,l,imnprstORS"); |
2287 |
|
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2288 |
|
|
2289 |
< |
if (ConfigChannel.use_except) |
2290 |
< |
add_isupport("EXCEPTS", "e", -1); |
2501 |
< |
if (ConfigChannel.use_invex) |
2502 |
< |
add_isupport("INVEX", "I", -1); |
2289 |
> |
add_isupport("EXCEPTS", "e", -1); |
2290 |
> |
add_isupport("INVEX", "I", -1); |
2291 |
|
add_isupport("CHANMODES", chanmodes, -1); |
2292 |
|
|
2293 |
|
/* |
2351 |
|
struct ClassItem *cltmp; |
2352 |
|
struct MatchItem *match_item; |
2353 |
|
dlink_list *free_items [] = { |
2354 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, |
2354 |
> |
&server_items, &oconf_items, |
2355 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
2356 |
< |
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
2356 |
> |
&nresv_items, &cluster_items, &service_items, NULL |
2357 |
|
}; |
2358 |
|
|
2359 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2396 |
|
delete_conf_item(conf); |
2397 |
|
} |
2398 |
|
} |
2611 |
– |
else if (conf->type == CLIENT_TYPE) |
2612 |
– |
{ |
2613 |
– |
aconf = map_to_conf(conf); |
2614 |
– |
|
2615 |
– |
if (aconf->clients != 0) |
2616 |
– |
{ |
2617 |
– |
SetConfIllegal(aconf); |
2618 |
– |
} |
2619 |
– |
else |
2620 |
– |
{ |
2621 |
– |
delete_conf_item(conf); |
2622 |
– |
} |
2623 |
– |
} |
2399 |
|
else if (conf->type == XLINE_TYPE || |
2400 |
|
conf->type == RXLINE_TYPE || |
2401 |
|
conf->type == RKLINE_TYPE) |
2409 |
|
} |
2410 |
|
else |
2411 |
|
{ |
2637 |
– |
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2638 |
– |
{ |
2639 |
– |
match_item = map_to_conf(conf); |
2640 |
– |
if (match_item->ref_count <= 0) |
2641 |
– |
delete_conf_item(conf); |
2642 |
– |
else |
2643 |
– |
{ |
2644 |
– |
match_item->illegal = 1; |
2645 |
– |
dlinkDelete(&conf->node, *iterator); |
2646 |
– |
} |
2647 |
– |
} |
2648 |
– |
else |
2412 |
|
delete_conf_item(conf); |
2413 |
|
} |
2414 |
|
} |
2543 |
|
case KLINE_TYPE: |
2544 |
|
return ConfigFileEntry.klinefile; |
2545 |
|
break; |
2783 |
– |
case RKLINE_TYPE: |
2784 |
– |
return ConfigFileEntry.rklinefile; |
2785 |
– |
break; |
2546 |
|
case DLINE_TYPE: |
2547 |
|
return ConfigFileEntry.dlinefile; |
2548 |
|
break; |
2549 |
|
case XLINE_TYPE: |
2550 |
|
return ConfigFileEntry.xlinefile; |
2551 |
|
break; |
2792 |
– |
case RXLINE_TYPE: |
2793 |
– |
return ConfigFileEntry.rxlinefile; |
2794 |
– |
break; |
2552 |
|
case CRESV_TYPE: |
2553 |
|
return ConfigFileEntry.cresvfile; |
2554 |
|
break; |
2555 |
|
case NRESV_TYPE: |
2556 |
|
return ConfigFileEntry.nresvfile; |
2557 |
|
break; |
2801 |
– |
case GLINE_TYPE: |
2802 |
– |
return ConfigFileEntry.glinefile; |
2803 |
– |
break; |
2804 |
– |
|
2558 |
|
default: |
2559 |
|
return NULL; /* This should NEVER HAPPEN since we call this function |
2560 |
|
only with the above values, this will cause us to core |
2583 |
|
if (aconf->class_ptr != NULL) |
2584 |
|
{ |
2585 |
|
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
2586 |
< |
*pingwarn = PingWarning(aclass); |
2587 |
< |
return PingFreq(aclass); |
2586 |
> |
*pingwarn = aclass->ping_warning; |
2587 |
> |
return aclass->ping_freq; |
2588 |
|
} |
2589 |
|
} |
2590 |
|
|
2600 |
|
const char * |
2601 |
|
get_client_class(struct Client *target_p) |
2602 |
|
{ |
2603 |
< |
dlink_node *ptr; |
2604 |
< |
struct ConfItem *conf; |
2605 |
< |
struct AccessItem *aconf; |
2603 |
> |
dlink_node *cnode = NULL; |
2604 |
> |
struct AccessItem *aconf = NULL; |
2605 |
> |
|
2606 |
> |
assert(!IsMe(target_p)); |
2607 |
|
|
2608 |
< |
if (target_p != NULL && !IsMe(target_p) && |
2855 |
< |
target_p->localClient->confs.head != NULL) |
2608 |
> |
if ((cnode = target_p->localClient->confs.head)) |
2609 |
|
{ |
2610 |
< |
DLINK_FOREACH(ptr, target_p->localClient->confs.head) |
2858 |
< |
{ |
2859 |
< |
conf = ptr->data; |
2610 |
> |
struct ConfItem *conf = cnode->data; |
2611 |
|
|
2612 |
< |
if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE || |
2613 |
< |
conf->type == OPER_TYPE) |
2614 |
< |
{ |
2615 |
< |
aconf = (struct AccessItem *) map_to_conf(conf); |
2616 |
< |
if (aconf->class_ptr != NULL) |
2617 |
< |
return aconf->class_ptr->name; |
2867 |
< |
} |
2868 |
< |
} |
2612 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2613 |
> |
(conf->type == OPER_TYPE)); |
2614 |
> |
|
2615 |
> |
aconf = map_to_conf(conf); |
2616 |
> |
if (aconf->class_ptr != NULL) |
2617 |
> |
return aconf->class_ptr->name; |
2618 |
|
} |
2619 |
|
|
2620 |
|
return "default"; |
2630 |
|
int |
2631 |
|
get_client_ping(struct Client *target_p, int *pingwarn) |
2632 |
|
{ |
2633 |
< |
int ping; |
2634 |
< |
struct ConfItem *conf; |
2886 |
< |
dlink_node *nlink; |
2633 |
> |
int ping = 0; |
2634 |
> |
dlink_node *cnode = NULL; |
2635 |
|
|
2636 |
< |
if (target_p->localClient->confs.head != NULL) |
2637 |
< |
DLINK_FOREACH(nlink, target_p->localClient->confs.head) |
2638 |
< |
{ |
2891 |
< |
conf = nlink->data; |
2636 |
> |
if ((cnode = target_p->localClient->confs.head)) |
2637 |
> |
{ |
2638 |
> |
struct ConfItem *conf = cnode->data; |
2639 |
|
|
2640 |
< |
if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2641 |
< |
(conf->type == OPER_TYPE)) |
2642 |
< |
{ |
2643 |
< |
ping = get_conf_ping(conf, pingwarn); |
2644 |
< |
if (ping > 0) |
2645 |
< |
return ping; |
2646 |
< |
} |
2900 |
< |
} |
2640 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2641 |
> |
(conf->type == OPER_TYPE)); |
2642 |
> |
|
2643 |
> |
ping = get_conf_ping(conf, pingwarn); |
2644 |
> |
if (ping > 0) |
2645 |
> |
return ping; |
2646 |
> |
} |
2647 |
|
|
2648 |
|
*pingwarn = 0; |
2649 |
|
return DEFAULT_PINGFREQUENCY; |
2681 |
|
{ |
2682 |
|
struct ClassItem *aclass = map_to_conf(ptr->data); |
2683 |
|
|
2684 |
< |
if (!aclass->active && !CurrUserCount(aclass)) |
2684 |
> |
if (!aclass->active && !aclass->curr_user_count) |
2685 |
|
{ |
2686 |
|
destroy_cidr_class(aclass); |
2687 |
|
delete_conf_item(ptr->data); |
2705 |
|
aclass = map_to_conf(class_default); |
2706 |
|
aclass->active = 1; |
2707 |
|
DupString(class_default->name, "default"); |
2708 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2709 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2710 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
2711 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
2708 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
2709 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
2710 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
2711 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
2712 |
> |
aclass->max_recvq = DEFAULT_RECVQ; |
2713 |
|
|
2714 |
|
client_check_cb = register_callback("check_client", check_client); |
2715 |
|
} |
2724 |
|
get_sendq(struct Client *client_p) |
2725 |
|
{ |
2726 |
|
unsigned int sendq = DEFAULT_SENDQ; |
2727 |
< |
dlink_node *ptr; |
2981 |
< |
struct ConfItem *conf; |
2727 |
> |
dlink_node *cnode; |
2728 |
|
struct ConfItem *class_conf; |
2729 |
|
struct ClassItem *aclass; |
2730 |
|
struct AccessItem *aconf; |
2731 |
|
|
2732 |
< |
if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head)) |
2732 |
> |
assert(!IsMe(client_p)); |
2733 |
> |
|
2734 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2735 |
|
{ |
2736 |
< |
DLINK_FOREACH(ptr, client_p->localClient->confs.head) |
2737 |
< |
{ |
2738 |
< |
conf = ptr->data; |
2739 |
< |
if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE) |
2740 |
< |
|| (conf->type == CLIENT_TYPE)) |
2741 |
< |
{ |
2742 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2743 |
< |
if ((class_conf = aconf->class_ptr) == NULL) |
2744 |
< |
continue; |
2745 |
< |
aclass = (struct ClassItem *)map_to_conf(class_conf); |
2746 |
< |
sendq = MaxSendq(aclass); |
2747 |
< |
return sendq; |
2748 |
< |
} |
3001 |
< |
} |
2736 |
> |
struct ConfItem *conf = cnode->data; |
2737 |
> |
|
2738 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2739 |
> |
(conf->type == OPER_TYPE)); |
2740 |
> |
|
2741 |
> |
aconf = map_to_conf(conf); |
2742 |
> |
|
2743 |
> |
if ((class_conf = aconf->class_ptr) == NULL) |
2744 |
> |
return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */ |
2745 |
> |
|
2746 |
> |
aclass = map_to_conf(class_conf); |
2747 |
> |
sendq = aclass->max_sendq; |
2748 |
> |
return sendq; |
2749 |
|
} |
2750 |
+ |
|
2751 |
|
/* XXX return a default? |
2752 |
|
* if here, then there wasn't an attached conf with a sendq |
2753 |
|
* that is very bad -Dianora |
2755 |
|
return DEFAULT_SENDQ; |
2756 |
|
} |
2757 |
|
|
2758 |
+ |
unsigned int |
2759 |
+ |
get_recvq(struct Client *client_p) |
2760 |
+ |
{ |
2761 |
+ |
unsigned int recvq = DEFAULT_RECVQ; |
2762 |
+ |
dlink_node *cnode; |
2763 |
+ |
struct ConfItem *class_conf; |
2764 |
+ |
struct ClassItem *aclass; |
2765 |
+ |
struct AccessItem *aconf; |
2766 |
+ |
|
2767 |
+ |
assert(!IsMe(client_p)); |
2768 |
+ |
|
2769 |
+ |
if ((cnode = client_p->localClient->confs.head)) |
2770 |
+ |
{ |
2771 |
+ |
struct ConfItem *conf = cnode->data; |
2772 |
+ |
|
2773 |
+ |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2774 |
+ |
(conf->type == OPER_TYPE)); |
2775 |
+ |
|
2776 |
+ |
aconf = map_to_conf(conf); |
2777 |
+ |
|
2778 |
+ |
if ((class_conf = aconf->class_ptr) == NULL) |
2779 |
+ |
return DEFAULT_RECVQ; /* TBV: shouldn't be possible at all */ |
2780 |
+ |
|
2781 |
+ |
aclass = map_to_conf(class_conf); |
2782 |
+ |
recvq = aclass->max_recvq; |
2783 |
+ |
return recvq; |
2784 |
+ |
} |
2785 |
+ |
|
2786 |
+ |
/* XXX return a default? |
2787 |
+ |
* if here, then there wasn't an attached conf with a recvq |
2788 |
+ |
* that is very bad -Dianora |
2789 |
+ |
*/ |
2790 |
+ |
return DEFAULT_RECVQ; |
2791 |
+ |
} |
2792 |
+ |
|
2793 |
|
/* conf_add_class_to_conf() |
2794 |
|
* |
2795 |
|
* inputs - pointer to config item |
2845 |
|
int |
2846 |
|
conf_add_server(struct ConfItem *conf, const char *class_name) |
2847 |
|
{ |
2848 |
< |
struct AccessItem *aconf; |
3066 |
< |
struct split_nuh_item nuh; |
3067 |
< |
char conf_user[USERLEN + 1]; |
3068 |
< |
char conf_host[HOSTLEN + 1]; |
3069 |
< |
|
3070 |
< |
aconf = map_to_conf(conf); |
2848 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
2849 |
|
|
2850 |
|
conf_add_class_to_conf(conf, class_name); |
2851 |
|
|
2864 |
|
return -1; |
2865 |
|
} |
2866 |
|
|
3089 |
– |
nuh.nuhmask = aconf->host; |
3090 |
– |
nuh.nickptr = NULL; |
3091 |
– |
nuh.userptr = conf_user; |
3092 |
– |
nuh.hostptr = conf_host; |
3093 |
– |
|
3094 |
– |
nuh.nicksize = 0; |
3095 |
– |
nuh.usersize = sizeof(conf_user); |
3096 |
– |
nuh.hostsize = sizeof(conf_host); |
3097 |
– |
|
3098 |
– |
split_nuh(&nuh); |
3099 |
– |
|
3100 |
– |
MyFree(aconf->host); |
3101 |
– |
aconf->host = NULL; |
3102 |
– |
|
3103 |
– |
DupString(aconf->user, conf_user); /* somehow username checking for servers |
3104 |
– |
got lost in H6/7, will have to be re-added */ |
3105 |
– |
DupString(aconf->host, conf_host); |
3106 |
– |
|
2867 |
|
lookup_confhost(conf); |
2868 |
|
|
2869 |
|
return 0; |
3195 |
|
|
3196 |
|
return 1; |
3197 |
|
} |
3198 |
< |
else if (!(flags & NOUSERLOOKUP)) |
3198 |
> |
else |
3199 |
|
{ |
3200 |
|
/* Try to find user@host mask from nick */ |
3201 |
|
/* Okay to use source_p as the first param, because source_p == client_p */ |
3269 |
|
{ |
3270 |
|
const char *encr = NULL; |
3271 |
|
|
3272 |
< |
if (password == NULL || aconf->passwd == NULL) |
3272 |
> |
if (EmptyString(password) || EmptyString(aconf->passwd)) |
3273 |
|
return 0; |
3274 |
|
|
3275 |
|
if (aconf->flags & CONF_FLAGS_ENCRYPTED) |
3276 |
< |
{ |
3517 |
< |
/* use first two chars of the password they send in as salt */ |
3518 |
< |
/* If the password in the conf is MD5, and ircd is linked |
3519 |
< |
* to scrypt on FreeBSD, or the standard crypt library on |
3520 |
< |
* glibc Linux, then this code will work fine on generating |
3521 |
< |
* the proper encrypted hash for comparison. |
3522 |
< |
*/ |
3523 |
< |
if (*aconf->passwd) |
3524 |
< |
encr = crypt(password, aconf->passwd); |
3525 |
< |
else |
3526 |
< |
encr = ""; |
3527 |
< |
} |
3276 |
> |
encr = crypt(password, aconf->passwd); |
3277 |
|
else |
3278 |
|
encr = password; |
3279 |
|
|
3446 |
|
dlink_node *ptr = NULL; |
3447 |
|
struct CidrItem *cidr; |
3448 |
|
|
3449 |
< |
if (NumberPerCidr(aclass) <= 0) |
3449 |
> |
if (aclass->number_per_cidr <= 0) |
3450 |
|
return 0; |
3451 |
|
|
3452 |
|
if (ip->ss.ss_family == AF_INET) |
3453 |
|
{ |
3454 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
3454 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
3455 |
|
return 0; |
3456 |
|
|
3457 |
|
DLINK_FOREACH(ptr, aclass->list_ipv4.head) |
3458 |
|
{ |
3459 |
|
cidr = ptr->data; |
3460 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
3460 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
3461 |
|
{ |
3462 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
3462 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
3463 |
|
return -1; |
3464 |
|
cidr->number_on_this_cidr++; |
3465 |
|
return 0; |
3468 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
3469 |
|
cidr->number_on_this_cidr = 1; |
3470 |
|
cidr->mask = *ip; |
3471 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV4(aclass)); |
3471 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4); |
3472 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4); |
3473 |
|
} |
3474 |
|
#ifdef IPV6 |
3475 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
3475 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
3476 |
|
{ |
3477 |
|
DLINK_FOREACH(ptr, aclass->list_ipv6.head) |
3478 |
|
{ |
3479 |
|
cidr = ptr->data; |
3480 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
3480 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
3481 |
|
{ |
3482 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
3482 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
3483 |
|
return -1; |
3484 |
|
cidr->number_on_this_cidr++; |
3485 |
|
return 0; |
3488 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
3489 |
|
cidr->number_on_this_cidr = 1; |
3490 |
|
cidr->mask = *ip; |
3491 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV6(aclass)); |
3491 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6); |
3492 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6); |
3493 |
|
} |
3494 |
|
#endif |
3510 |
|
dlink_node *next_ptr = NULL; |
3511 |
|
struct CidrItem *cidr; |
3512 |
|
|
3513 |
< |
if (NumberPerCidr(aclass) == 0) |
3513 |
> |
if (aclass->number_per_cidr == 0) |
3514 |
|
return; |
3515 |
|
|
3516 |
|
if (ip->ss.ss_family == AF_INET) |
3517 |
|
{ |
3518 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
3518 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
3519 |
|
return; |
3520 |
|
|
3521 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
3522 |
|
{ |
3523 |
|
cidr = ptr->data; |
3524 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
3524 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
3525 |
|
{ |
3526 |
|
cidr->number_on_this_cidr--; |
3527 |
|
if (cidr->number_on_this_cidr == 0) |
3534 |
|
} |
3535 |
|
} |
3536 |
|
#ifdef IPV6 |
3537 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
3537 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
3538 |
|
{ |
3539 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head) |
3540 |
|
{ |
3541 |
|
cidr = ptr->data; |
3542 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
3542 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
3543 |
|
{ |
3544 |
|
cidr->number_on_this_cidr--; |
3545 |
|
if (cidr->number_on_this_cidr == 0) |
3602 |
|
{ |
3603 |
|
struct ClassItem *old_class = map_to_conf(conf); |
3604 |
|
|
3605 |
< |
if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0) |
3605 |
> |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
3606 |
|
{ |
3607 |
< |
if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0) |
3607 |
> |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
3608 |
|
rebuild_cidr_list(AF_INET, conf, new_class, |
3609 |
|
&old_class->list_ipv4, &new_class->list_ipv4, |
3610 |
< |
CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class)); |
3610 |
> |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
3611 |
|
|
3612 |
|
#ifdef IPV6 |
3613 |
< |
if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0) |
3613 |
> |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
3614 |
|
rebuild_cidr_list(AF_INET6, conf, new_class, |
3615 |
|
&old_class->list_ipv6, &new_class->list_ipv6, |
3616 |
< |
CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class)); |
3616 |
> |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
3617 |
|
#endif |
3618 |
|
} |
3619 |
|
|