| 59 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
| 60 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
| 61 |
|
dlink_list cluster_items = { NULL, NULL, 0 }; |
| 62 |
– |
dlink_list hub_items = { NULL, NULL, 0 }; |
| 63 |
– |
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 }; |
| 68 |
|
dlink_list class_items = { NULL, NULL, 0 }; |
| 69 |
|
dlink_list gdeny_items = { NULL, NULL, 0 }; |
| 70 |
|
|
| 73 |
– |
dlink_list temporary_klines = { NULL, NULL, 0 }; |
| 74 |
– |
dlink_list temporary_dlines = { NULL, NULL, 0 }; |
| 71 |
|
dlink_list temporary_xlines = { NULL, NULL, 0 }; |
| 76 |
– |
dlink_list temporary_glines = { NULL, NULL, 0 }; |
| 72 |
|
dlink_list temporary_resv = { NULL, NULL, 0 }; |
| 73 |
|
|
| 74 |
|
extern unsigned int lineno; |
| 161 |
|
aconf->dns_pending = 0; |
| 162 |
|
|
| 163 |
|
if (addr != NULL) |
| 164 |
< |
memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum)); |
| 164 |
> |
memcpy(&aconf->addr, addr, sizeof(aconf->addr)); |
| 165 |
|
else |
| 166 |
|
aconf->dns_failed = 1; |
| 167 |
|
} |
| 249 |
|
aconf->status = status; |
| 250 |
|
break; |
| 251 |
|
|
| 257 |
– |
case LEAF_TYPE: |
| 258 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
| 259 |
– |
sizeof(struct MatchItem)); |
| 260 |
– |
dlinkAdd(conf, &conf->node, &leaf_items); |
| 261 |
– |
break; |
| 262 |
– |
|
| 263 |
– |
case HUB_TYPE: |
| 264 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
| 265 |
– |
sizeof(struct MatchItem)); |
| 266 |
– |
dlinkAdd(conf, &conf->node, &hub_items); |
| 267 |
– |
break; |
| 268 |
– |
|
| 252 |
|
case ULINE_TYPE: |
| 253 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
| 254 |
|
sizeof(struct MatchItem)); |
| 310 |
|
|
| 311 |
|
aclass = map_to_conf(conf); |
| 312 |
|
aclass->active = 1; |
| 313 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
| 314 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
| 315 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
| 316 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
| 313 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
| 314 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
| 315 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
| 316 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
| 317 |
|
|
| 318 |
|
break; |
| 319 |
|
|
| 331 |
|
void |
| 332 |
|
delete_conf_item(struct ConfItem *conf) |
| 333 |
|
{ |
| 334 |
< |
dlink_node *m = NULL; |
| 334 |
> |
dlink_node *m = NULL, *m_next = NULL; |
| 335 |
|
struct MatchItem *match_item; |
| 336 |
|
struct AccessItem *aconf; |
| 337 |
|
ConfType type = conf->type; |
| 391 |
|
|
| 392 |
|
case SERVER_TYPE: |
| 393 |
|
aconf = map_to_conf(conf); |
| 394 |
+ |
|
| 395 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head) |
| 396 |
+ |
{ |
| 397 |
+ |
MyFree(m->data); |
| 398 |
+ |
free_dlink_node(m); |
| 399 |
+ |
} |
| 400 |
+ |
|
| 401 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head) |
| 402 |
+ |
{ |
| 403 |
+ |
MyFree(m->data); |
| 404 |
+ |
free_dlink_node(m); |
| 405 |
+ |
} |
| 406 |
+ |
|
| 407 |
|
if (!IsConfIllegal(aconf)) |
| 408 |
|
dlinkDelete(&conf->node, &server_items); |
| 409 |
|
MyFree(conf); |
| 414 |
|
} |
| 415 |
|
break; |
| 416 |
|
|
| 421 |
– |
case HUB_TYPE: |
| 422 |
– |
match_item = map_to_conf(conf); |
| 423 |
– |
MyFree(match_item->user); |
| 424 |
– |
MyFree(match_item->host); |
| 425 |
– |
MyFree(match_item->reason); |
| 426 |
– |
MyFree(match_item->oper_reason); |
| 427 |
– |
/* If marked illegal, its already been pulled off of the hub_items list */ |
| 428 |
– |
if (!match_item->illegal) |
| 429 |
– |
dlinkDelete(&conf->node, &hub_items); |
| 430 |
– |
MyFree(conf); |
| 431 |
– |
break; |
| 432 |
– |
|
| 433 |
– |
case LEAF_TYPE: |
| 434 |
– |
match_item = map_to_conf(conf); |
| 435 |
– |
MyFree(match_item->user); |
| 436 |
– |
MyFree(match_item->host); |
| 437 |
– |
MyFree(match_item->reason); |
| 438 |
– |
MyFree(match_item->oper_reason); |
| 439 |
– |
/* If marked illegal, its already been pulled off of the leaf_items list */ |
| 440 |
– |
if (!match_item->illegal) |
| 441 |
– |
dlinkDelete(&conf->node, &leaf_items); |
| 442 |
– |
MyFree(conf); |
| 443 |
– |
break; |
| 444 |
– |
|
| 417 |
|
case ULINE_TYPE: |
| 418 |
|
match_item = map_to_conf(conf); |
| 419 |
|
MyFree(match_item->user); |
| 538 |
|
void |
| 539 |
|
report_confitem_types(struct Client *source_p, ConfType type) |
| 540 |
|
{ |
| 541 |
< |
dlink_node *ptr = NULL; |
| 541 |
> |
dlink_node *ptr = NULL, *dptr = NULL; |
| 542 |
|
struct ConfItem *conf = NULL; |
| 543 |
|
struct AccessItem *aconf = NULL; |
| 544 |
|
struct MatchItem *matchitem = NULL; |
| 676 |
|
classitem = map_to_conf(conf); |
| 677 |
|
sendto_one(source_p, form_str(RPL_STATSYLINE), |
| 678 |
|
me.name, source_p->name, 'Y', |
| 679 |
< |
conf->name, PingFreq(classitem), |
| 680 |
< |
ConFreq(classitem), |
| 681 |
< |
MaxTotal(classitem), MaxSendq(classitem), |
| 682 |
< |
CurrUserCount(classitem), |
| 679 |
> |
conf->name, classitem->ping_freq, |
| 680 |
> |
classitem->con_freq, |
| 681 |
> |
classitem->max_total, classitem->max_sendq, |
| 682 |
> |
classitem->curr_user_count, |
| 683 |
|
classitem->active ? "active" : "disabled"); |
| 684 |
|
} |
| 685 |
|
break; |
| 735 |
|
break; |
| 736 |
|
|
| 737 |
|
case HUB_TYPE: |
| 738 |
< |
DLINK_FOREACH(ptr, hub_items.head) |
| 738 |
> |
DLINK_FOREACH(ptr, server_items.head) |
| 739 |
|
{ |
| 740 |
|
conf = ptr->data; |
| 741 |
< |
matchitem = map_to_conf(conf); |
| 742 |
< |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
| 743 |
< |
source_p->name, 'H', matchitem->host, conf->name, 0, "*"); |
| 741 |
> |
aconf = map_to_conf(conf); |
| 742 |
> |
|
| 743 |
> |
DLINK_FOREACH(dptr, aconf->hub_list.head) |
| 744 |
> |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
| 745 |
> |
source_p->name, 'H', dptr->data, conf->name, 0, "*"); |
| 746 |
|
} |
| 747 |
|
break; |
| 748 |
|
|
| 749 |
|
case LEAF_TYPE: |
| 750 |
< |
DLINK_FOREACH(ptr, leaf_items.head) |
| 750 |
> |
DLINK_FOREACH(ptr, server_items.head) |
| 751 |
|
{ |
| 752 |
|
conf = ptr->data; |
| 753 |
< |
matchitem = map_to_conf(conf); |
| 754 |
< |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
| 755 |
< |
source_p->name, 'L', matchitem->host, conf->name, 0, "*"); |
| 753 |
> |
aconf = map_to_conf(conf); |
| 754 |
> |
|
| 755 |
> |
DLINK_FOREACH(dptr, aconf->leaf_list.head) |
| 756 |
> |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
| 757 |
> |
source_p->name, 'L', dptr->data, conf->name, 0, "*"); |
| 758 |
|
} |
| 759 |
|
break; |
| 760 |
|
|
| 993 |
|
* setting a_limit_reached if any limit is reached. |
| 994 |
|
* - Dianora |
| 995 |
|
*/ |
| 996 |
< |
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
| 996 |
> |
if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total) |
| 997 |
|
a_limit_reached = 1; |
| 998 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
| 998 |
> |
else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip) |
| 999 |
|
a_limit_reached = 1; |
| 1000 |
< |
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
| 1000 |
> |
else if (aclass->max_local != 0 && local >= aclass->max_local) |
| 1001 |
|
a_limit_reached = 1; |
| 1002 |
< |
else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass)) |
| 1002 |
> |
else if (aclass->max_global != 0 && global >= aclass->max_global) |
| 1003 |
|
a_limit_reached = 1; |
| 1004 |
< |
else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) && |
| 1004 |
> |
else if (aclass->max_ident != 0 && ident >= aclass->max_ident && |
| 1005 |
|
client_p->username[0] != '~') |
| 1006 |
|
a_limit_reached = 1; |
| 1007 |
|
|
| 1284 |
|
|
| 1285 |
|
assert(aconf->clients > 0); |
| 1286 |
|
|
| 1287 |
< |
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
| 1287 |
> |
if ((aclass_conf = aconf->class_ptr) != NULL) |
| 1288 |
|
{ |
| 1289 |
|
aclass = map_to_conf(aclass_conf); |
| 1290 |
|
|
| 1300 |
|
delete_conf_item(conf); |
| 1301 |
|
|
| 1302 |
|
break; |
| 1327 |
– |
|
| 1328 |
– |
case LEAF_TYPE: |
| 1329 |
– |
case HUB_TYPE: |
| 1330 |
– |
match_item = map_to_conf(conf); |
| 1331 |
– |
if (match_item->ref_count == 0 && match_item->illegal) |
| 1332 |
– |
delete_conf_item(conf); |
| 1333 |
– |
break; |
| 1303 |
|
default: |
| 1304 |
|
break; |
| 1305 |
|
} |
| 1343 |
|
&client_p->localClient->ip, aclass)) |
| 1344 |
|
return TOO_MANY; /* Already at maximum allowed */ |
| 1345 |
|
|
| 1346 |
< |
CurrUserCount(aclass)++; |
| 1346 |
> |
aclass->curr_user_count++; |
| 1347 |
|
aconf->clients++; |
| 1348 |
|
} |
| 1380 |
– |
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
| 1381 |
– |
{ |
| 1382 |
– |
struct MatchItem *match_item = map_to_conf(conf); |
| 1383 |
– |
match_item->ref_count++; |
| 1384 |
– |
} |
| 1349 |
|
|
| 1350 |
|
dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs); |
| 1351 |
|
|
| 1434 |
|
{ |
| 1435 |
|
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
| 1436 |
|
|
| 1437 |
< |
if (aconf->clients >= MaxTotal(aclass)) |
| 1437 |
> |
if (aconf->clients >= aclass->max_total) |
| 1438 |
|
continue; |
| 1439 |
|
} |
| 1440 |
|
|
| 1683 |
|
break; |
| 1684 |
|
case HM_IPV4: |
| 1685 |
|
if (who->localClient->aftype == AF_INET) |
| 1686 |
< |
if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
| 1686 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits)) |
| 1687 |
|
return conf; |
| 1688 |
|
break; |
| 1689 |
|
#ifdef IPV6 |
| 1690 |
|
case HM_IPV6: |
| 1691 |
|
if (who->localClient->aftype == AF_INET6) |
| 1692 |
< |
if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits)) |
| 1692 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits)) |
| 1693 |
|
return conf; |
| 1694 |
|
break; |
| 1695 |
|
#endif |
| 1997 |
|
|
| 1998 |
|
assert(res != NULL); |
| 1999 |
|
|
| 2000 |
< |
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
| 2001 |
< |
aconf->ipnum.ss_len = res->ai_addrlen; |
| 2002 |
< |
aconf->ipnum.ss.ss_family = res->ai_family; |
| 2000 |
> |
memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen); |
| 2001 |
> |
aconf->addr.ss_len = res->ai_addrlen; |
| 2002 |
> |
aconf->addr.ss.ss_family = res->ai_family; |
| 2003 |
|
freeaddrinfo(res); |
| 2004 |
|
} |
| 2005 |
|
|
| 2077 |
|
|
| 2078 |
|
assert(client_p != NULL); |
| 2079 |
|
|
| 2080 |
< |
aconf = find_kline_conf(client_p->host, client_p->username, |
| 2081 |
< |
&client_p->localClient->ip, |
| 2082 |
< |
client_p->localClient->aftype); |
| 2080 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
| 2081 |
> |
CONF_KLINE, client_p->localClient->aftype, |
| 2082 |
> |
client_p->username, NULL, 1); |
| 2083 |
|
if (aconf == NULL) |
| 2084 |
|
aconf = find_regexp_kline(uhi); |
| 2085 |
|
|
| 2086 |
< |
if (aconf && (aconf->status & CONF_KLINE)) |
| 2123 |
< |
return aconf; |
| 2124 |
< |
|
| 2125 |
< |
return NULL; |
| 2086 |
> |
return aconf; |
| 2087 |
|
} |
| 2088 |
|
|
| 2089 |
|
struct AccessItem * |
| 2093 |
|
|
| 2094 |
|
assert(client_p != NULL); |
| 2095 |
|
|
| 2096 |
< |
aconf = find_gline_conf(client_p->host, client_p->username, |
| 2097 |
< |
&client_p->localClient->ip, |
| 2098 |
< |
client_p->localClient->aftype); |
| 2099 |
< |
|
| 2139 |
< |
if (aconf && (aconf->status & CONF_GLINE)) |
| 2140 |
< |
return aconf; |
| 2141 |
< |
|
| 2142 |
< |
return NULL; |
| 2096 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
| 2097 |
> |
CONF_GLINE, client_p->localClient->aftype, |
| 2098 |
> |
client_p->username, NULL, 1); |
| 2099 |
> |
return aconf; |
| 2100 |
|
} |
| 2101 |
|
|
| 2102 |
|
/* add_temp_line() |
| 2109 |
|
void |
| 2110 |
|
add_temp_line(struct ConfItem *conf) |
| 2111 |
|
{ |
| 2112 |
< |
struct AccessItem *aconf; |
| 2156 |
< |
|
| 2157 |
< |
if (conf->type == DLINE_TYPE) |
| 2158 |
< |
{ |
| 2159 |
< |
aconf = map_to_conf(conf); |
| 2160 |
< |
SetConfTemporary(aconf); |
| 2161 |
< |
dlinkAdd(conf, &conf->node, &temporary_dlines); |
| 2162 |
< |
MyFree(aconf->user); |
| 2163 |
< |
aconf->user = NULL; |
| 2164 |
< |
add_conf_by_address(CONF_DLINE, aconf); |
| 2165 |
< |
} |
| 2166 |
< |
else if (conf->type == KLINE_TYPE) |
| 2167 |
< |
{ |
| 2168 |
< |
aconf = map_to_conf(conf); |
| 2169 |
< |
SetConfTemporary(aconf); |
| 2170 |
< |
dlinkAdd(conf, &conf->node, &temporary_klines); |
| 2171 |
< |
add_conf_by_address(CONF_KILL, aconf); |
| 2172 |
< |
} |
| 2173 |
< |
else if (conf->type == GLINE_TYPE) |
| 2174 |
< |
{ |
| 2175 |
< |
aconf = map_to_conf(conf); |
| 2176 |
< |
SetConfTemporary(aconf); |
| 2177 |
< |
dlinkAdd(conf, &conf->node, &temporary_glines); |
| 2178 |
< |
add_conf_by_address(CONF_GLINE, aconf); |
| 2179 |
< |
} |
| 2180 |
< |
else if (conf->type == XLINE_TYPE) |
| 2112 |
> |
if (conf->type == XLINE_TYPE) |
| 2113 |
|
{ |
| 2114 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
| 2115 |
|
dlinkAdd(conf, make_dlink_node(), &temporary_xlines); |
| 2131 |
|
void |
| 2132 |
|
cleanup_tklines(void *notused) |
| 2133 |
|
{ |
| 2134 |
< |
expire_tklines(&temporary_glines); |
| 2203 |
< |
expire_tklines(&temporary_klines); |
| 2204 |
< |
expire_tklines(&temporary_dlines); |
| 2134 |
> |
hostmask_expire_temporary(); |
| 2135 |
|
expire_tklines(&temporary_xlines); |
| 2136 |
|
expire_tklines(&temporary_resv); |
| 2137 |
|
} |
| 2150 |
|
struct ConfItem *conf; |
| 2151 |
|
struct MatchItem *xconf; |
| 2152 |
|
struct MatchItem *nconf; |
| 2223 |
– |
struct AccessItem *aconf; |
| 2153 |
|
struct ResvChannel *cconf; |
| 2154 |
|
|
| 2155 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
| 2156 |
|
{ |
| 2157 |
|
conf = ptr->data; |
| 2229 |
– |
if (conf->type == GLINE_TYPE || |
| 2230 |
– |
conf->type == KLINE_TYPE || |
| 2231 |
– |
conf->type == DLINE_TYPE) |
| 2232 |
– |
{ |
| 2233 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2234 |
– |
if (aconf->hold <= CurrentTime) |
| 2235 |
– |
{ |
| 2236 |
– |
/* XXX - Do we want GLINE expiry notices?? */ |
| 2237 |
– |
/* Alert opers that a TKline expired - Hwy */ |
| 2238 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
| 2239 |
– |
{ |
| 2240 |
– |
if (aconf->status & CONF_KILL) |
| 2241 |
– |
{ |
| 2242 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2243 |
– |
"Temporary K-line for [%s@%s] expired", |
| 2244 |
– |
(aconf->user) ? aconf->user : "*", |
| 2245 |
– |
(aconf->host) ? aconf->host : "*"); |
| 2246 |
– |
} |
| 2247 |
– |
else if (conf->type == DLINE_TYPE) |
| 2248 |
– |
{ |
| 2249 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2250 |
– |
"Temporary D-line for [%s] expired", |
| 2251 |
– |
(aconf->host) ? aconf->host : "*"); |
| 2252 |
– |
} |
| 2253 |
– |
} |
| 2158 |
|
|
| 2159 |
< |
dlinkDelete(ptr, tklist); |
| 2256 |
< |
delete_one_address_conf(aconf->host, aconf); |
| 2257 |
< |
} |
| 2258 |
< |
} |
| 2259 |
< |
else if (conf->type == XLINE_TYPE || |
| 2260 |
< |
conf->type == RXLINE_TYPE) |
| 2159 |
> |
if (conf->type == XLINE_TYPE) |
| 2160 |
|
{ |
| 2161 |
|
xconf = (struct MatchItem *)map_to_conf(conf); |
| 2162 |
|
if (xconf->hold <= CurrentTime) |
| 2163 |
|
{ |
| 2164 |
|
if (ConfigFileEntry.tkline_expire_notices) |
| 2165 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2166 |
< |
"Temporary X-line for [%s] %sexpired", conf->name, |
| 2268 |
< |
conf->type == RXLINE_TYPE ? "(REGEX) " : ""); |
| 2166 |
> |
"Temporary X-line for [%s] sexpired", conf->name); |
| 2167 |
|
dlinkDelete(ptr, tklist); |
| 2168 |
|
free_dlink_node(ptr); |
| 2169 |
|
delete_conf_item(conf); |
| 2170 |
|
} |
| 2171 |
|
} |
| 2274 |
– |
else if (conf->type == RKLINE_TYPE) |
| 2275 |
– |
{ |
| 2276 |
– |
aconf = map_to_conf(conf); |
| 2277 |
– |
if (aconf->hold <= CurrentTime) |
| 2278 |
– |
{ |
| 2279 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
| 2280 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2281 |
– |
"Temporary K-line for [%s@%s] (REGEX) expired", |
| 2282 |
– |
(aconf->user) ? aconf->user : "*", |
| 2283 |
– |
(aconf->host) ? aconf->host : "*"); |
| 2284 |
– |
dlinkDelete(ptr, tklist); |
| 2285 |
– |
free_dlink_node(ptr); |
| 2286 |
– |
delete_conf_item(conf); |
| 2287 |
– |
} |
| 2288 |
– |
} |
| 2172 |
|
else if (conf->type == NRESV_TYPE) |
| 2173 |
|
{ |
| 2174 |
|
nconf = (struct MatchItem *)map_to_conf(conf); |
| 2417 |
|
struct ClassItem *cltmp; |
| 2418 |
|
struct MatchItem *match_item; |
| 2419 |
|
dlink_list *free_items [] = { |
| 2420 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, |
| 2420 |
> |
&server_items, &oconf_items, |
| 2421 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
| 2422 |
|
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
| 2423 |
|
}; |
| 2462 |
|
delete_conf_item(conf); |
| 2463 |
|
} |
| 2464 |
|
} |
| 2582 |
– |
else if (conf->type == CLIENT_TYPE) |
| 2583 |
– |
{ |
| 2584 |
– |
aconf = map_to_conf(conf); |
| 2585 |
– |
|
| 2586 |
– |
if (aconf->clients != 0) |
| 2587 |
– |
{ |
| 2588 |
– |
SetConfIllegal(aconf); |
| 2589 |
– |
} |
| 2590 |
– |
else |
| 2591 |
– |
{ |
| 2592 |
– |
delete_conf_item(conf); |
| 2593 |
– |
} |
| 2594 |
– |
} |
| 2465 |
|
else if (conf->type == XLINE_TYPE || |
| 2466 |
|
conf->type == RXLINE_TYPE || |
| 2467 |
|
conf->type == RKLINE_TYPE) |
| 2475 |
|
} |
| 2476 |
|
else |
| 2477 |
|
{ |
| 2608 |
– |
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
| 2609 |
– |
{ |
| 2610 |
– |
match_item = map_to_conf(conf); |
| 2611 |
– |
if (match_item->ref_count <= 0) |
| 2612 |
– |
delete_conf_item(conf); |
| 2613 |
– |
else |
| 2614 |
– |
{ |
| 2615 |
– |
match_item->illegal = 1; |
| 2616 |
– |
dlinkDelete(&conf->node, *iterator); |
| 2617 |
– |
} |
| 2618 |
– |
} |
| 2619 |
– |
else |
| 2478 |
|
delete_conf_item(conf); |
| 2479 |
|
} |
| 2480 |
|
} |
| 2659 |
|
if (aconf->class_ptr != NULL) |
| 2660 |
|
{ |
| 2661 |
|
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 2662 |
< |
*pingwarn = PingWarning(aclass); |
| 2663 |
< |
return PingFreq(aclass); |
| 2662 |
> |
*pingwarn = aclass->ping_warning; |
| 2663 |
> |
return aclass->ping_freq; |
| 2664 |
|
} |
| 2665 |
|
} |
| 2666 |
|
|
| 2676 |
|
const char * |
| 2677 |
|
get_client_class(struct Client *target_p) |
| 2678 |
|
{ |
| 2679 |
< |
dlink_node *ptr; |
| 2680 |
< |
struct ConfItem *conf; |
| 2823 |
< |
struct AccessItem *aconf; |
| 2679 |
> |
dlink_node *cnode = NULL; |
| 2680 |
> |
struct AccessItem *aconf = NULL; |
| 2681 |
|
|
| 2682 |
< |
if (target_p != NULL && !IsMe(target_p) && |
| 2683 |
< |
target_p->localClient->confs.head != NULL) |
| 2682 |
> |
assert(!IsMe(target_p)); |
| 2683 |
> |
|
| 2684 |
> |
if ((cnode = target_p->localClient->confs.head)) |
| 2685 |
|
{ |
| 2686 |
< |
DLINK_FOREACH(ptr, target_p->localClient->confs.head) |
| 2829 |
< |
{ |
| 2830 |
< |
conf = ptr->data; |
| 2686 |
> |
struct ConfItem *conf = cnode->data; |
| 2687 |
|
|
| 2688 |
< |
if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE || |
| 2689 |
< |
conf->type == OPER_TYPE) |
| 2690 |
< |
{ |
| 2691 |
< |
aconf = (struct AccessItem *) map_to_conf(conf); |
| 2692 |
< |
if (aconf->class_ptr != NULL) |
| 2693 |
< |
return aconf->class_ptr->name; |
| 2838 |
< |
} |
| 2839 |
< |
} |
| 2688 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2689 |
> |
(conf->type == OPER_TYPE)); |
| 2690 |
> |
|
| 2691 |
> |
aconf = map_to_conf(conf); |
| 2692 |
> |
if (aconf->class_ptr != NULL) |
| 2693 |
> |
return aconf->class_ptr->name; |
| 2694 |
|
} |
| 2695 |
|
|
| 2696 |
|
return "default"; |
| 2706 |
|
int |
| 2707 |
|
get_client_ping(struct Client *target_p, int *pingwarn) |
| 2708 |
|
{ |
| 2709 |
< |
int ping; |
| 2710 |
< |
struct ConfItem *conf; |
| 2857 |
< |
dlink_node *nlink; |
| 2709 |
> |
int ping = 0; |
| 2710 |
> |
dlink_node *cnode = NULL; |
| 2711 |
|
|
| 2712 |
< |
if (target_p->localClient->confs.head != NULL) |
| 2713 |
< |
DLINK_FOREACH(nlink, target_p->localClient->confs.head) |
| 2714 |
< |
{ |
| 2862 |
< |
conf = nlink->data; |
| 2712 |
> |
if ((cnode = target_p->localClient->confs.head)) |
| 2713 |
> |
{ |
| 2714 |
> |
struct ConfItem *conf = cnode->data; |
| 2715 |
|
|
| 2716 |
< |
if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2717 |
< |
(conf->type == OPER_TYPE)) |
| 2718 |
< |
{ |
| 2719 |
< |
ping = get_conf_ping(conf, pingwarn); |
| 2720 |
< |
if (ping > 0) |
| 2721 |
< |
return ping; |
| 2722 |
< |
} |
| 2871 |
< |
} |
| 2716 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2717 |
> |
(conf->type == OPER_TYPE)); |
| 2718 |
> |
|
| 2719 |
> |
ping = get_conf_ping(conf, pingwarn); |
| 2720 |
> |
if (ping > 0) |
| 2721 |
> |
return ping; |
| 2722 |
> |
} |
| 2723 |
|
|
| 2724 |
|
*pingwarn = 0; |
| 2725 |
|
return DEFAULT_PINGFREQUENCY; |
| 2757 |
|
{ |
| 2758 |
|
struct ClassItem *aclass = map_to_conf(ptr->data); |
| 2759 |
|
|
| 2760 |
< |
if (!aclass->active && !CurrUserCount(aclass)) |
| 2760 |
> |
if (!aclass->active && !aclass->curr_user_count) |
| 2761 |
|
{ |
| 2762 |
|
destroy_cidr_class(aclass); |
| 2763 |
|
delete_conf_item(ptr->data); |
| 2781 |
|
aclass = map_to_conf(class_default); |
| 2782 |
|
aclass->active = 1; |
| 2783 |
|
DupString(class_default->name, "default"); |
| 2784 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
| 2785 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
| 2786 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
| 2787 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
| 2784 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
| 2785 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
| 2786 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
| 2787 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
| 2788 |
|
|
| 2789 |
|
client_check_cb = register_callback("check_client", check_client); |
| 2790 |
|
} |
| 2799 |
|
get_sendq(struct Client *client_p) |
| 2800 |
|
{ |
| 2801 |
|
unsigned int sendq = DEFAULT_SENDQ; |
| 2802 |
< |
dlink_node *ptr; |
| 2952 |
< |
struct ConfItem *conf; |
| 2802 |
> |
dlink_node *cnode; |
| 2803 |
|
struct ConfItem *class_conf; |
| 2804 |
|
struct ClassItem *aclass; |
| 2805 |
|
struct AccessItem *aconf; |
| 2806 |
|
|
| 2807 |
< |
if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head)) |
| 2807 |
> |
assert(!IsMe(client_p)); |
| 2808 |
> |
|
| 2809 |
> |
if ((cnode = client_p->localClient->confs.head)) |
| 2810 |
|
{ |
| 2811 |
< |
DLINK_FOREACH(ptr, client_p->localClient->confs.head) |
| 2812 |
< |
{ |
| 2813 |
< |
conf = ptr->data; |
| 2814 |
< |
if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE) |
| 2815 |
< |
|| (conf->type == CLIENT_TYPE)) |
| 2816 |
< |
{ |
| 2817 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2818 |
< |
if ((class_conf = aconf->class_ptr) == NULL) |
| 2819 |
< |
continue; |
| 2820 |
< |
aclass = (struct ClassItem *)map_to_conf(class_conf); |
| 2821 |
< |
sendq = MaxSendq(aclass); |
| 2822 |
< |
return sendq; |
| 2823 |
< |
} |
| 2972 |
< |
} |
| 2811 |
> |
struct ConfItem *conf = cnode->data; |
| 2812 |
> |
|
| 2813 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2814 |
> |
(conf->type == OPER_TYPE)); |
| 2815 |
> |
|
| 2816 |
> |
aconf = map_to_conf(conf); |
| 2817 |
> |
|
| 2818 |
> |
if ((class_conf = aconf->class_ptr) == NULL) |
| 2819 |
> |
return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */ |
| 2820 |
> |
|
| 2821 |
> |
aclass = map_to_conf(class_conf); |
| 2822 |
> |
sendq = aclass->max_sendq; |
| 2823 |
> |
return sendq; |
| 2824 |
|
} |
| 2825 |
+ |
|
| 2826 |
|
/* XXX return a default? |
| 2827 |
|
* if here, then there wasn't an attached conf with a sendq |
| 2828 |
|
* that is very bad -Dianora |
| 3309 |
|
{ |
| 3310 |
|
const char *encr = NULL; |
| 3311 |
|
|
| 3312 |
< |
if (password == NULL || aconf->passwd == NULL) |
| 3312 |
> |
if (EmptyString(password) || EmptyString(aconf->passwd)) |
| 3313 |
|
return 0; |
| 3314 |
|
|
| 3315 |
|
if (aconf->flags & CONF_FLAGS_ENCRYPTED) |
| 3316 |
< |
{ |
| 3465 |
< |
/* use first two chars of the password they send in as salt */ |
| 3466 |
< |
/* If the password in the conf is MD5, and ircd is linked |
| 3467 |
< |
* to scrypt on FreeBSD, or the standard crypt library on |
| 3468 |
< |
* glibc Linux, then this code will work fine on generating |
| 3469 |
< |
* the proper encrypted hash for comparison. |
| 3470 |
< |
*/ |
| 3471 |
< |
if (*aconf->passwd) |
| 3472 |
< |
encr = crypt(password, aconf->passwd); |
| 3473 |
< |
else |
| 3474 |
< |
encr = ""; |
| 3475 |
< |
} |
| 3316 |
> |
encr = crypt(password, aconf->passwd); |
| 3317 |
|
else |
| 3318 |
|
encr = password; |
| 3319 |
|
|
| 3486 |
|
dlink_node *ptr = NULL; |
| 3487 |
|
struct CidrItem *cidr; |
| 3488 |
|
|
| 3489 |
< |
if (NumberPerCidr(aclass) <= 0) |
| 3489 |
> |
if (aclass->number_per_cidr <= 0) |
| 3490 |
|
return 0; |
| 3491 |
|
|
| 3492 |
|
if (ip->ss.ss_family == AF_INET) |
| 3493 |
|
{ |
| 3494 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
| 3494 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
| 3495 |
|
return 0; |
| 3496 |
|
|
| 3497 |
|
DLINK_FOREACH(ptr, aclass->list_ipv4.head) |
| 3498 |
|
{ |
| 3499 |
|
cidr = ptr->data; |
| 3500 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
| 3500 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
| 3501 |
|
{ |
| 3502 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
| 3502 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
| 3503 |
|
return -1; |
| 3504 |
|
cidr->number_on_this_cidr++; |
| 3505 |
|
return 0; |
| 3508 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
| 3509 |
|
cidr->number_on_this_cidr = 1; |
| 3510 |
|
cidr->mask = *ip; |
| 3511 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV4(aclass)); |
| 3511 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4); |
| 3512 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4); |
| 3513 |
|
} |
| 3514 |
|
#ifdef IPV6 |
| 3515 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
| 3515 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
| 3516 |
|
{ |
| 3517 |
|
DLINK_FOREACH(ptr, aclass->list_ipv6.head) |
| 3518 |
|
{ |
| 3519 |
|
cidr = ptr->data; |
| 3520 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
| 3520 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
| 3521 |
|
{ |
| 3522 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
| 3522 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
| 3523 |
|
return -1; |
| 3524 |
|
cidr->number_on_this_cidr++; |
| 3525 |
|
return 0; |
| 3528 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
| 3529 |
|
cidr->number_on_this_cidr = 1; |
| 3530 |
|
cidr->mask = *ip; |
| 3531 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV6(aclass)); |
| 3531 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6); |
| 3532 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6); |
| 3533 |
|
} |
| 3534 |
|
#endif |
| 3550 |
|
dlink_node *next_ptr = NULL; |
| 3551 |
|
struct CidrItem *cidr; |
| 3552 |
|
|
| 3553 |
< |
if (NumberPerCidr(aclass) == 0) |
| 3553 |
> |
if (aclass->number_per_cidr == 0) |
| 3554 |
|
return; |
| 3555 |
|
|
| 3556 |
|
if (ip->ss.ss_family == AF_INET) |
| 3557 |
|
{ |
| 3558 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
| 3558 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
| 3559 |
|
return; |
| 3560 |
|
|
| 3561 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
| 3562 |
|
{ |
| 3563 |
|
cidr = ptr->data; |
| 3564 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
| 3564 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
| 3565 |
|
{ |
| 3566 |
|
cidr->number_on_this_cidr--; |
| 3567 |
|
if (cidr->number_on_this_cidr == 0) |
| 3574 |
|
} |
| 3575 |
|
} |
| 3576 |
|
#ifdef IPV6 |
| 3577 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
| 3577 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
| 3578 |
|
{ |
| 3579 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head) |
| 3580 |
|
{ |
| 3581 |
|
cidr = ptr->data; |
| 3582 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
| 3582 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
| 3583 |
|
{ |
| 3584 |
|
cidr->number_on_this_cidr--; |
| 3585 |
|
if (cidr->number_on_this_cidr == 0) |
| 3642 |
|
{ |
| 3643 |
|
struct ClassItem *old_class = map_to_conf(conf); |
| 3644 |
|
|
| 3645 |
< |
if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0) |
| 3645 |
> |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
| 3646 |
|
{ |
| 3647 |
< |
if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0) |
| 3647 |
> |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
| 3648 |
|
rebuild_cidr_list(AF_INET, conf, new_class, |
| 3649 |
|
&old_class->list_ipv4, &new_class->list_ipv4, |
| 3650 |
< |
CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class)); |
| 3650 |
> |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
| 3651 |
|
|
| 3652 |
|
#ifdef IPV6 |
| 3653 |
< |
if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0) |
| 3653 |
> |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
| 3654 |
|
rebuild_cidr_list(AF_INET6, conf, new_class, |
| 3655 |
|
&old_class->list_ipv6, &new_class->list_ipv6, |
| 3656 |
< |
CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class)); |
| 3656 |
> |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
| 3657 |
|
#endif |
| 3658 |
|
} |
| 3659 |
|
|