28 |
|
#include "list.h" |
29 |
|
#include "ircd_defs.h" |
30 |
|
#include "conf.h" |
31 |
< |
#include "s_serv.h" |
31 |
> |
#include "server.h" |
32 |
|
#include "resv.h" |
33 |
|
#include "channel.h" |
34 |
|
#include "client.h" |
35 |
|
#include "event.h" |
36 |
– |
#include "hook.h" |
36 |
|
#include "irc_string.h" |
37 |
|
#include "s_bsd.h" |
38 |
|
#include "ircd.h" |
43 |
|
#include "fdlist.h" |
44 |
|
#include "log.h" |
45 |
|
#include "send.h" |
47 |
– |
#include "s_gline.h" |
46 |
|
#include "memory.h" |
47 |
< |
#include "mempool.h" |
50 |
< |
#include "irc_res.h" |
47 |
> |
#include "res.h" |
48 |
|
#include "userhost.h" |
49 |
< |
#include "s_user.h" |
49 |
> |
#include "user.h" |
50 |
|
#include "channel_mode.h" |
51 |
|
#include "parse.h" |
52 |
< |
#include "s_misc.h" |
52 |
> |
#include "misc.h" |
53 |
|
#include "conf_db.h" |
54 |
|
#include "conf_class.h" |
55 |
|
#include "motd.h" |
56 |
+ |
#include "ipcache.h" |
57 |
|
|
58 |
|
|
61 |
– |
struct config_channel_entry ConfigChannel; |
62 |
– |
struct config_server_hide ConfigServerHide; |
63 |
– |
struct config_file_entry ConfigFileEntry; |
64 |
– |
struct logging_entry ConfigLoggingEntry = { .use_logging = 1 }; |
65 |
– |
struct server_info ServerInfo; |
66 |
– |
struct admin_info AdminInfo; |
67 |
– |
|
59 |
|
/* general conf items link list root, other than k lines etc. */ |
60 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
61 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list uconf_items = { NULL, NULL, 0 }; |
65 |
|
dlink_list xconf_items = { NULL, NULL, 0 }; |
66 |
|
dlink_list nresv_items = { NULL, NULL, 0 }; |
67 |
< |
dlink_list cresv_items = { NULL, NULL, 0 }; |
67 |
> |
dlink_list cresv_items = { NULL, NULL, 0 }; |
68 |
|
|
69 |
|
extern unsigned int lineno; |
70 |
|
extern char linebuf[]; |
71 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
72 |
|
extern int yyparse(); /* defined in y.tab.c */ |
73 |
|
|
83 |
– |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
84 |
– |
|
74 |
|
/* internally defined functions */ |
75 |
|
static void read_conf(FILE *); |
76 |
|
static void clear_out_old_conf(void); |
77 |
|
static void expire_tklines(dlink_list *); |
89 |
– |
static void garbage_collect_ip_entries(void); |
90 |
– |
static int hash_ip(struct irc_ssaddr *); |
78 |
|
static int verify_access(struct Client *); |
79 |
|
static int attach_iline(struct Client *, struct MaskItem *); |
93 |
– |
static struct ip_entry *find_or_add_ip(struct irc_ssaddr *); |
80 |
|
static dlink_list *map_to_list(enum maskitem_type); |
81 |
|
static int find_user_host(struct Client *, char *, char *, char *, unsigned int); |
82 |
|
|
83 |
|
|
98 |
– |
/* usually, with hash tables, you use a prime number... |
99 |
– |
* but in this case I am dealing with ip addresses, |
100 |
– |
* not ascii strings. |
101 |
– |
*/ |
102 |
– |
#define IP_HASH_SIZE 0x1000 |
103 |
– |
|
104 |
– |
struct ip_entry |
105 |
– |
{ |
106 |
– |
struct irc_ssaddr ip; |
107 |
– |
unsigned int count; |
108 |
– |
time_t last_attempt; |
109 |
– |
struct ip_entry *next; |
110 |
– |
}; |
111 |
– |
|
112 |
– |
static struct ip_entry *ip_hash_table[IP_HASH_SIZE]; |
113 |
– |
static mp_pool_t *ip_entry_pool = NULL; |
114 |
– |
static int ip_entries_count = 0; |
115 |
– |
|
116 |
– |
|
84 |
|
/* conf_dns_callback() |
85 |
|
* |
86 |
|
* inputs - pointer to struct MaskItem |
92 |
|
* if successful save hp in the conf item it was called with |
93 |
|
*/ |
94 |
|
static void |
95 |
< |
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name) |
95 |
> |
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name, size_t namelength) |
96 |
|
{ |
97 |
|
struct MaskItem *conf = vptr; |
98 |
|
|
99 |
|
conf->dns_pending = 0; |
100 |
|
|
101 |
< |
if (addr != NULL) |
101 |
> |
if (addr) |
102 |
|
memcpy(&conf->addr, addr, sizeof(conf->addr)); |
103 |
|
else |
104 |
|
conf->dns_failed = 1; |
116 |
|
if (!conf->dns_pending) |
117 |
|
{ |
118 |
|
conf->dns_pending = 1; |
119 |
< |
gethost_byname(conf_dns_callback, conf, conf->host); |
119 |
> |
|
120 |
> |
if (conf->aftype == AF_INET) |
121 |
> |
gethost_byname_type(conf_dns_callback, conf, conf->host, T_A); |
122 |
> |
else |
123 |
> |
gethost_byname_type(conf_dns_callback, conf, conf->host, T_AAAA); |
124 |
|
} |
125 |
|
} |
126 |
|
|
127 |
|
struct MaskItem * |
128 |
|
conf_make(enum maskitem_type type) |
129 |
|
{ |
130 |
< |
struct MaskItem *conf = MyMalloc(sizeof(*conf)); |
130 |
> |
struct MaskItem *conf = MyCalloc(sizeof(*conf)); |
131 |
|
dlink_list *list = NULL; |
132 |
|
|
133 |
|
conf->type = type; |
145 |
|
dlink_node *ptr = NULL, *ptr_next = NULL; |
146 |
|
dlink_list *list = NULL; |
147 |
|
|
148 |
< |
if (conf->node.next) |
149 |
< |
if ((list = map_to_list(conf->type))) |
150 |
< |
dlinkDelete(&conf->node, list); |
148 |
> |
assert(conf->node.data); |
149 |
> |
|
150 |
> |
if ((list = map_to_list(conf->type))) |
151 |
> |
dlinkDelete(&conf->node, list); |
152 |
|
|
153 |
|
MyFree(conf->name); |
154 |
|
|
155 |
|
if (conf->dns_pending) |
156 |
|
delete_resolver_queries(conf); |
157 |
< |
if (conf->passwd != NULL) |
157 |
> |
if (conf->passwd) |
158 |
|
memset(conf->passwd, 0, strlen(conf->passwd)); |
159 |
< |
if (conf->spasswd != NULL) |
159 |
> |
if (conf->spasswd) |
160 |
|
memset(conf->spasswd, 0, strlen(conf->spasswd)); |
161 |
|
|
162 |
|
conf->class = NULL; |
296 |
|
conf = find_address_conf(client_p->host, client_p->username, |
297 |
|
&client_p->localClient->ip, |
298 |
|
client_p->localClient->aftype, |
299 |
< |
client_p->localClient->passwd); |
299 |
> |
client_p->localClient->password); |
300 |
|
} |
301 |
|
else |
302 |
|
{ |
304 |
|
conf = find_address_conf(client_p->host,non_ident, |
305 |
|
&client_p->localClient->ip, |
306 |
|
client_p->localClient->aftype, |
307 |
< |
client_p->localClient->passwd); |
307 |
> |
client_p->localClient->password); |
308 |
|
} |
309 |
|
|
310 |
|
if (conf) |
325 |
|
/* Thanks for spoof idea amm */ |
326 |
|
if (IsConfDoSpoofIp(conf)) |
327 |
|
{ |
328 |
< |
if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(conf)) |
328 |
> |
if (!ConfigGeneral.hide_spoof_ips && IsConfSpoofNotice(conf)) |
329 |
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
330 |
|
"%s spoofing: %s as %s", |
331 |
|
client_p->name, client_p->host, conf->name); |
335 |
|
|
336 |
|
return attach_iline(client_p, conf); |
337 |
|
} |
338 |
< |
else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf))) |
338 |
> |
else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf))) |
339 |
|
{ |
340 |
|
if (IsConfGline(conf)) |
341 |
|
sendto_one_notice(client_p, &me, ":*** G-lined"); |
357 |
|
static int |
358 |
|
attach_iline(struct Client *client_p, struct MaskItem *conf) |
359 |
|
{ |
360 |
< |
struct ClassItem *class = NULL; |
360 |
> |
const struct ClassItem *class = conf->class; |
361 |
|
struct ip_entry *ip_found; |
362 |
|
int a_limit_reached = 0; |
363 |
|
unsigned int local = 0, global = 0, ident = 0; |
364 |
|
|
365 |
< |
assert(conf->class); |
394 |
< |
|
395 |
< |
ip_found = find_or_add_ip(&client_p->localClient->ip); |
365 |
> |
ip_found = ipcache_find_or_add_address(&client_p->localClient->ip); |
366 |
|
ip_found->count++; |
367 |
< |
SetIpHash(client_p); |
398 |
< |
|
399 |
< |
class = conf->class; |
367 |
> |
AddFlag(client_p, FLAGS_IPHASH); |
368 |
|
|
369 |
|
count_user_host(client_p->username, client_p->host, |
370 |
|
&global, &local, &ident); |
373 |
|
* setting a_limit_reached if any limit is reached. |
374 |
|
* - Dianora |
375 |
|
*/ |
376 |
< |
if (class->max_total != 0 && class->ref_count >= class->max_total) |
376 |
> |
if (class->max_total && class->ref_count >= class->max_total) |
377 |
|
a_limit_reached = 1; |
378 |
< |
else if (class->max_perip != 0 && ip_found->count > class->max_perip) |
378 |
> |
else if (class->max_perip && ip_found->count > class->max_perip) |
379 |
|
a_limit_reached = 1; |
380 |
< |
else if (class->max_local != 0 && local >= class->max_local) |
380 |
> |
else if (class->max_local && local >= class->max_local) |
381 |
|
a_limit_reached = 1; |
382 |
< |
else if (class->max_global != 0 && global >= class->max_global) |
382 |
> |
else if (class->max_global && global >= class->max_global) |
383 |
|
a_limit_reached = 1; |
384 |
< |
else if (class->max_ident != 0 && ident >= class->max_ident && |
384 |
> |
else if (class->max_ident && ident >= class->max_ident && |
385 |
|
client_p->username[0] != '~') |
386 |
|
a_limit_reached = 1; |
387 |
|
|
397 |
|
return attach_conf(client_p, conf); |
398 |
|
} |
399 |
|
|
432 |
– |
/* init_ip_hash_table() |
433 |
– |
* |
434 |
– |
* inputs - NONE |
435 |
– |
* output - NONE |
436 |
– |
* side effects - allocate memory for ip_entry(s) |
437 |
– |
* - clear the ip hash table |
438 |
– |
*/ |
439 |
– |
void |
440 |
– |
init_ip_hash_table(void) |
441 |
– |
{ |
442 |
– |
ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY); |
443 |
– |
memset(ip_hash_table, 0, sizeof(ip_hash_table)); |
444 |
– |
} |
445 |
– |
|
446 |
– |
/* find_or_add_ip() |
447 |
– |
* |
448 |
– |
* inputs - pointer to struct irc_ssaddr |
449 |
– |
* output - pointer to a struct ip_entry |
450 |
– |
* side effects - |
451 |
– |
* |
452 |
– |
* If the ip # was not found, a new struct ip_entry is created, and the ip |
453 |
– |
* count set to 0. |
454 |
– |
*/ |
455 |
– |
static struct ip_entry * |
456 |
– |
find_or_add_ip(struct irc_ssaddr *ip_in) |
457 |
– |
{ |
458 |
– |
struct ip_entry *ptr, *newptr; |
459 |
– |
int hash_index = hash_ip(ip_in), res; |
460 |
– |
struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4; |
461 |
– |
#ifdef IPV6 |
462 |
– |
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6; |
463 |
– |
#endif |
464 |
– |
|
465 |
– |
for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next) |
466 |
– |
{ |
467 |
– |
#ifdef IPV6 |
468 |
– |
if (ptr->ip.ss.ss_family != ip_in->ss.ss_family) |
469 |
– |
continue; |
470 |
– |
if (ip_in->ss.ss_family == AF_INET6) |
471 |
– |
{ |
472 |
– |
ptr_v6 = (struct sockaddr_in6 *)&ptr->ip; |
473 |
– |
res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)); |
474 |
– |
} |
475 |
– |
else |
476 |
– |
#endif |
477 |
– |
{ |
478 |
– |
ptr_v4 = (struct sockaddr_in *)&ptr->ip; |
479 |
– |
res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)); |
480 |
– |
} |
481 |
– |
if (res == 0) |
482 |
– |
{ |
483 |
– |
/* Found entry already in hash, return it. */ |
484 |
– |
return ptr; |
485 |
– |
} |
486 |
– |
} |
487 |
– |
|
488 |
– |
if (ip_entries_count >= 2 * hard_fdlimit) |
489 |
– |
garbage_collect_ip_entries(); |
490 |
– |
|
491 |
– |
newptr = mp_pool_get(ip_entry_pool); |
492 |
– |
memset(newptr, 0, sizeof(*newptr)); |
493 |
– |
ip_entries_count++; |
494 |
– |
memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr)); |
495 |
– |
|
496 |
– |
newptr->next = ip_hash_table[hash_index]; |
497 |
– |
ip_hash_table[hash_index] = newptr; |
498 |
– |
|
499 |
– |
return newptr; |
500 |
– |
} |
501 |
– |
|
502 |
– |
/* remove_one_ip() |
503 |
– |
* |
504 |
– |
* inputs - unsigned long IP address value |
505 |
– |
* output - NONE |
506 |
– |
* side effects - The ip address given, is looked up in ip hash table |
507 |
– |
* and number of ip#'s for that ip decremented. |
508 |
– |
* If ip # count reaches 0 and has expired, |
509 |
– |
* the struct ip_entry is returned to the ip_entry_heap |
510 |
– |
*/ |
511 |
– |
void |
512 |
– |
remove_one_ip(struct irc_ssaddr *ip_in) |
513 |
– |
{ |
514 |
– |
struct ip_entry *ptr; |
515 |
– |
struct ip_entry *last_ptr = NULL; |
516 |
– |
int hash_index = hash_ip(ip_in), res; |
517 |
– |
struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4; |
518 |
– |
#ifdef IPV6 |
519 |
– |
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6; |
520 |
– |
#endif |
521 |
– |
|
522 |
– |
for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next) |
523 |
– |
{ |
524 |
– |
#ifdef IPV6 |
525 |
– |
if (ptr->ip.ss.ss_family != ip_in->ss.ss_family) |
526 |
– |
continue; |
527 |
– |
if (ip_in->ss.ss_family == AF_INET6) |
528 |
– |
{ |
529 |
– |
ptr_v6 = (struct sockaddr_in6 *)&ptr->ip; |
530 |
– |
res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)); |
531 |
– |
} |
532 |
– |
else |
533 |
– |
#endif |
534 |
– |
{ |
535 |
– |
ptr_v4 = (struct sockaddr_in *)&ptr->ip; |
536 |
– |
res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)); |
537 |
– |
} |
538 |
– |
if (res) |
539 |
– |
continue; |
540 |
– |
if (ptr->count > 0) |
541 |
– |
ptr->count--; |
542 |
– |
if (ptr->count == 0 && |
543 |
– |
(CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time) |
544 |
– |
{ |
545 |
– |
if (last_ptr != NULL) |
546 |
– |
last_ptr->next = ptr->next; |
547 |
– |
else |
548 |
– |
ip_hash_table[hash_index] = ptr->next; |
549 |
– |
|
550 |
– |
mp_pool_release(ptr); |
551 |
– |
ip_entries_count--; |
552 |
– |
return; |
553 |
– |
} |
554 |
– |
last_ptr = ptr; |
555 |
– |
} |
556 |
– |
} |
557 |
– |
|
558 |
– |
/* hash_ip() |
559 |
– |
* |
560 |
– |
* input - pointer to an irc_inaddr |
561 |
– |
* output - integer value used as index into hash table |
562 |
– |
* side effects - hopefully, none |
563 |
– |
*/ |
564 |
– |
static int |
565 |
– |
hash_ip(struct irc_ssaddr *addr) |
566 |
– |
{ |
567 |
– |
if (addr->ss.ss_family == AF_INET) |
568 |
– |
{ |
569 |
– |
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
570 |
– |
int hash; |
571 |
– |
uint32_t ip; |
572 |
– |
|
573 |
– |
ip = ntohl(v4->sin_addr.s_addr); |
574 |
– |
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
575 |
– |
return hash; |
576 |
– |
} |
577 |
– |
#ifdef IPV6 |
578 |
– |
else |
579 |
– |
{ |
580 |
– |
int hash; |
581 |
– |
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
582 |
– |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
583 |
– |
|
584 |
– |
hash = ip[0] ^ ip[3]; |
585 |
– |
hash ^= hash >> 16; |
586 |
– |
hash ^= hash >> 8; |
587 |
– |
hash = hash & (IP_HASH_SIZE - 1); |
588 |
– |
return hash; |
589 |
– |
} |
590 |
– |
#else |
591 |
– |
return 0; |
592 |
– |
#endif |
593 |
– |
} |
594 |
– |
|
595 |
– |
/* count_ip_hash() |
596 |
– |
* |
597 |
– |
* inputs - pointer to counter of number of ips hashed |
598 |
– |
* - pointer to memory used for ip hash |
599 |
– |
* output - returned via pointers input |
600 |
– |
* side effects - NONE |
601 |
– |
* |
602 |
– |
* number of hashed ip #'s is counted up, plus the amount of memory |
603 |
– |
* used in the hash. |
604 |
– |
*/ |
605 |
– |
void |
606 |
– |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
607 |
– |
{ |
608 |
– |
struct ip_entry *ptr; |
609 |
– |
int i; |
610 |
– |
|
611 |
– |
*number_ips_stored = 0; |
612 |
– |
*mem_ips_stored = 0; |
613 |
– |
|
614 |
– |
for (i = 0; i < IP_HASH_SIZE; i++) |
615 |
– |
{ |
616 |
– |
for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next) |
617 |
– |
{ |
618 |
– |
*number_ips_stored += 1; |
619 |
– |
*mem_ips_stored += sizeof(struct ip_entry); |
620 |
– |
} |
621 |
– |
} |
622 |
– |
} |
623 |
– |
|
624 |
– |
/* garbage_collect_ip_entries() |
625 |
– |
* |
626 |
– |
* input - NONE |
627 |
– |
* output - NONE |
628 |
– |
* side effects - free up all ip entries with no connections |
629 |
– |
*/ |
630 |
– |
static void |
631 |
– |
garbage_collect_ip_entries(void) |
632 |
– |
{ |
633 |
– |
struct ip_entry *ptr; |
634 |
– |
struct ip_entry *last_ptr; |
635 |
– |
struct ip_entry *next_ptr; |
636 |
– |
int i; |
637 |
– |
|
638 |
– |
for (i = 0; i < IP_HASH_SIZE; i++) |
639 |
– |
{ |
640 |
– |
last_ptr = NULL; |
641 |
– |
|
642 |
– |
for (ptr = ip_hash_table[i]; ptr; ptr = next_ptr) |
643 |
– |
{ |
644 |
– |
next_ptr = ptr->next; |
645 |
– |
|
646 |
– |
if (ptr->count == 0 && |
647 |
– |
(CurrentTime - ptr->last_attempt) >= ConfigFileEntry.throttle_time) |
648 |
– |
{ |
649 |
– |
if (last_ptr != NULL) |
650 |
– |
last_ptr->next = ptr->next; |
651 |
– |
else |
652 |
– |
ip_hash_table[i] = ptr->next; |
653 |
– |
mp_pool_release(ptr); |
654 |
– |
ip_entries_count--; |
655 |
– |
} |
656 |
– |
else |
657 |
– |
last_ptr = ptr; |
658 |
– |
} |
659 |
– |
} |
660 |
– |
} |
661 |
– |
|
400 |
|
/* detach_conf() |
401 |
|
* |
402 |
|
* inputs - pointer to client to detach |
408 |
|
void |
409 |
|
detach_conf(struct Client *client_p, enum maskitem_type type) |
410 |
|
{ |
411 |
< |
dlink_node *ptr = NULL, *next_ptr = NULL; |
411 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
412 |
|
|
413 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head) |
413 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head) |
414 |
|
{ |
415 |
|
struct MaskItem *conf = ptr->data; |
416 |
|
|
451 |
|
int |
452 |
|
attach_conf(struct Client *client_p, struct MaskItem *conf) |
453 |
|
{ |
454 |
< |
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
454 |
> |
if (dlinkFind(&client_p->localClient->confs, conf)) |
455 |
|
return 1; |
456 |
|
|
457 |
|
if (conf->type == CONF_CLIENT) |
523 |
|
|
524 |
|
if (conf->type == type) |
525 |
|
{ |
526 |
< |
if (conf->name && (irccmp(conf->name, name) == 0 || |
526 |
> |
if (conf->name && (!irccmp(conf->name, name) || |
527 |
|
!match(conf->name, name))) |
528 |
|
return conf; |
529 |
|
} |
717 |
|
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
718 |
|
return conf; |
719 |
|
break; |
982 |
– |
#ifdef IPV6 |
720 |
|
case HM_IPV6: |
721 |
|
if (who->localClient->aftype == AF_INET6) |
722 |
|
if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits)) |
723 |
|
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total) |
724 |
|
return conf; |
725 |
|
break; |
989 |
– |
#endif |
726 |
|
default: |
727 |
|
assert(0); |
728 |
|
} |
769 |
|
int |
770 |
|
rehash(int sig) |
771 |
|
{ |
772 |
< |
if (sig != 0) |
772 |
> |
if (sig) |
773 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
774 |
|
"Got signal SIGHUP, reloading configuration file(s)"); |
775 |
|
|
777 |
|
|
778 |
|
/* don't close listeners until we know we can go ahead with the rehash */ |
779 |
|
|
1044 |
– |
/* Check to see if we magically got(or lost) IPv6 support */ |
1045 |
– |
check_can_use_v6(); |
1046 |
– |
|
780 |
|
read_conf_files(0); |
781 |
|
|
1049 |
– |
if (ServerInfo.description != NULL) |
1050 |
– |
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1051 |
– |
|
782 |
|
load_conf_modules(); |
783 |
< |
|
1054 |
< |
rehashed_klines = 1; |
783 |
> |
check_conf_klines(); |
784 |
|
|
785 |
|
return 0; |
786 |
|
} |
803 |
|
assert(class_default == class_get_list()->tail->data); |
804 |
|
|
805 |
|
#ifdef HAVE_LIBCRYPTO |
806 |
< |
ServerInfo.rsa_private_key = NULL; |
807 |
< |
ServerInfo.rsa_private_key_file = NULL; |
806 |
> |
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH) |
807 |
> |
{ |
808 |
> |
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); |
809 |
> |
|
810 |
> |
if (key) |
811 |
> |
{ |
812 |
> |
SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key); |
813 |
> |
EC_KEY_free(key); |
814 |
> |
} |
815 |
> |
} |
816 |
> |
|
817 |
> |
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE); |
818 |
|
#endif |
819 |
|
|
820 |
< |
/* ServerInfo.name is not rehashable */ |
821 |
< |
/* ServerInfo.name = ServerInfo.name; */ |
822 |
< |
ServerInfo.description = NULL; |
823 |
< |
ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
824 |
< |
ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
825 |
< |
|
826 |
< |
memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip)); |
827 |
< |
ServerInfo.specific_ipv4_vhost = 0; |
828 |
< |
memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6)); |
829 |
< |
ServerInfo.specific_ipv6_vhost = 0; |
830 |
< |
|
831 |
< |
ServerInfo.max_clients = MAXCLIENTS_MAX; |
832 |
< |
ServerInfo.max_nick_length = 9; |
833 |
< |
ServerInfo.max_topic_length = 80; |
834 |
< |
|
835 |
< |
ServerInfo.hub = 0; |
836 |
< |
ServerInfo.dns_host.sin_addr.s_addr = 0; |
837 |
< |
ServerInfo.dns_host.sin_port = 0; |
838 |
< |
AdminInfo.name = NULL; |
839 |
< |
AdminInfo.email = NULL; |
840 |
< |
AdminInfo.description = NULL; |
820 |
> |
ConfigServerInfo.message_digest_algorithm = EVP_sha256(); |
821 |
> |
ConfigServerInfo.rsa_private_key = NULL; |
822 |
> |
ConfigServerInfo.rsa_private_key_file = NULL; |
823 |
> |
#endif |
824 |
> |
|
825 |
> |
/* ConfigServerInfo.name is not rehashable */ |
826 |
> |
/* ConfigServerInfo.name = ConfigServerInfo.name; */ |
827 |
> |
ConfigServerInfo.description = NULL; |
828 |
> |
ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
829 |
> |
ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
830 |
> |
|
831 |
> |
memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip)); |
832 |
> |
ConfigServerInfo.specific_ipv4_vhost = 0; |
833 |
> |
memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6)); |
834 |
> |
ConfigServerInfo.specific_ipv6_vhost = 0; |
835 |
> |
|
836 |
> |
ConfigServerInfo.max_clients = MAXCLIENTS_MAX; |
837 |
> |
ConfigServerInfo.max_nick_length = 9; |
838 |
> |
ConfigServerInfo.max_topic_length = 80; |
839 |
> |
ConfigServerInfo.hub = 0; |
840 |
> |
|
841 |
> |
ConfigAdminInfo.name = NULL; |
842 |
> |
ConfigAdminInfo.email = NULL; |
843 |
> |
ConfigAdminInfo.description = NULL; |
844 |
|
|
845 |
|
log_del_all(); |
846 |
|
|
847 |
< |
ConfigLoggingEntry.use_logging = 1; |
847 |
> |
ConfigLog.use_logging = 1; |
848 |
|
|
849 |
|
ConfigChannel.disable_fake_channels = 0; |
850 |
< |
ConfigChannel.knock_delay = 300; |
850 |
> |
ConfigChannel.invite_client_count = 10; |
851 |
> |
ConfigChannel.invite_client_time = 300; |
852 |
> |
ConfigChannel.knock_client_count = 1; |
853 |
> |
ConfigChannel.knock_client_time = 300; |
854 |
|
ConfigChannel.knock_delay_channel = 60; |
855 |
< |
ConfigChannel.max_chans_per_user = 25; |
1111 |
< |
ConfigChannel.max_chans_per_oper = 50; |
855 |
> |
ConfigChannel.max_channels = 25; |
856 |
|
ConfigChannel.max_bans = 25; |
857 |
|
ConfigChannel.default_split_user_count = 0; |
858 |
|
ConfigChannel.default_split_server_count = 0; |
868 |
|
ConfigServerHide.hide_server_ips = 0; |
869 |
|
ConfigServerHide.disable_remote_commands = 0; |
870 |
|
|
871 |
< |
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
872 |
< |
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
873 |
< |
ConfigFileEntry.cycle_on_host_change = 1; |
874 |
< |
ConfigFileEntry.glines = 0; |
875 |
< |
ConfigFileEntry.gline_time = 12 * 3600; |
876 |
< |
ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
877 |
< |
ConfigFileEntry.gline_min_cidr = 16; |
878 |
< |
ConfigFileEntry.gline_min_cidr6 = 48; |
879 |
< |
ConfigFileEntry.invisible_on_connect = 1; |
880 |
< |
ConfigFileEntry.tkline_expire_notices = 1; |
881 |
< |
ConfigFileEntry.hide_spoof_ips = 1; |
882 |
< |
ConfigFileEntry.ignore_bogus_ts = 0; |
883 |
< |
ConfigFileEntry.disable_auth = 0; |
884 |
< |
ConfigFileEntry.kill_chase_time_limit = 90; |
885 |
< |
ConfigFileEntry.default_floodcount = 8; |
886 |
< |
ConfigFileEntry.failed_oper_notice = 1; |
887 |
< |
ConfigFileEntry.dots_in_ident = 0; |
888 |
< |
ConfigFileEntry.min_nonwildcard = 4; |
889 |
< |
ConfigFileEntry.min_nonwildcard_simple = 3; |
890 |
< |
ConfigFileEntry.max_accept = 20; |
891 |
< |
ConfigFileEntry.anti_nick_flood = 0; |
892 |
< |
ConfigFileEntry.max_nick_time = 20; |
893 |
< |
ConfigFileEntry.max_nick_changes = 5; |
894 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
895 |
< |
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
896 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
897 |
< |
ConfigFileEntry.warn_no_nline = 1; |
898 |
< |
ConfigFileEntry.stats_o_oper_only = 0; |
899 |
< |
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
900 |
< |
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
901 |
< |
ConfigFileEntry.stats_P_oper_only = 0; |
902 |
< |
ConfigFileEntry.stats_u_oper_only = 0; |
903 |
< |
ConfigFileEntry.caller_id_wait = 60; |
904 |
< |
ConfigFileEntry.opers_bypass_callerid = 0; |
905 |
< |
ConfigFileEntry.pace_wait = 10; |
906 |
< |
ConfigFileEntry.pace_wait_simple = 1; |
907 |
< |
ConfigFileEntry.short_motd = 0; |
908 |
< |
ConfigFileEntry.ping_cookie = 0; |
909 |
< |
ConfigFileEntry.no_oper_flood = 0; |
910 |
< |
ConfigFileEntry.true_no_oper_flood = 0; |
911 |
< |
ConfigFileEntry.oper_pass_resv = 1; |
912 |
< |
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
913 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
914 |
< |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
915 |
< |
UMODE_OPERWALL | UMODE_WALLOP; |
916 |
< |
ConfigFileEntry.use_egd = 0; |
917 |
< |
ConfigFileEntry.egdpool_path = NULL; |
918 |
< |
ConfigFileEntry.throttle_time = 10; |
871 |
> |
ConfigGeneral.away_count = 2; |
872 |
> |
ConfigGeneral.away_time = 10; |
873 |
> |
ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
874 |
> |
ConfigGeneral.max_watch = WATCHSIZE_DEFAULT; |
875 |
> |
ConfigGeneral.cycle_on_host_change = 1; |
876 |
> |
ConfigGeneral.glines = 0; |
877 |
> |
ConfigGeneral.gline_time = 12 * 3600; |
878 |
> |
ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
879 |
> |
ConfigGeneral.gline_min_cidr = 16; |
880 |
> |
ConfigGeneral.gline_min_cidr6 = 48; |
881 |
> |
ConfigGeneral.invisible_on_connect = 1; |
882 |
> |
ConfigGeneral.tkline_expire_notices = 1; |
883 |
> |
ConfigGeneral.hide_spoof_ips = 1; |
884 |
> |
ConfigGeneral.ignore_bogus_ts = 0; |
885 |
> |
ConfigGeneral.disable_auth = 0; |
886 |
> |
ConfigGeneral.kill_chase_time_limit = 90; |
887 |
> |
ConfigGeneral.default_floodcount = 8; |
888 |
> |
ConfigGeneral.failed_oper_notice = 1; |
889 |
> |
ConfigGeneral.dots_in_ident = 0; |
890 |
> |
ConfigGeneral.min_nonwildcard = 4; |
891 |
> |
ConfigGeneral.min_nonwildcard_simple = 3; |
892 |
> |
ConfigGeneral.max_accept = 20; |
893 |
> |
ConfigGeneral.anti_nick_flood = 0; |
894 |
> |
ConfigGeneral.max_nick_time = 20; |
895 |
> |
ConfigGeneral.max_nick_changes = 5; |
896 |
> |
ConfigGeneral.anti_spam_exit_message_time = 0; |
897 |
> |
ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
898 |
> |
ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
899 |
> |
ConfigGeneral.warn_no_connect_block = 1; |
900 |
> |
ConfigGeneral.stats_e_disabled = 0; |
901 |
> |
ConfigGeneral.stats_o_oper_only = 0; |
902 |
> |
ConfigGeneral.stats_k_oper_only = 1; /* 1 = masked */ |
903 |
> |
ConfigGeneral.stats_i_oper_only = 1; /* 1 = masked */ |
904 |
> |
ConfigGeneral.stats_P_oper_only = 0; |
905 |
> |
ConfigGeneral.stats_u_oper_only = 0; |
906 |
> |
ConfigGeneral.caller_id_wait = 60; |
907 |
> |
ConfigGeneral.opers_bypass_callerid = 0; |
908 |
> |
ConfigGeneral.pace_wait = 10; |
909 |
> |
ConfigGeneral.pace_wait_simple = 1; |
910 |
> |
ConfigGeneral.short_motd = 0; |
911 |
> |
ConfigGeneral.ping_cookie = 0; |
912 |
> |
ConfigGeneral.no_oper_flood = 0; |
913 |
> |
ConfigGeneral.true_no_oper_flood = 0; |
914 |
> |
ConfigGeneral.oper_pass_resv = 1; |
915 |
> |
ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT; |
916 |
> |
ConfigGeneral.oper_only_umodes = UMODE_DEBUG; |
917 |
> |
ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
918 |
> |
ConfigGeneral.throttle_count = 1; |
919 |
> |
ConfigGeneral.throttle_time = 1; |
920 |
|
} |
921 |
|
|
922 |
|
static void |
923 |
|
validate_conf(void) |
924 |
|
{ |
925 |
< |
if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN) |
926 |
< |
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
925 |
> |
if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN) |
926 |
> |
ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
927 |
|
|
928 |
< |
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
929 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
928 |
> |
if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN) |
929 |
> |
ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
930 |
|
|
931 |
< |
if (ServerInfo.network_name == NULL) |
932 |
< |
ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
931 |
> |
if (ConfigServerInfo.network_name == NULL) |
932 |
> |
ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
933 |
|
|
934 |
< |
if (ServerInfo.network_desc == NULL) |
935 |
< |
ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
934 |
> |
if (ConfigServerInfo.network_desc == NULL) |
935 |
> |
ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
936 |
|
|
937 |
< |
if (ConfigFileEntry.service_name == NULL) |
938 |
< |
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
937 |
> |
if (ConfigGeneral.service_name == NULL) |
938 |
> |
ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
939 |
|
|
940 |
< |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
940 |
> |
ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN); |
941 |
|
} |
942 |
|
|
943 |
|
/* read_conf() |
951 |
|
{ |
952 |
|
lineno = 0; |
953 |
|
|
954 |
< |
set_default_conf(); /* Set default values prior to conf parsing */ |
954 |
> |
set_default_conf(); /* Set default values prior to conf parsing */ |
955 |
|
conf_parser_ctx.pass = 1; |
956 |
< |
yyparse(); /* pick up the classes first */ |
956 |
> |
yyparse(); /* Pick up the classes first */ |
957 |
|
|
958 |
|
rewind(file); |
959 |
|
|
960 |
|
conf_parser_ctx.pass = 2; |
961 |
< |
yyparse(); /* Load the values from the conf */ |
962 |
< |
validate_conf(); /* Check to make sure some values are still okay. */ |
963 |
< |
/* Some global values are also loaded here. */ |
964 |
< |
class_delete_marked(); /* Make sure classes are valid */ |
961 |
> |
yyparse(); /* Load the values from the conf */ |
962 |
> |
validate_conf(); /* Check to make sure some values are still okay. */ |
963 |
> |
/* Some global values are also loaded here. */ |
964 |
> |
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
965 |
|
} |
966 |
|
|
967 |
|
/* lookup_confhost() |
974 |
|
{ |
975 |
|
struct addrinfo hints, *res; |
976 |
|
|
977 |
< |
/* Do name lookup now on hostnames given and store the |
977 |
> |
/* |
978 |
> |
* Do name lookup now on hostnames given and store the |
979 |
|
* ip numbers in conf structure. |
980 |
|
*/ |
981 |
|
memset(&hints, 0, sizeof(hints)); |
992 |
|
return; |
993 |
|
} |
994 |
|
|
995 |
< |
assert(res != NULL); |
995 |
> |
assert(res); |
996 |
|
|
997 |
|
memcpy(&conf->addr, res->ai_addr, res->ai_addrlen); |
998 |
|
conf->addr.ss_len = res->ai_addrlen; |
1011 |
|
int |
1012 |
|
conf_connect_allowed(struct irc_ssaddr *addr, int aftype) |
1013 |
|
{ |
1014 |
< |
struct ip_entry *ip_found; |
1014 |
> |
struct ip_entry *ip_found = NULL; |
1015 |
|
struct MaskItem *conf = find_dline_conf(addr, aftype); |
1016 |
|
|
1017 |
|
/* DLINE exempt also gets you out of static limits/pacing... */ |
1018 |
|
if (conf && (conf->type == CONF_EXEMPT)) |
1019 |
|
return 0; |
1020 |
|
|
1021 |
< |
if (conf != NULL) |
1021 |
> |
if (conf) |
1022 |
|
return BANNED_CLIENT; |
1023 |
|
|
1024 |
< |
ip_found = find_or_add_ip(addr); |
1024 |
> |
ip_found = ipcache_find_or_add_address(addr); |
1025 |
|
|
1026 |
< |
if ((CurrentTime - ip_found->last_attempt) < |
1281 |
< |
ConfigFileEntry.throttle_time) |
1026 |
> |
if ((CurrentTime - ip_found->last_attempt) < ConfigGeneral.throttle_time) |
1027 |
|
{ |
1028 |
< |
ip_found->last_attempt = CurrentTime; |
1029 |
< |
return TOO_FAST; |
1028 |
> |
if (ip_found->connection_count >= ConfigGeneral.throttle_count) |
1029 |
> |
return TOO_FAST; |
1030 |
> |
|
1031 |
> |
++ip_found->connection_count; |
1032 |
|
} |
1033 |
+ |
else |
1034 |
+ |
ip_found->connection_count = 1; |
1035 |
|
|
1036 |
|
ip_found->last_attempt = CurrentTime; |
1037 |
|
return 0; |
1045 |
|
* This is an event started off in ircd.c |
1046 |
|
*/ |
1047 |
|
void |
1048 |
< |
cleanup_tklines(void *notused) |
1048 |
> |
cleanup_tklines(void *unused) |
1049 |
|
{ |
1050 |
|
hostmask_expire_temporary(); |
1051 |
|
expire_tklines(&xconf_items); |
1062 |
|
static void |
1063 |
|
expire_tklines(dlink_list *tklist) |
1064 |
|
{ |
1065 |
< |
dlink_node *ptr; |
1066 |
< |
dlink_node *next_ptr; |
1318 |
< |
struct MaskItem *conf; |
1065 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1066 |
> |
struct MaskItem *conf = NULL; |
1067 |
|
|
1068 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
1068 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head) |
1069 |
|
{ |
1070 |
|
conf = ptr->data; |
1071 |
|
|
1074 |
|
|
1075 |
|
if (conf->type == CONF_XLINE) |
1076 |
|
{ |
1077 |
< |
if (ConfigFileEntry.tkline_expire_notices) |
1077 |
> |
if (ConfigGeneral.tkline_expire_notices) |
1078 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1079 |
|
"Temporary X-line for [%s] expired", conf->name); |
1080 |
|
conf_free(conf); |
1081 |
|
} |
1082 |
|
else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV) |
1083 |
|
{ |
1084 |
< |
if (ConfigFileEntry.tkline_expire_notices) |
1084 |
> |
if (ConfigGeneral.tkline_expire_notices) |
1085 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1086 |
|
"Temporary RESV for [%s] expired", conf->name); |
1087 |
|
conf_free(conf); |
1105 |
|
{ OPER_FLAG_DIE, 'D' }, |
1106 |
|
{ OPER_FLAG_GLINE, 'G' }, |
1107 |
|
{ OPER_FLAG_REHASH, 'H' }, |
1108 |
< |
{ OPER_FLAG_K, 'K' }, |
1361 |
< |
{ OPER_FLAG_OPERWALL, 'L' }, |
1108 |
> |
{ OPER_FLAG_KLINE, 'K' }, |
1109 |
|
{ OPER_FLAG_KILL, 'N' }, |
1110 |
|
{ OPER_FLAG_KILL_REMOTE, 'O' }, |
1111 |
|
{ OPER_FLAG_CONNECT, 'P' }, |
1122 |
|
{ |
1123 |
|
static char privs_out[IRCD_BUFSIZE]; |
1124 |
|
char *privs_ptr = privs_out; |
1378 |
– |
const struct oper_privs *opriv = flag_list; |
1125 |
|
|
1126 |
< |
for (; opriv->flag; ++opriv) |
1126 |
> |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
1127 |
|
{ |
1128 |
|
if (port & opriv->flag) |
1129 |
|
*privs_ptr++ = opriv->c; |
1137 |
|
} |
1138 |
|
|
1139 |
|
/* |
1140 |
< |
* Input: A client to find the active oper{} name for. |
1140 |
> |
* Input: A client to find the active operator {} name for. |
1141 |
|
* Output: The nick!user@host{oper} of the oper. |
1142 |
|
* "oper" is server name for remote opers |
1143 |
|
* Side effects: None. |
1163 |
|
} |
1164 |
|
} |
1165 |
|
|
1166 |
< |
/* Probably should assert here for now. If there is an oper out there |
1167 |
< |
* with no oper{} conf attached, it would be good for us to know... |
1166 |
> |
/* |
1167 |
> |
* Probably should assert here for now. If there is an oper out there |
1168 |
> |
* with no operator {} conf attached, it would be good for us to know... |
1169 |
|
*/ |
1170 |
< |
assert(0); /* Oper without oper conf! */ |
1170 |
> |
assert(0); /* Oper without oper conf! */ |
1171 |
|
} |
1172 |
|
|
1173 |
|
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
1184 |
|
void |
1185 |
|
read_conf_files(int cold) |
1186 |
|
{ |
1187 |
< |
const char *filename; |
1188 |
< |
char chanmodes[IRCD_BUFSIZE]; |
1189 |
< |
char chanlimit[IRCD_BUFSIZE]; |
1187 |
> |
const char *filename = NULL; |
1188 |
> |
char chanmodes[IRCD_BUFSIZE] = ""; |
1189 |
> |
char chanlimit[IRCD_BUFSIZE] = ""; |
1190 |
|
|
1191 |
|
conf_parser_ctx.boot = cold; |
1192 |
< |
filename = ConfigFileEntry.configfile; |
1192 |
> |
filename = ConfigGeneral.configfile; |
1193 |
|
|
1194 |
|
/* We need to know the initial filename for the yyerror() to report |
1195 |
|
FIXME: The full path is in conffilenamebuf first time since we |
1196 |
< |
dont know anything else |
1196 |
> |
don't know anything else |
1197 |
|
|
1198 |
|
- Gozem 2002-07-21 |
1199 |
|
*/ |
1224 |
|
|
1225 |
|
log_reopen_all(); |
1226 |
|
|
1227 |
< |
add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length); |
1228 |
< |
add_isupport("NETWORK", ServerInfo.network_name, -1); |
1227 |
> |
add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length); |
1228 |
> |
add_isupport("NETWORK", ConfigServerInfo.network_name, -1); |
1229 |
|
|
1230 |
|
snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans); |
1231 |
|
add_isupport("MAXLIST", chanmodes, -1); |
1232 |
< |
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
1232 |
> |
add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets); |
1233 |
|
add_isupport("CHANTYPES", "#", -1); |
1234 |
|
|
1235 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1236 |
< |
ConfigChannel.max_chans_per_user); |
1236 |
> |
ConfigChannel.max_channels); |
1237 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
1238 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS"); |
1239 |
< |
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
1240 |
< |
add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length); |
1238 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1239 |
> |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1240 |
> |
add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1241 |
|
add_isupport("CHANMODES", chanmodes, -1); |
1242 |
|
|
1243 |
|
/* |
1307 |
|
/* clean out module paths */ |
1308 |
|
mod_clear_paths(); |
1309 |
|
|
1310 |
< |
/* clean out ServerInfo */ |
1311 |
< |
MyFree(ServerInfo.description); |
1312 |
< |
ServerInfo.description = NULL; |
1313 |
< |
MyFree(ServerInfo.network_name); |
1314 |
< |
ServerInfo.network_name = NULL; |
1315 |
< |
MyFree(ServerInfo.network_desc); |
1316 |
< |
ServerInfo.network_desc = NULL; |
1570 |
< |
MyFree(ConfigFileEntry.egdpool_path); |
1571 |
< |
ConfigFileEntry.egdpool_path = NULL; |
1310 |
> |
/* clean out ConfigServerInfo */ |
1311 |
> |
MyFree(ConfigServerInfo.description); |
1312 |
> |
ConfigServerInfo.description = NULL; |
1313 |
> |
MyFree(ConfigServerInfo.network_name); |
1314 |
> |
ConfigServerInfo.network_name = NULL; |
1315 |
> |
MyFree(ConfigServerInfo.network_desc); |
1316 |
> |
ConfigServerInfo.network_desc = NULL; |
1317 |
|
#ifdef HAVE_LIBCRYPTO |
1318 |
< |
if (ServerInfo.rsa_private_key != NULL) |
1318 |
> |
if (ConfigServerInfo.rsa_private_key) |
1319 |
|
{ |
1320 |
< |
RSA_free(ServerInfo.rsa_private_key); |
1321 |
< |
ServerInfo.rsa_private_key = NULL; |
1320 |
> |
RSA_free(ConfigServerInfo.rsa_private_key); |
1321 |
> |
ConfigServerInfo.rsa_private_key = NULL; |
1322 |
|
} |
1323 |
|
|
1324 |
< |
MyFree(ServerInfo.rsa_private_key_file); |
1325 |
< |
ServerInfo.rsa_private_key_file = NULL; |
1581 |
< |
|
1582 |
< |
if (ServerInfo.server_ctx) |
1583 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
1584 |
< |
SSL_OP_NO_SSLv3| |
1585 |
< |
SSL_OP_NO_TLSv1); |
1586 |
< |
if (ServerInfo.client_ctx) |
1587 |
< |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
1588 |
< |
SSL_OP_NO_SSLv3| |
1589 |
< |
SSL_OP_NO_TLSv1); |
1324 |
> |
MyFree(ConfigServerInfo.rsa_private_key_file); |
1325 |
> |
ConfigServerInfo.rsa_private_key_file = NULL; |
1326 |
|
#endif |
1327 |
|
|
1328 |
< |
/* clean out AdminInfo */ |
1329 |
< |
MyFree(AdminInfo.name); |
1330 |
< |
AdminInfo.name = NULL; |
1331 |
< |
MyFree(AdminInfo.email); |
1332 |
< |
AdminInfo.email = NULL; |
1333 |
< |
MyFree(AdminInfo.description); |
1334 |
< |
AdminInfo.description = NULL; |
1328 |
> |
/* clean out ConfigAdminInfo */ |
1329 |
> |
MyFree(ConfigAdminInfo.name); |
1330 |
> |
ConfigAdminInfo.name = NULL; |
1331 |
> |
MyFree(ConfigAdminInfo.email); |
1332 |
> |
ConfigAdminInfo.email = NULL; |
1333 |
> |
MyFree(ConfigAdminInfo.description); |
1334 |
> |
ConfigAdminInfo.description = NULL; |
1335 |
|
|
1336 |
|
/* clean out listeners */ |
1337 |
|
close_listeners(); |
1338 |
|
|
1339 |
|
/* clean out general */ |
1340 |
< |
MyFree(ConfigFileEntry.service_name); |
1341 |
< |
ConfigFileEntry.service_name = NULL; |
1340 |
> |
MyFree(ConfigGeneral.service_name); |
1341 |
> |
ConfigGeneral.service_name = NULL; |
1342 |
|
} |
1343 |
|
|
1344 |
|
/* conf_add_class_to_conf() |
1475 |
|
{ |
1476 |
|
const unsigned char *p = (const unsigned char *)data; |
1477 |
|
unsigned char tmpch = '\0'; |
1478 |
< |
int nonwild = 0; |
1478 |
> |
unsigned int nonwild = 0; |
1479 |
|
|
1480 |
|
while ((tmpch = *p++)) |
1481 |
|
{ |
1482 |
< |
if (tmpch == '\\') |
1482 |
> |
if (tmpch == '\\' && *p) |
1483 |
|
{ |
1484 |
|
++p; |
1485 |
< |
if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple) |
1485 |
> |
if (++nonwild >= ConfigGeneral.min_nonwildcard_simple) |
1486 |
|
return 1; |
1487 |
|
} |
1488 |
|
else if (!IsMWildChar(tmpch)) |
1489 |
|
{ |
1490 |
< |
if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple) |
1490 |
> |
if (++nonwild >= ConfigGeneral.min_nonwildcard_simple) |
1491 |
|
return 1; |
1492 |
|
} |
1493 |
|
} |
1506 |
|
int |
1507 |
|
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1508 |
|
{ |
1509 |
< |
char tmpch; |
1510 |
< |
int nonwild = 0; |
1509 |
> |
unsigned char tmpch = '\0'; |
1510 |
> |
unsigned int nonwild = 0; |
1511 |
|
va_list args; |
1512 |
|
|
1513 |
|
/* |
1526 |
|
|
1527 |
|
while (count--) |
1528 |
|
{ |
1529 |
< |
const char *p = va_arg(args, const char *); |
1529 |
> |
const unsigned char *p = va_arg(args, const unsigned char *); |
1530 |
|
if (p == NULL) |
1531 |
|
continue; |
1532 |
|
|
1538 |
|
* If we find enough non-wild characters, we can |
1539 |
|
* break - no point in searching further. |
1540 |
|
*/ |
1541 |
< |
if (++nonwild >= ConfigFileEntry.min_nonwildcard) |
1541 |
> |
if (++nonwild >= ConfigGeneral.min_nonwildcard) |
1542 |
|
{ |
1543 |
|
va_end(args); |
1544 |
|
return 1; |
1549 |
|
|
1550 |
|
if (warn) |
1551 |
|
sendto_one_notice(source_p, &me, |
1552 |
< |
":Please include at least %d non-wildcard characters with the mask", |
1553 |
< |
ConfigFileEntry.min_nonwildcard); |
1552 |
> |
":Please include at least %u non-wildcard characters with the mask", |
1553 |
> |
ConfigGeneral.min_nonwildcard); |
1554 |
|
va_end(args); |
1555 |
|
return 0; |
1556 |
|
} |
1592 |
|
char **target_server, char **reason) |
1593 |
|
{ |
1594 |
|
int found_tkline_time=0; |
1595 |
< |
static char def_reason[] = "No Reason"; |
1595 |
> |
static char def_reason[] = CONF_NOREASON; |
1596 |
|
static char user[USERLEN*4+1]; |
1597 |
|
static char host[HOSTLEN*4+1]; |
1598 |
|
|
1758 |
|
/* Okay to use source_p as the first param, because source_p == client_p */ |
1759 |
|
if ((target_p = |
1760 |
|
find_chasing(source_p, user_host_or_nick)) == NULL) |
1761 |
< |
return 0; |
1761 |
> |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
1762 |
|
|
1763 |
|
if (IsExemptKline(target_p)) |
1764 |
|
{ |
1824 |
|
else |
1825 |
|
encr = password; |
1826 |
|
|
1827 |
< |
return !strcmp(encr, conf->passwd); |
1827 |
> |
return encr && !strcmp(encr, conf->passwd); |
1828 |
|
} |
1829 |
|
|
1830 |
|
/* |
1832 |
|
* |
1833 |
|
* inputs - client sending the cluster |
1834 |
|
* - command name "KLINE" "XLINE" etc. |
1835 |
< |
* - capab -- CAP_KLN etc. from s_serv.h |
1835 |
> |
* - capab -- CAP_KLN etc. from server.h |
1836 |
|
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
1837 |
|
* - pattern and args to send along |
1838 |
|
* output - none |
1844 |
|
int capab, int cluster_type, const char *pattern, ...) |
1845 |
|
{ |
1846 |
|
va_list args; |
1847 |
< |
char buffer[IRCD_BUFSIZE]; |
1847 |
> |
char buffer[IRCD_BUFSIZE] = ""; |
1848 |
|
const dlink_node *ptr = NULL; |
1849 |
|
|
1850 |
|
va_start(args, pattern); |
1905 |
|
{ |
1906 |
|
*p = '\0'; |
1907 |
|
|
1908 |
< |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
1908 |
> |
if (iptr->nickptr && *iptr->nuhmask) |
1909 |
|
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
1910 |
|
|
1911 |
|
if ((q = strchr(++p, '@'))) |
1912 |
|
{ |
1913 |
|
*q++ = '\0'; |
1914 |
|
|
1915 |
< |
if (*p != '\0') |
1915 |
> |
if (*p) |
1916 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
1917 |
|
|
1918 |
< |
if (*q != '\0') |
1918 |
> |
if (*q) |
1919 |
|
strlcpy(iptr->hostptr, q, iptr->hostsize); |
1920 |
|
} |
1921 |
|
else |
1922 |
|
{ |
1923 |
< |
if (*p != '\0') |
1923 |
> |
if (*p) |
1924 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
1925 |
|
} |
1926 |
|
} |
1932 |
|
/* if found a @ */ |
1933 |
|
*p++ = '\0'; |
1934 |
|
|
1935 |
< |
if (*iptr->nuhmask != '\0') |
1935 |
> |
if (*iptr->nuhmask) |
1936 |
|
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
1937 |
|
|
1938 |
< |
if (*p != '\0') |
1938 |
> |
if (*p) |
1939 |
|
strlcpy(iptr->hostptr, p, iptr->hostsize); |
1940 |
|
} |
1941 |
|
else |