1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2016 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2018 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
27 |
|
#include "stdinc.h" |
28 |
|
#include "list.h" |
29 |
|
#include "ircd_defs.h" |
30 |
+ |
#include "parse.h" |
31 |
|
#include "conf.h" |
32 |
+ |
#include "conf_cluster.h" |
33 |
+ |
#include "conf_gecos.h" |
34 |
|
#include "conf_pseudo.h" |
35 |
+ |
#include "conf_resv.h" |
36 |
+ |
#include "conf_service.h" |
37 |
+ |
#include "conf_shared.h" |
38 |
|
#include "server.h" |
33 |
– |
#include "resv.h" |
39 |
|
#include "channel.h" |
40 |
|
#include "client.h" |
41 |
|
#include "event.h" |
51 |
|
#include "send.h" |
52 |
|
#include "memory.h" |
53 |
|
#include "res.h" |
49 |
– |
#include "userhost.h" |
54 |
|
#include "user.h" |
55 |
|
#include "channel_mode.h" |
52 |
– |
#include "parse.h" |
56 |
|
#include "misc.h" |
57 |
|
#include "conf_db.h" |
58 |
|
#include "conf_class.h" |
59 |
|
#include "motd.h" |
60 |
|
#include "ipcache.h" |
61 |
|
#include "isupport.h" |
62 |
+ |
#include "whowas.h" |
63 |
|
|
64 |
|
|
65 |
|
struct config_channel_entry ConfigChannel; |
71 |
|
struct conf_parser_context conf_parser_ctx; |
72 |
|
|
73 |
|
/* general conf items link list root, other than k lines etc. */ |
74 |
< |
dlink_list service_items; |
71 |
< |
dlink_list server_items; |
72 |
< |
dlink_list cluster_items; |
74 |
> |
dlink_list connect_items; |
75 |
|
dlink_list operator_items; |
74 |
– |
dlink_list shared_items; |
75 |
– |
dlink_list gecos_items; |
76 |
– |
dlink_list nresv_items; |
77 |
– |
dlink_list cresv_items; |
76 |
|
|
77 |
|
extern unsigned int lineno; |
78 |
|
extern char linebuf[]; |
134 |
|
{ |
135 |
|
switch (type) |
136 |
|
{ |
139 |
– |
case CONF_XLINE: |
140 |
– |
return &gecos_items; |
141 |
– |
break; |
142 |
– |
case CONF_SHARED: |
143 |
– |
return &shared_items; |
144 |
– |
break; |
145 |
– |
case CONF_NRESV: |
146 |
– |
return &nresv_items; |
147 |
– |
break; |
148 |
– |
case CONF_CRESV: |
149 |
– |
return &cresv_items; |
150 |
– |
break; |
137 |
|
case CONF_OPER: |
138 |
|
return &operator_items; |
139 |
|
break; |
140 |
|
case CONF_SERVER: |
141 |
< |
return &server_items; |
156 |
< |
break; |
157 |
< |
case CONF_SERVICE: |
158 |
< |
return &service_items; |
159 |
< |
break; |
160 |
< |
case CONF_CLUSTER: |
161 |
< |
return &cluster_items; |
141 |
> |
return &connect_items; |
142 |
|
break; |
143 |
|
default: |
144 |
|
return NULL; |
203 |
|
free_dlink_node(node); |
204 |
|
} |
205 |
|
|
226 |
– |
DLINK_FOREACH_SAFE(node, node_next, conf->exempt_list.head) |
227 |
– |
{ |
228 |
– |
struct exempt *exptr = node->data; |
229 |
– |
|
230 |
– |
dlinkDelete(node, &conf->exempt_list); |
231 |
– |
xfree(exptr->name); |
232 |
– |
xfree(exptr->user); |
233 |
– |
xfree(exptr->host); |
234 |
– |
xfree(exptr); |
235 |
– |
} |
236 |
– |
|
206 |
|
xfree(conf); |
207 |
|
} |
208 |
|
|
217 |
|
attach_iline(struct Client *client_p, struct MaskItem *conf) |
218 |
|
{ |
219 |
|
const struct ClassItem *const class = conf->class; |
251 |
– |
struct ip_entry *ip_found; |
220 |
|
int a_limit_reached = 0; |
253 |
– |
unsigned int local = 0, global = 0, ident = 0; |
221 |
|
|
222 |
< |
ip_found = ipcache_find_or_add_address(&client_p->connection->ip); |
223 |
< |
ip_found->count++; |
222 |
> |
struct ip_entry *ipcache = ipcache_find_or_add_address(&client_p->ip); |
223 |
> |
++ipcache->count_local; |
224 |
|
AddFlag(client_p, FLAGS_IPHASH); |
225 |
|
|
259 |
– |
userhost_count(client_p->username, client_p->host, |
260 |
– |
&global, &local, &ident); |
261 |
– |
|
262 |
– |
/* XXX blah. go down checking the various silly limits |
263 |
– |
* setting a_limit_reached if any limit is reached. |
264 |
– |
* - Dianora |
265 |
– |
*/ |
226 |
|
if (class->max_total && class->ref_count >= class->max_total) |
227 |
|
a_limit_reached = 1; |
228 |
< |
else if (class->max_perip && ip_found->count > class->max_perip) |
269 |
< |
a_limit_reached = 1; |
270 |
< |
else if (class->max_local && local >= class->max_local) |
228 |
> |
else if (class->max_perip_local && ipcache->count_local > class->max_perip_local) |
229 |
|
a_limit_reached = 1; |
230 |
< |
else if (class->max_global && global >= class->max_global) |
231 |
< |
a_limit_reached = 1; |
274 |
< |
else if (class->max_ident && ident >= class->max_ident && |
275 |
< |
client_p->username[0] != '~') |
230 |
> |
else if (class->max_perip_global && |
231 |
> |
(ipcache->count_local + ipcache->count_remote) > class->max_perip_global) |
232 |
|
a_limit_reached = 1; |
233 |
|
|
234 |
|
if (a_limit_reached) |
240 |
|
"but you have exceed_limit = yes;"); |
241 |
|
} |
242 |
|
|
243 |
< |
return attach_conf(client_p, conf); |
243 |
> |
return conf_attach(client_p, conf); |
244 |
|
} |
245 |
|
|
246 |
|
/* verify_access() |
257 |
|
if (HasFlag(client_p, FLAGS_GOTID)) |
258 |
|
{ |
259 |
|
conf = find_address_conf(client_p->host, client_p->username, |
260 |
< |
&client_p->connection->ip, |
261 |
< |
client_p->connection->aftype, |
260 |
> |
&client_p->ip, |
261 |
> |
client_p->ip.ss.ss_family, |
262 |
|
client_p->connection->password); |
263 |
|
} |
264 |
|
else |
267 |
|
|
268 |
|
strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1); |
269 |
|
conf = find_address_conf(client_p->host, non_ident, |
270 |
< |
&client_p->connection->ip, |
271 |
< |
client_p->connection->aftype, |
270 |
> |
&client_p->ip, |
271 |
> |
client_p->ip.ss.ss_family, |
272 |
|
client_p->connection->password); |
273 |
|
} |
274 |
|
|
330 |
|
case TOO_MANY: |
331 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
332 |
|
"Too many on IP for %s (%s).", |
333 |
< |
get_client_name(source_p, SHOW_IP), |
333 |
> |
client_get_name(source_p, SHOW_IP), |
334 |
|
source_p->sockhost); |
335 |
|
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
336 |
< |
get_client_name(source_p, SHOW_IP)); |
336 |
> |
client_get_name(source_p, SHOW_IP)); |
337 |
|
++ServerStats.is_ref; |
338 |
|
exit_client(source_p, "No more connections allowed on that IP"); |
339 |
|
break; |
341 |
|
case I_LINE_FULL: |
342 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
343 |
|
"auth {} block is full for %s (%s).", |
344 |
< |
get_client_name(source_p, SHOW_IP), |
344 |
> |
client_get_name(source_p, SHOW_IP), |
345 |
|
source_p->sockhost); |
346 |
|
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
347 |
< |
get_client_name(source_p, SHOW_IP)); |
347 |
> |
client_get_name(source_p, SHOW_IP)); |
348 |
|
++ServerStats.is_ref; |
349 |
|
exit_client(source_p, "No more connections allowed in your connection class"); |
350 |
|
break; |
353 |
|
/* jdc - lists server name & port connections are on */ |
354 |
|
/* a purely cosmetical change */ |
355 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE, |
356 |
< |
"Unauthorized client connection from %s [%s] on [%s/%u].", |
357 |
< |
get_client_name(source_p, SHOW_IP), |
402 |
< |
source_p->sockhost, |
356 |
> |
"Unauthorized client connection from %s on [%s/%u].", |
357 |
> |
client_get_name(source_p, SHOW_IP), |
358 |
|
source_p->connection->listener->name, |
359 |
|
source_p->connection->listener->port); |
360 |
|
ilog(LOG_TYPE_IRCD, "Unauthorized client connection from %s on [%s/%u].", |
361 |
< |
get_client_name(source_p, SHOW_IP), |
361 |
> |
client_get_name(source_p, SHOW_IP), |
362 |
|
source_p->connection->listener->name, |
363 |
|
source_p->connection->listener->port); |
364 |
|
|
379 |
|
return !(i < 0); |
380 |
|
} |
381 |
|
|
382 |
< |
/* detach_conf() |
383 |
< |
* |
384 |
< |
* inputs - pointer to client to detach |
385 |
< |
* - type of conf to detach |
431 |
< |
* output - 0 for success, -1 for failure |
432 |
< |
* side effects - Disassociate configuration from the client. |
433 |
< |
* Also removes a class from the list if marked for deleting. |
382 |
> |
/*! \brief Disassociate configuration from the client. Also removes a class |
383 |
> |
* from the list if marked for deleting. |
384 |
> |
* \param client_p Client to operate on |
385 |
> |
* \param type Type of conf to detach |
386 |
|
*/ |
387 |
|
void |
388 |
< |
detach_conf(struct Client *client_p, enum maskitem_type type) |
388 |
> |
conf_detach(struct Client *client_p, enum maskitem_type type) |
389 |
|
{ |
390 |
< |
dlink_node *node = NULL, *node_next = NULL; |
390 |
> |
dlink_node *node, *node_next; |
391 |
|
|
392 |
|
DLINK_FOREACH_SAFE(node, node_next, client_p->connection->confs.head) |
393 |
|
{ |
404 |
|
free_dlink_node(node); |
405 |
|
|
406 |
|
if (conf->type == CONF_CLIENT) |
407 |
< |
remove_from_cidr_check(&client_p->connection->ip, conf->class); |
407 |
> |
remove_from_cidr_check(&client_p->ip, conf->class); |
408 |
|
|
409 |
|
if (--conf->class->ref_count == 0 && conf->class->active == 0) |
410 |
|
{ |
417 |
|
} |
418 |
|
} |
419 |
|
|
420 |
< |
/* attach_conf() |
421 |
< |
* |
422 |
< |
* inputs - client pointer |
423 |
< |
* - conf pointer |
424 |
< |
* output - |
473 |
< |
* side effects - Associate a specific configuration entry to a *local* |
474 |
< |
* client (this is the one which used in accepting the |
475 |
< |
* connection). Note, that this automatically changes the |
476 |
< |
* attachment if there was an old one... |
420 |
> |
/*! \brief Associate a specific configuration entry to a *local* client (this |
421 |
> |
* is the one which used in accepting the connection). Note, that this |
422 |
> |
* automatically changes the attachment if there was an old one. |
423 |
> |
* \param client_p Client to attach the conf to |
424 |
> |
* \param conf Configuration record to attach |
425 |
|
*/ |
426 |
|
int |
427 |
< |
attach_conf(struct Client *client_p, struct MaskItem *conf) |
427 |
> |
conf_attach(struct Client *client_p, struct MaskItem *conf) |
428 |
|
{ |
429 |
|
if (dlinkFind(&client_p->connection->confs, conf)) |
430 |
|
return 1; |
431 |
|
|
432 |
|
if (conf->type == CONF_CLIENT) |
433 |
|
if (cidr_limit_reached(IsConfExemptLimits(conf), |
434 |
< |
&client_p->connection->ip, conf->class)) |
434 |
> |
&client_p->ip, conf->class)) |
435 |
|
return TOO_MANY; /* Already at maximum allowed */ |
436 |
|
|
437 |
|
conf->class->ref_count++; |
442 |
|
return 0; |
443 |
|
} |
444 |
|
|
497 |
– |
/* attach_connect_block() |
498 |
– |
* |
499 |
– |
* inputs - pointer to server to attach |
500 |
– |
* - name of server |
501 |
– |
* - hostname of server |
502 |
– |
* output - true (1) if both are found, otherwise return false (0) |
503 |
– |
* side effects - find connect block and attach them to connecting client |
504 |
– |
*/ |
505 |
– |
int |
506 |
– |
attach_connect_block(struct Client *client_p, const char *name, |
507 |
– |
const char *host) |
508 |
– |
{ |
509 |
– |
dlink_node *node = NULL; |
510 |
– |
|
511 |
– |
assert(host); |
512 |
– |
|
513 |
– |
DLINK_FOREACH(node, server_items.head) |
514 |
– |
{ |
515 |
– |
struct MaskItem *conf = node->data; |
516 |
– |
|
517 |
– |
if (match(conf->name, name) || match(conf->host, host)) |
518 |
– |
continue; |
519 |
– |
|
520 |
– |
attach_conf(client_p, conf); |
521 |
– |
return 1; |
522 |
– |
} |
523 |
– |
|
524 |
– |
return 0; |
525 |
– |
} |
526 |
– |
|
445 |
|
/* find_conf_name() |
446 |
|
* |
447 |
|
* inputs - pointer to conf link list to search |
470 |
|
return NULL; |
471 |
|
} |
472 |
|
|
473 |
< |
/* find_matching_name_conf() |
474 |
< |
* |
475 |
< |
* inputs - type of link list to look in |
558 |
< |
* - pointer to name string to find |
559 |
< |
* - pointer to user |
560 |
< |
* - pointer to host |
561 |
< |
* - optional flags to match on as well |
562 |
< |
* output - NULL or pointer to found struct MaskItem |
563 |
< |
* side effects - looks for a match on name field |
473 |
> |
/*! \brief Find a connect {} conf that has a name that matches \a name. |
474 |
> |
* \param name Name to match |
475 |
> |
* \param compare Pointer to function to be used for string matching |
476 |
|
*/ |
477 |
|
struct MaskItem * |
478 |
< |
find_matching_name_conf(enum maskitem_type type, const char *name, const char *user, |
567 |
< |
const char *host, unsigned int flags) |
478 |
> |
connect_find(const char *name, int (*compare)(const char *, const char *)) |
479 |
|
{ |
480 |
< |
dlink_node *node = NULL; |
570 |
< |
dlink_list *list = map_to_list(type); |
571 |
< |
struct MaskItem *conf = NULL; |
480 |
> |
dlink_node *node; |
481 |
|
|
482 |
< |
switch (type) |
482 |
> |
DLINK_FOREACH(node, connect_items.head) |
483 |
|
{ |
484 |
< |
case CONF_SERVICE: |
576 |
< |
DLINK_FOREACH(node, list->head) |
577 |
< |
{ |
578 |
< |
conf = node->data; |
579 |
< |
|
580 |
< |
if (EmptyString(conf->name)) |
581 |
< |
continue; |
582 |
< |
if (name && !irccmp(name, conf->name)) |
583 |
< |
return conf; |
584 |
< |
} |
585 |
< |
break; |
586 |
< |
|
587 |
< |
case CONF_XLINE: |
588 |
< |
case CONF_SHARED: |
589 |
< |
case CONF_NRESV: |
590 |
< |
case CONF_CRESV: |
591 |
< |
DLINK_FOREACH(node, list->head) |
592 |
< |
{ |
593 |
< |
conf = node->data; |
594 |
< |
|
595 |
< |
if (EmptyString(conf->name)) |
596 |
< |
continue; |
597 |
< |
if (name && !match(conf->name, name)) |
598 |
< |
{ |
599 |
< |
if ((user == NULL && (host == NULL))) |
600 |
< |
return conf; |
601 |
< |
if ((conf->modes & flags) != flags) |
602 |
< |
continue; |
603 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
604 |
< |
return conf; |
605 |
< |
if (!match(conf->user, user) && !match(conf->host, host)) |
606 |
< |
return conf; |
607 |
< |
} |
608 |
< |
} |
609 |
< |
break; |
610 |
< |
|
611 |
< |
case CONF_SERVER: |
612 |
< |
DLINK_FOREACH(node, list->head) |
613 |
< |
{ |
614 |
< |
conf = node->data; |
615 |
< |
|
616 |
< |
if (name && !match(name, conf->name)) |
617 |
< |
return conf; |
618 |
< |
if (host && !match(host, conf->host)) |
619 |
< |
return conf; |
620 |
< |
} |
621 |
< |
break; |
484 |
> |
struct MaskItem *conf = node->data; |
485 |
|
|
486 |
< |
default: |
487 |
< |
break; |
486 |
> |
if (!compare(name, conf->name)) |
487 |
> |
return conf; |
488 |
|
} |
489 |
+ |
|
490 |
|
return NULL; |
491 |
|
} |
492 |
|
|
500 |
|
* side effects - looks for an exact match on name field |
501 |
|
*/ |
502 |
|
struct MaskItem * |
503 |
< |
find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name, |
640 |
< |
const char *user, const char *host) |
503 |
> |
operator_find(const struct Client *who, const char *name) |
504 |
|
{ |
505 |
|
dlink_node *node = NULL; |
643 |
– |
dlink_list *list = map_to_list(type); |
644 |
– |
struct MaskItem *conf = NULL; |
506 |
|
|
507 |
< |
switch(type) |
507 |
> |
DLINK_FOREACH(node, operator_items.head) |
508 |
|
{ |
509 |
< |
case CONF_XLINE: |
649 |
< |
case CONF_SHARED: |
650 |
< |
case CONF_NRESV: |
651 |
< |
case CONF_CRESV: |
652 |
< |
|
653 |
< |
DLINK_FOREACH(node, list->head) |
654 |
< |
{ |
655 |
< |
conf = node->data; |
656 |
< |
|
657 |
< |
if (EmptyString(conf->name)) |
658 |
< |
continue; |
659 |
< |
|
660 |
< |
if (irccmp(conf->name, name) == 0) |
661 |
< |
{ |
662 |
< |
if ((user == NULL && (host == NULL))) |
663 |
< |
return conf; |
664 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
665 |
< |
return conf; |
666 |
< |
if (!match(conf->user, user) && !match(conf->host, host)) |
667 |
< |
return conf; |
668 |
< |
} |
669 |
< |
} |
670 |
< |
break; |
509 |
> |
struct MaskItem *conf = node->data; |
510 |
|
|
511 |
< |
case CONF_OPER: |
673 |
< |
DLINK_FOREACH(node, list->head) |
511 |
> |
if (!irccmp(conf->name, name)) |
512 |
|
{ |
513 |
< |
conf = node->data; |
514 |
< |
|
677 |
< |
if (EmptyString(conf->name)) |
678 |
< |
continue; |
513 |
> |
if (!who) |
514 |
> |
return conf; |
515 |
|
|
516 |
< |
if (!irccmp(conf->name, name)) |
516 |
> |
if (!match(conf->user, who->username)) |
517 |
|
{ |
518 |
< |
if (!who) |
683 |
< |
return conf; |
684 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
685 |
< |
return NULL; |
686 |
< |
if (!match(conf->user, who->username)) |
518 |
> |
switch (conf->htype) |
519 |
|
{ |
520 |
< |
switch (conf->htype) |
521 |
< |
{ |
522 |
< |
case HM_HOST: |
523 |
< |
if (!match(conf->host, who->host) || !match(conf->host, who->sockhost)) |
520 |
> |
case HM_HOST: |
521 |
> |
if (!match(conf->host, who->host) || !match(conf->host, who->sockhost)) |
522 |
> |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
523 |
> |
return conf; |
524 |
> |
break; |
525 |
> |
case HM_IPV4: |
526 |
> |
if (who->ip.ss.ss_family == AF_INET) |
527 |
> |
if (match_ipv4(&who->ip, &conf->addr, conf->bits)) |
528 |
|
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
529 |
|
return conf; |
530 |
< |
break; |
531 |
< |
case HM_IPV4: |
532 |
< |
if (who->connection->aftype == AF_INET) |
533 |
< |
if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits)) |
534 |
< |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
535 |
< |
return conf; |
536 |
< |
break; |
537 |
< |
case HM_IPV6: |
538 |
< |
if (who->connection->aftype == AF_INET6) |
703 |
< |
if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits)) |
704 |
< |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
705 |
< |
return conf; |
706 |
< |
break; |
707 |
< |
default: |
708 |
< |
assert(0); |
709 |
< |
} |
530 |
> |
break; |
531 |
> |
case HM_IPV6: |
532 |
> |
if (who->ip.ss.ss_family == AF_INET6) |
533 |
> |
if (match_ipv6(&who->ip, &conf->addr, conf->bits)) |
534 |
> |
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
535 |
> |
return conf; |
536 |
> |
break; |
537 |
> |
default: |
538 |
> |
assert(0); |
539 |
|
} |
540 |
|
} |
541 |
|
} |
713 |
– |
|
714 |
– |
break; |
715 |
– |
|
716 |
– |
case CONF_SERVER: |
717 |
– |
DLINK_FOREACH(node, list->head) |
718 |
– |
{ |
719 |
– |
conf = node->data; |
720 |
– |
|
721 |
– |
if (EmptyString(conf->name)) |
722 |
– |
continue; |
723 |
– |
|
724 |
– |
if (name == NULL) |
725 |
– |
{ |
726 |
– |
if (EmptyString(conf->host)) |
727 |
– |
continue; |
728 |
– |
if (irccmp(conf->host, host) == 0) |
729 |
– |
return conf; |
730 |
– |
} |
731 |
– |
else if (irccmp(conf->name, name) == 0) |
732 |
– |
return conf; |
733 |
– |
} |
734 |
– |
|
735 |
– |
break; |
736 |
– |
|
737 |
– |
default: |
738 |
– |
break; |
542 |
|
} |
543 |
|
|
544 |
|
return NULL; |
582 |
|
ConfigChannel.invite_client_count = 10; |
583 |
|
ConfigChannel.invite_client_time = 300; |
584 |
|
ConfigChannel.invite_delay_channel = 5; |
585 |
+ |
ConfigChannel.invite_expire_time = 1800; |
586 |
|
ConfigChannel.knock_client_count = 1; |
587 |
|
ConfigChannel.knock_client_time = 300; |
588 |
|
ConfigChannel.knock_delay_channel = 60; |
589 |
|
ConfigChannel.max_channels = 25; |
590 |
< |
ConfigChannel.max_bans = 25; |
590 |
> |
ConfigChannel.max_invites = 20; |
591 |
> |
ConfigChannel.max_bans = 100; |
592 |
> |
ConfigChannel.max_bans_large = 500; |
593 |
|
ConfigChannel.default_join_flood_count = 18; |
594 |
|
ConfigChannel.default_join_flood_time = 6; |
595 |
|
|
605 |
|
ConfigGeneral.away_count = 2; |
606 |
|
ConfigGeneral.away_time = 10; |
607 |
|
ConfigGeneral.max_watch = 50; |
608 |
+ |
ConfigGeneral.whowas_history_length = 15000; |
609 |
|
ConfigGeneral.cycle_on_host_change = 1; |
610 |
|
ConfigGeneral.dline_min_cidr = 16; |
611 |
|
ConfigGeneral.dline_min_cidr6 = 48; |
617 |
|
ConfigGeneral.disable_auth = 0; |
618 |
|
ConfigGeneral.kill_chase_time_limit = 90; |
619 |
|
ConfigGeneral.default_floodcount = 8; |
620 |
+ |
ConfigGeneral.default_floodtime = 1; |
621 |
|
ConfigGeneral.failed_oper_notice = 1; |
622 |
|
ConfigGeneral.dots_in_ident = 0; |
623 |
|
ConfigGeneral.min_nonwildcard = 4; |
638 |
|
ConfigGeneral.stats_P_oper_only = 0; |
639 |
|
ConfigGeneral.stats_u_oper_only = 0; |
640 |
|
ConfigGeneral.caller_id_wait = 60; |
641 |
< |
ConfigGeneral.opers_bypass_callerid = 0; |
641 |
> |
ConfigGeneral.opers_bypass_callerid = 1; |
642 |
|
ConfigGeneral.pace_wait = 10; |
643 |
|
ConfigGeneral.pace_wait_simple = 1; |
644 |
|
ConfigGeneral.short_motd = 0; |
672 |
|
static void |
673 |
|
read_conf(FILE *file) |
674 |
|
{ |
675 |
< |
lineno = 0; |
675 |
> |
lineno = 1; |
676 |
|
|
677 |
|
set_default_conf(); /* Set default values prior to conf parsing */ |
678 |
|
conf_parser_ctx.pass = 1; |
684 |
|
yyparse(); /* Load the values from the conf */ |
685 |
|
validate_conf(); /* Check to make sure some values are still okay. */ |
686 |
|
/* Some global values are also loaded here. */ |
687 |
+ |
whowas_trim(); /* Attempt to trim whowas list if necessary */ |
688 |
|
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
689 |
|
} |
690 |
|
|
698 |
|
conf_rehash(int sig) |
699 |
|
{ |
700 |
|
if (sig) |
701 |
+ |
{ |
702 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
703 |
|
"Got signal SIGHUP, reloading configuration file(s)"); |
704 |
+ |
ilog(LOG_TYPE_IRCD, "Got signal SIGHUP, reloading configuration file(s)"); |
705 |
+ |
} |
706 |
|
|
707 |
|
restart_resolver(); |
708 |
|
|
788 |
|
return 0; |
789 |
|
} |
790 |
|
|
979 |
– |
/* expire_tklines() |
980 |
– |
* |
981 |
– |
* inputs - tkline list pointer |
982 |
– |
* output - NONE |
983 |
– |
* side effects - expire tklines |
984 |
– |
*/ |
985 |
– |
static void |
986 |
– |
expire_tklines(dlink_list *list) |
987 |
– |
{ |
988 |
– |
dlink_node *node = NULL, *node_next = NULL; |
989 |
– |
|
990 |
– |
DLINK_FOREACH_SAFE(node, node_next, list->head) |
991 |
– |
{ |
992 |
– |
struct MaskItem *conf = node->data; |
993 |
– |
|
994 |
– |
if (!conf->until || conf->until > CurrentTime) |
995 |
– |
continue; |
996 |
– |
|
997 |
– |
if (ConfigGeneral.tkline_expire_notices) |
998 |
– |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired", |
999 |
– |
(conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name); |
1000 |
– |
conf_free(conf); |
1001 |
– |
} |
1002 |
– |
} |
1003 |
– |
|
791 |
|
/* cleanup_tklines() |
792 |
|
* |
793 |
|
* inputs - NONE |
799 |
|
cleanup_tklines(void *unused) |
800 |
|
{ |
801 |
|
hostmask_expire_temporary(); |
802 |
< |
expire_tklines(&gecos_items); |
803 |
< |
expire_tklines(&nresv_items); |
1017 |
< |
expire_tklines(&cresv_items); |
802 |
> |
gecos_expire(); |
803 |
> |
resv_expire(); |
804 |
|
} |
805 |
|
|
806 |
|
/* oper_privs_as_string() |
809 |
|
* output - pointer to static string showing oper privs |
810 |
|
* side effects - return as string, the oper privs as derived from port |
811 |
|
*/ |
812 |
< |
static const struct oper_privs |
812 |
> |
static const struct oper_flags |
813 |
|
{ |
814 |
|
const unsigned int flag; |
815 |
|
const unsigned char c; |
816 |
< |
} flag_list[] = { |
816 |
> |
} flag_table[] = { |
817 |
|
{ OPER_FLAG_ADMIN, 'A' }, |
818 |
|
{ OPER_FLAG_CLOSE, 'B' }, |
819 |
|
{ OPER_FLAG_CONNECT, 'C' }, |
846 |
|
}; |
847 |
|
|
848 |
|
const char * |
849 |
< |
oper_privs_as_string(const unsigned int port) |
849 |
> |
oper_privs_as_string(const unsigned int flags) |
850 |
|
{ |
851 |
< |
static char privs_out[IRCD_BUFSIZE]; |
852 |
< |
char *privs_ptr = privs_out; |
851 |
> |
static char buf[sizeof(flag_table) / sizeof(flag_table[0])]; |
852 |
> |
char *p = buf; |
853 |
|
|
854 |
< |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
855 |
< |
if (port & opriv->flag) |
856 |
< |
*privs_ptr++ = opriv->c; |
854 |
> |
for (const struct oper_flags *tab = flag_table; tab->flag; ++tab) |
855 |
> |
if (flags & tab->flag) |
856 |
> |
*p++ = tab->c; |
857 |
|
|
858 |
< |
if (privs_ptr == privs_out) |
859 |
< |
*privs_ptr++ = '0'; |
858 |
> |
if (p == buf) |
859 |
> |
*p++ = '0'; |
860 |
|
|
861 |
< |
*privs_ptr = '\0'; |
861 |
> |
*p = '\0'; |
862 |
|
|
863 |
< |
return privs_out; |
863 |
> |
return buf; |
864 |
|
} |
865 |
|
|
866 |
|
/* |
916 |
|
{ |
917 |
|
dlink_node *node = NULL, *node_next = NULL; |
918 |
|
dlink_list *free_items [] = { |
919 |
< |
&server_items, &operator_items, |
1134 |
< |
&shared_items, &gecos_items, |
1135 |
< |
&nresv_items, &cluster_items, &service_items, &cresv_items, NULL |
919 |
> |
&connect_items, &operator_items, NULL |
920 |
|
}; |
921 |
|
|
922 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
932 |
|
struct MaskItem *conf = node->data; |
933 |
|
|
934 |
|
conf->active = 0; |
935 |
+ |
dlinkDelete(&conf->node, *iterator); |
936 |
|
|
937 |
< |
if (!IsConfDatabase(conf)) |
938 |
< |
{ |
1154 |
< |
dlinkDelete(&conf->node, *iterator); |
1155 |
< |
|
1156 |
< |
if (!conf->ref_count) |
1157 |
< |
conf_free(conf); |
1158 |
< |
} |
937 |
> |
if (!conf->ref_count) |
938 |
> |
conf_free(conf); |
939 |
|
} |
940 |
|
} |
941 |
|
|
1162 |
– |
motd_clear(); |
1163 |
– |
|
942 |
|
/* |
943 |
|
* Don't delete the class table, rather mark all entries for deletion. |
944 |
|
* The table is cleaned up by class_delete_marked. - avalon |
947 |
|
|
948 |
|
clear_out_address_conf(); |
949 |
|
|
950 |
< |
/* Clean out module paths */ |
951 |
< |
mod_clear_paths(); |
950 |
> |
modules_conf_clear(); /* Clear modules {} items */ |
951 |
> |
|
952 |
> |
motd_clear(); /* Clear motd {} items and re-cache default motd */ |
953 |
|
|
954 |
< |
pseudo_clear(); |
954 |
> |
cluster_clear(); /* Clear cluster {} items */ |
955 |
> |
|
956 |
> |
gecos_clear(); /* Clear gecos {} items */ |
957 |
> |
|
958 |
> |
resv_clear(); /* Clear resv {} items */ |
959 |
> |
|
960 |
> |
service_clear(); /* Clear service {} items */ |
961 |
> |
|
962 |
> |
shared_clear(); /* Clear shared {} items */ |
963 |
> |
|
964 |
> |
pseudo_clear(); /* Clear pseudo {} items */ |
965 |
|
|
966 |
|
/* Clean out ConfigServerInfo */ |
967 |
|
xfree(ConfigServerInfo.description); |
970 |
|
ConfigServerInfo.network_name = NULL; |
971 |
|
xfree(ConfigServerInfo.network_desc); |
972 |
|
ConfigServerInfo.network_desc = NULL; |
1184 |
– |
|
973 |
|
xfree(ConfigServerInfo.rsa_private_key_file); |
974 |
|
ConfigServerInfo.rsa_private_key_file = NULL; |
975 |
|
xfree(ConfigServerInfo.ssl_certificate_file); |
991 |
|
xfree(ConfigAdminInfo.description); |
992 |
|
ConfigAdminInfo.description = NULL; |
993 |
|
|
994 |
+ |
/* Clean out ConfigServerHide */ |
995 |
|
xfree(ConfigServerHide.flatten_links_file); |
996 |
|
ConfigServerHide.flatten_links_file = NULL; |
997 |
+ |
xfree(ConfigServerHide.hidden_name); |
998 |
+ |
ConfigServerHide.hidden_name = NULL; |
999 |
|
|
1000 |
|
/* Clean out listeners */ |
1001 |
|
listener_close_marked(); |
1009 |
|
if (cold) |
1010 |
|
{ |
1011 |
|
ilog(LOG_TYPE_IRCD, "Error while initializing TLS"); |
1012 |
< |
exit(-1); |
1012 |
> |
exit(EXIT_FAILURE); |
1013 |
|
} |
1014 |
|
else |
1015 |
|
{ |
1081 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%u", |
1082 |
|
ConfigChannel.max_channels); |
1083 |
|
isupport_add("CHANLIMIT", chanlimit, -1); |
1084 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORST"); |
1084 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstuCLMNORST"); |
1085 |
|
isupport_add("CHANNELLEN", NULL, CHANNELLEN); |
1086 |
|
isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1087 |
|
isupport_add("CHANMODES", chanmodes, -1); |
1297 |
– |
|
1298 |
– |
/* |
1299 |
– |
* message_locale may have changed. rebuild isupport since it relies |
1300 |
– |
* on strlen(form_str(RPL_ISUPPORT)) |
1301 |
– |
*/ |
1302 |
– |
isupport_rebuild(); |
1088 |
|
} |
1089 |
|
|
1090 |
|
/* conf_add_class_to_conf() |
1120 |
|
void |
1121 |
|
yyerror(const char *msg) |
1122 |
|
{ |
1338 |
– |
char newlinebuf[IRCD_BUFSIZE]; |
1339 |
– |
|
1123 |
|
if (conf_parser_ctx.pass != 1) |
1124 |
|
return; |
1125 |
|
|
1126 |
< |
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1126 |
> |
const char *p = stripws(linebuf); |
1127 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1128 |
|
"\"%s\", line %u: %s: %s", |
1129 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1129 |
> |
conffilebuf, lineno, msg, p); |
1130 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1131 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1131 |
> |
conffilebuf, lineno, msg, p); |
1132 |
|
} |
1133 |
|
|
1134 |
|
void |
1135 |
|
conf_error_report(const char *msg) |
1136 |
|
{ |
1137 |
< |
char newlinebuf[IRCD_BUFSIZE]; |
1355 |
< |
|
1356 |
< |
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1137 |
> |
const char *p = stripws(linebuf); |
1138 |
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1139 |
|
"\"%s\", line %u: %s: %s", |
1140 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1140 |
> |
conffilebuf, lineno, msg, p); |
1141 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1142 |
< |
conffilebuf, lineno + 1, msg, newlinebuf); |
1142 |
> |
conffilebuf, lineno, msg, p); |
1143 |
|
} |
1144 |
|
|
1145 |
|
/* |
1152 |
|
* side effects - none |
1153 |
|
* Originally written by Dianora (Diane, db@db.net) |
1154 |
|
*/ |
1155 |
< |
time_t |
1155 |
> |
uintmax_t |
1156 |
|
valid_tkline(const char *data, const int minutes) |
1157 |
|
{ |
1158 |
|
const unsigned char *p = (const unsigned char *)data; |
1159 |
|
unsigned char tmpch = '\0'; |
1160 |
< |
time_t result = 0; |
1160 |
> |
uintmax_t result = 0; |
1161 |
|
|
1162 |
|
while ((tmpch = *p++)) |
1163 |
|
{ |
1233 |
|
* side effects - NOTICE is given to source_p if warn is 1 |
1234 |
|
*/ |
1235 |
|
int |
1236 |
< |
valid_wild_card(struct Client *source_p, int count, ...) |
1236 |
> |
valid_wild_card(int count, ...) |
1237 |
|
{ |
1238 |
|
unsigned char tmpch = '\0'; |
1239 |
|
unsigned int nonwild = 0; |
1276 |
|
} |
1277 |
|
} |
1278 |
|
|
1498 |
– |
if (IsClient(source_p)) |
1499 |
– |
sendto_one_notice(source_p, &me, |
1500 |
– |
":Please include at least %u non-wildcard characters with the mask", |
1501 |
– |
ConfigGeneral.min_nonwildcard); |
1279 |
|
va_end(args); |
1280 |
|
return 0; |
1281 |
|
} |
1392 |
|
int |
1393 |
|
parse_aline(const char *cmd, struct Client *source_p, |
1394 |
|
int parc, char **parv, |
1395 |
< |
int parse_flags, char **up_p, char **h_p, time_t *tkline_time, |
1395 |
> |
char **up_p, char **h_p, uintmax_t *tkline_time, |
1396 |
|
char **target_server, char **reason) |
1397 |
|
{ |
1398 |
< |
int found_tkline_time=0; |
1398 |
> |
uintmax_t found_tkline_time=0; |
1399 |
|
static char default_reason[] = CONF_NOREASON; |
1400 |
|
static char user[USERLEN*4+1]; |
1401 |
|
static char host[HOSTLEN*4+1]; |
1472 |
|
} |
1473 |
|
} |
1474 |
|
|
1698 |
– |
if (h_p) |
1699 |
– |
{ |
1700 |
– |
if (strchr(user, '!')) |
1701 |
– |
{ |
1702 |
– |
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1703 |
– |
return 0; |
1704 |
– |
} |
1705 |
– |
|
1706 |
– |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p)) |
1707 |
– |
return 0; |
1708 |
– |
} |
1709 |
– |
else |
1710 |
– |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p)) |
1711 |
– |
return 0; |
1712 |
– |
|
1475 |
|
if (reason) |
1476 |
|
{ |
1477 |
|
if (parc && !EmptyString(*parv)) |
1507 |
|
} |
1508 |
|
|
1509 |
|
/* |
1748 |
– |
* cluster_a_line |
1749 |
– |
* |
1750 |
– |
* inputs - client sending the cluster |
1751 |
– |
* - command name "KLINE" "XLINE" etc. |
1752 |
– |
* - capab -- CAPAB_KLN etc. from server.h |
1753 |
– |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
1754 |
– |
* - pattern and args to send along |
1755 |
– |
* output - none |
1756 |
– |
* side effects - Take source_p send the pattern with args given |
1757 |
– |
* along to all servers that match capab and cluster type |
1758 |
– |
*/ |
1759 |
– |
void |
1760 |
– |
cluster_a_line(struct Client *source_p, const char *command, unsigned int capab, |
1761 |
– |
unsigned int cluster_type, const char *pattern, ...) |
1762 |
– |
{ |
1763 |
– |
va_list args; |
1764 |
– |
char buffer[IRCD_BUFSIZE] = ""; |
1765 |
– |
const dlink_node *node = NULL; |
1766 |
– |
|
1767 |
– |
va_start(args, pattern); |
1768 |
– |
vsnprintf(buffer, sizeof(buffer), pattern, args); |
1769 |
– |
va_end(args); |
1770 |
– |
|
1771 |
– |
DLINK_FOREACH(node, cluster_items.head) |
1772 |
– |
{ |
1773 |
– |
const struct MaskItem *conf = node->data; |
1774 |
– |
|
1775 |
– |
if (conf->flags & cluster_type) |
1776 |
– |
sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab, |
1777 |
– |
"%s %s %s", command, conf->name, buffer); |
1778 |
– |
} |
1779 |
– |
} |
1780 |
– |
|
1781 |
– |
/* |
1510 |
|
* split_nuh |
1511 |
|
* |
1512 |
|
* inputs - pointer to original mask (modified in place) |