44 |
|
#include "log.h" |
45 |
|
#include "send.h" |
46 |
|
#include "memory.h" |
47 |
– |
#include "mempool.h" |
47 |
|
#include "res.h" |
48 |
|
#include "userhost.h" |
49 |
|
#include "user.h" |
53 |
|
#include "conf_db.h" |
54 |
|
#include "conf_class.h" |
55 |
|
#include "motd.h" |
56 |
+ |
#include "ipcache.h" |
57 |
|
|
58 |
|
|
59 |
– |
struct config_channel_entry ConfigChannel; |
60 |
– |
struct config_server_hide ConfigServerHide; |
61 |
– |
struct config_file_entry ConfigFileEntry; |
62 |
– |
struct logging_entry ConfigLoggingEntry = { .use_logging = 1 }; |
63 |
– |
struct server_info ServerInfo; |
64 |
– |
struct admin_info AdminInfo; |
65 |
– |
|
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 |
|
|
81 |
– |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
82 |
– |
|
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 *); |
87 |
– |
static void garbage_collect_ip_entries(void); |
88 |
– |
static int hash_ip(struct irc_ssaddr *); |
78 |
|
static int verify_access(struct Client *); |
79 |
|
static int attach_iline(struct Client *, struct MaskItem *); |
91 |
– |
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 |
|
|
96 |
– |
/* usually, with hash tables, you use a prime number... |
97 |
– |
* but in this case I am dealing with ip addresses, |
98 |
– |
* not ascii strings. |
99 |
– |
*/ |
100 |
– |
#define IP_HASH_SIZE 0x1000 |
101 |
– |
|
102 |
– |
struct ip_entry |
103 |
– |
{ |
104 |
– |
struct irc_ssaddr ip; |
105 |
– |
unsigned int count; |
106 |
– |
time_t last_attempt; |
107 |
– |
struct ip_entry *next; |
108 |
– |
}; |
109 |
– |
|
110 |
– |
static struct ip_entry *ip_hash_table[IP_HASH_SIZE]; |
111 |
– |
static mp_pool_t *ip_entry_pool = NULL; |
112 |
– |
static int ip_entries_count = 0; |
113 |
– |
|
114 |
– |
|
84 |
|
/* conf_dns_callback() |
85 |
|
* |
86 |
|
* inputs - pointer to struct MaskItem |
123 |
|
struct MaskItem * |
124 |
|
conf_make(enum maskitem_type type) |
125 |
|
{ |
126 |
< |
struct MaskItem *conf = MyMalloc(sizeof(*conf)); |
126 |
> |
struct MaskItem *conf = MyCalloc(sizeof(*conf)); |
127 |
|
dlink_list *list = NULL; |
128 |
|
|
129 |
|
conf->type = type; |
320 |
|
/* Thanks for spoof idea amm */ |
321 |
|
if (IsConfDoSpoofIp(conf)) |
322 |
|
{ |
323 |
< |
if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(conf)) |
323 |
> |
if (!ConfigGeneral.hide_spoof_ips && IsConfSpoofNotice(conf)) |
324 |
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
325 |
|
"%s spoofing: %s as %s", |
326 |
|
client_p->name, client_p->host, conf->name); |
330 |
|
|
331 |
|
return attach_iline(client_p, conf); |
332 |
|
} |
333 |
< |
else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf))) |
333 |
> |
else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf))) |
334 |
|
{ |
335 |
|
if (IsConfGline(conf)) |
336 |
|
sendto_one_notice(client_p, &me, ":*** G-lined"); |
352 |
|
static int |
353 |
|
attach_iline(struct Client *client_p, struct MaskItem *conf) |
354 |
|
{ |
355 |
< |
struct ClassItem *class = NULL; |
355 |
> |
const struct ClassItem *class = conf->class; |
356 |
|
struct ip_entry *ip_found; |
357 |
|
int a_limit_reached = 0; |
358 |
|
unsigned int local = 0, global = 0, ident = 0; |
359 |
|
|
360 |
< |
assert(conf->class); |
392 |
< |
|
393 |
< |
ip_found = find_or_add_ip(&client_p->localClient->ip); |
360 |
> |
ip_found = ipcache_find_or_add_address(&client_p->localClient->ip); |
361 |
|
ip_found->count++; |
362 |
|
SetIpHash(client_p); |
363 |
|
|
397 |
– |
class = conf->class; |
398 |
– |
|
364 |
|
count_user_host(client_p->username, client_p->host, |
365 |
|
&global, &local, &ident); |
366 |
|
|
392 |
|
return attach_conf(client_p, conf); |
393 |
|
} |
394 |
|
|
430 |
– |
/* init_ip_hash_table() |
431 |
– |
* |
432 |
– |
* inputs - NONE |
433 |
– |
* output - NONE |
434 |
– |
* side effects - allocate memory for ip_entry(s) |
435 |
– |
* - clear the ip hash table |
436 |
– |
*/ |
437 |
– |
void |
438 |
– |
init_ip_hash_table(void) |
439 |
– |
{ |
440 |
– |
ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY); |
441 |
– |
memset(ip_hash_table, 0, sizeof(ip_hash_table)); |
442 |
– |
} |
443 |
– |
|
444 |
– |
/* find_or_add_ip() |
445 |
– |
* |
446 |
– |
* inputs - pointer to struct irc_ssaddr |
447 |
– |
* output - pointer to a struct ip_entry |
448 |
– |
* side effects - |
449 |
– |
* |
450 |
– |
* If the ip # was not found, a new struct ip_entry is created, and the ip |
451 |
– |
* count set to 0. |
452 |
– |
*/ |
453 |
– |
static struct ip_entry * |
454 |
– |
find_or_add_ip(struct irc_ssaddr *ip_in) |
455 |
– |
{ |
456 |
– |
struct ip_entry *ptr, *newptr; |
457 |
– |
int hash_index = hash_ip(ip_in), res; |
458 |
– |
struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4; |
459 |
– |
#ifdef IPV6 |
460 |
– |
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6; |
461 |
– |
#endif |
462 |
– |
|
463 |
– |
for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next) |
464 |
– |
{ |
465 |
– |
#ifdef IPV6 |
466 |
– |
if (ptr->ip.ss.ss_family != ip_in->ss.ss_family) |
467 |
– |
continue; |
468 |
– |
if (ip_in->ss.ss_family == AF_INET6) |
469 |
– |
{ |
470 |
– |
ptr_v6 = (struct sockaddr_in6 *)&ptr->ip; |
471 |
– |
res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)); |
472 |
– |
} |
473 |
– |
else |
474 |
– |
#endif |
475 |
– |
{ |
476 |
– |
ptr_v4 = (struct sockaddr_in *)&ptr->ip; |
477 |
– |
res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)); |
478 |
– |
} |
479 |
– |
if (res == 0) |
480 |
– |
{ |
481 |
– |
/* Found entry already in hash, return it. */ |
482 |
– |
return ptr; |
483 |
– |
} |
484 |
– |
} |
485 |
– |
|
486 |
– |
if (ip_entries_count >= 2 * hard_fdlimit) |
487 |
– |
garbage_collect_ip_entries(); |
488 |
– |
|
489 |
– |
newptr = mp_pool_get(ip_entry_pool); |
490 |
– |
memset(newptr, 0, sizeof(*newptr)); |
491 |
– |
ip_entries_count++; |
492 |
– |
memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr)); |
493 |
– |
|
494 |
– |
newptr->next = ip_hash_table[hash_index]; |
495 |
– |
ip_hash_table[hash_index] = newptr; |
496 |
– |
|
497 |
– |
return newptr; |
498 |
– |
} |
499 |
– |
|
500 |
– |
/* remove_one_ip() |
501 |
– |
* |
502 |
– |
* inputs - unsigned long IP address value |
503 |
– |
* output - NONE |
504 |
– |
* side effects - The ip address given, is looked up in ip hash table |
505 |
– |
* and number of ip#'s for that ip decremented. |
506 |
– |
* If ip # count reaches 0 and has expired, |
507 |
– |
* the struct ip_entry is returned to the ip_entry_heap |
508 |
– |
*/ |
509 |
– |
void |
510 |
– |
remove_one_ip(struct irc_ssaddr *ip_in) |
511 |
– |
{ |
512 |
– |
struct ip_entry *ptr; |
513 |
– |
struct ip_entry *last_ptr = NULL; |
514 |
– |
int hash_index = hash_ip(ip_in), res; |
515 |
– |
struct sockaddr_in *v4 = (struct sockaddr_in *)ip_in, *ptr_v4; |
516 |
– |
#ifdef IPV6 |
517 |
– |
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)ip_in, *ptr_v6; |
518 |
– |
#endif |
519 |
– |
|
520 |
– |
for (ptr = ip_hash_table[hash_index]; ptr; ptr = ptr->next) |
521 |
– |
{ |
522 |
– |
#ifdef IPV6 |
523 |
– |
if (ptr->ip.ss.ss_family != ip_in->ss.ss_family) |
524 |
– |
continue; |
525 |
– |
if (ip_in->ss.ss_family == AF_INET6) |
526 |
– |
{ |
527 |
– |
ptr_v6 = (struct sockaddr_in6 *)&ptr->ip; |
528 |
– |
res = memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)); |
529 |
– |
} |
530 |
– |
else |
531 |
– |
#endif |
532 |
– |
{ |
533 |
– |
ptr_v4 = (struct sockaddr_in *)&ptr->ip; |
534 |
– |
res = memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)); |
535 |
– |
} |
536 |
– |
if (res) |
537 |
– |
continue; |
538 |
– |
if (ptr->count > 0) |
539 |
– |
ptr->count--; |
540 |
– |
if (ptr->count == 0 && |
541 |
– |
(CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time) |
542 |
– |
{ |
543 |
– |
if (last_ptr != NULL) |
544 |
– |
last_ptr->next = ptr->next; |
545 |
– |
else |
546 |
– |
ip_hash_table[hash_index] = ptr->next; |
547 |
– |
|
548 |
– |
mp_pool_release(ptr); |
549 |
– |
ip_entries_count--; |
550 |
– |
return; |
551 |
– |
} |
552 |
– |
last_ptr = ptr; |
553 |
– |
} |
554 |
– |
} |
555 |
– |
|
556 |
– |
/* hash_ip() |
557 |
– |
* |
558 |
– |
* input - pointer to an irc_inaddr |
559 |
– |
* output - integer value used as index into hash table |
560 |
– |
* side effects - hopefully, none |
561 |
– |
*/ |
562 |
– |
static int |
563 |
– |
hash_ip(struct irc_ssaddr *addr) |
564 |
– |
{ |
565 |
– |
if (addr->ss.ss_family == AF_INET) |
566 |
– |
{ |
567 |
– |
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
568 |
– |
int hash; |
569 |
– |
uint32_t ip; |
570 |
– |
|
571 |
– |
ip = ntohl(v4->sin_addr.s_addr); |
572 |
– |
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
573 |
– |
return hash; |
574 |
– |
} |
575 |
– |
#ifdef IPV6 |
576 |
– |
else |
577 |
– |
{ |
578 |
– |
int hash; |
579 |
– |
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
580 |
– |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
581 |
– |
|
582 |
– |
hash = ip[0] ^ ip[3]; |
583 |
– |
hash ^= hash >> 16; |
584 |
– |
hash ^= hash >> 8; |
585 |
– |
hash = hash & (IP_HASH_SIZE - 1); |
586 |
– |
return hash; |
587 |
– |
} |
588 |
– |
#else |
589 |
– |
return 0; |
590 |
– |
#endif |
591 |
– |
} |
592 |
– |
|
593 |
– |
/* count_ip_hash() |
594 |
– |
* |
595 |
– |
* inputs - pointer to counter of number of ips hashed |
596 |
– |
* - pointer to memory used for ip hash |
597 |
– |
* output - returned via pointers input |
598 |
– |
* side effects - NONE |
599 |
– |
* |
600 |
– |
* number of hashed ip #'s is counted up, plus the amount of memory |
601 |
– |
* used in the hash. |
602 |
– |
*/ |
603 |
– |
void |
604 |
– |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
605 |
– |
{ |
606 |
– |
struct ip_entry *ptr; |
607 |
– |
|
608 |
– |
*number_ips_stored = 0; |
609 |
– |
*mem_ips_stored = 0; |
610 |
– |
|
611 |
– |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
612 |
– |
{ |
613 |
– |
for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next) |
614 |
– |
{ |
615 |
– |
*number_ips_stored += 1; |
616 |
– |
*mem_ips_stored += sizeof(struct ip_entry); |
617 |
– |
} |
618 |
– |
} |
619 |
– |
} |
620 |
– |
|
621 |
– |
/* garbage_collect_ip_entries() |
622 |
– |
* |
623 |
– |
* input - NONE |
624 |
– |
* output - NONE |
625 |
– |
* side effects - free up all ip entries with no connections |
626 |
– |
*/ |
627 |
– |
static void |
628 |
– |
garbage_collect_ip_entries(void) |
629 |
– |
{ |
630 |
– |
struct ip_entry *ptr; |
631 |
– |
struct ip_entry *last_ptr; |
632 |
– |
struct ip_entry *next_ptr; |
633 |
– |
|
634 |
– |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
635 |
– |
{ |
636 |
– |
last_ptr = NULL; |
637 |
– |
|
638 |
– |
for (ptr = ip_hash_table[i]; ptr; ptr = next_ptr) |
639 |
– |
{ |
640 |
– |
next_ptr = ptr->next; |
641 |
– |
|
642 |
– |
if (ptr->count == 0 && |
643 |
– |
(CurrentTime - ptr->last_attempt) >= ConfigFileEntry.throttle_time) |
644 |
– |
{ |
645 |
– |
if (last_ptr != NULL) |
646 |
– |
last_ptr->next = ptr->next; |
647 |
– |
else |
648 |
– |
ip_hash_table[i] = ptr->next; |
649 |
– |
mp_pool_release(ptr); |
650 |
– |
ip_entries_count--; |
651 |
– |
} |
652 |
– |
else |
653 |
– |
last_ptr = ptr; |
654 |
– |
} |
655 |
– |
} |
656 |
– |
} |
657 |
– |
|
395 |
|
/* detach_conf() |
396 |
|
* |
397 |
|
* inputs - pointer to client to detach |
779 |
|
|
780 |
|
read_conf_files(0); |
781 |
|
|
782 |
< |
if (ServerInfo.description) |
783 |
< |
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
782 |
> |
if (ConfigServerInfo.description) |
783 |
> |
strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info)); |
784 |
|
|
785 |
|
load_conf_modules(); |
786 |
< |
|
1050 |
< |
rehashed_klines = 1; |
786 |
> |
check_conf_klines(); |
787 |
|
|
788 |
|
return 0; |
789 |
|
} |
806 |
|
assert(class_default == class_get_list()->tail->data); |
807 |
|
|
808 |
|
#ifdef HAVE_LIBCRYPTO |
809 |
< |
ServerInfo.rsa_private_key = NULL; |
810 |
< |
ServerInfo.rsa_private_key_file = NULL; |
809 |
> |
ConfigServerInfo.message_digest_algorithm = EVP_sha256(); |
810 |
> |
ConfigServerInfo.rsa_private_key = NULL; |
811 |
> |
ConfigServerInfo.rsa_private_key_file = NULL; |
812 |
|
#endif |
813 |
|
|
814 |
< |
/* ServerInfo.name is not rehashable */ |
815 |
< |
/* ServerInfo.name = ServerInfo.name; */ |
816 |
< |
ServerInfo.description = NULL; |
817 |
< |
ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
818 |
< |
ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
819 |
< |
|
820 |
< |
memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip)); |
821 |
< |
ServerInfo.specific_ipv4_vhost = 0; |
822 |
< |
memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6)); |
823 |
< |
ServerInfo.specific_ipv6_vhost = 0; |
824 |
< |
|
825 |
< |
ServerInfo.max_clients = MAXCLIENTS_MAX; |
826 |
< |
ServerInfo.max_nick_length = 9; |
827 |
< |
ServerInfo.max_topic_length = 80; |
828 |
< |
|
829 |
< |
ServerInfo.hub = 0; |
830 |
< |
ServerInfo.dns_host.sin_addr.s_addr = 0; |
831 |
< |
ServerInfo.dns_host.sin_port = 0; |
832 |
< |
AdminInfo.name = NULL; |
1096 |
< |
AdminInfo.email = NULL; |
1097 |
< |
AdminInfo.description = NULL; |
814 |
> |
/* ConfigServerInfo.name is not rehashable */ |
815 |
> |
/* ConfigServerInfo.name = ConfigServerInfo.name; */ |
816 |
> |
ConfigServerInfo.description = NULL; |
817 |
> |
ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
818 |
> |
ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
819 |
> |
|
820 |
> |
memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip)); |
821 |
> |
ConfigServerInfo.specific_ipv4_vhost = 0; |
822 |
> |
memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6)); |
823 |
> |
ConfigServerInfo.specific_ipv6_vhost = 0; |
824 |
> |
|
825 |
> |
ConfigServerInfo.max_clients = MAXCLIENTS_MAX; |
826 |
> |
ConfigServerInfo.max_nick_length = 9; |
827 |
> |
ConfigServerInfo.max_topic_length = 80; |
828 |
> |
ConfigServerInfo.hub = 0; |
829 |
> |
|
830 |
> |
ConfigAdminInfo.name = NULL; |
831 |
> |
ConfigAdminInfo.email = NULL; |
832 |
> |
ConfigAdminInfo.description = NULL; |
833 |
|
|
834 |
|
log_del_all(); |
835 |
|
|
836 |
< |
ConfigLoggingEntry.use_logging = 1; |
836 |
> |
ConfigLog.use_logging = 1; |
837 |
|
|
838 |
|
ConfigChannel.disable_fake_channels = 0; |
839 |
< |
ConfigChannel.knock_delay = 300; |
839 |
> |
ConfigChannel.invite_client_count = 10; |
840 |
> |
ConfigChannel.invite_client_time = 300; |
841 |
> |
ConfigChannel.knock_client_count = 1; |
842 |
> |
ConfigChannel.knock_client_time = 300; |
843 |
|
ConfigChannel.knock_delay_channel = 60; |
844 |
< |
ConfigChannel.max_chans_per_user = 25; |
1107 |
< |
ConfigChannel.max_chans_per_oper = 50; |
844 |
> |
ConfigChannel.max_channels = 25; |
845 |
|
ConfigChannel.max_bans = 25; |
846 |
|
ConfigChannel.default_split_user_count = 0; |
847 |
|
ConfigChannel.default_split_server_count = 0; |
857 |
|
ConfigServerHide.hide_server_ips = 0; |
858 |
|
ConfigServerHide.disable_remote_commands = 0; |
859 |
|
|
860 |
< |
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
861 |
< |
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
862 |
< |
ConfigFileEntry.cycle_on_host_change = 1; |
863 |
< |
ConfigFileEntry.glines = 0; |
864 |
< |
ConfigFileEntry.gline_time = 12 * 3600; |
865 |
< |
ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
866 |
< |
ConfigFileEntry.gline_min_cidr = 16; |
867 |
< |
ConfigFileEntry.gline_min_cidr6 = 48; |
868 |
< |
ConfigFileEntry.invisible_on_connect = 1; |
869 |
< |
ConfigFileEntry.tkline_expire_notices = 1; |
870 |
< |
ConfigFileEntry.hide_spoof_ips = 1; |
871 |
< |
ConfigFileEntry.ignore_bogus_ts = 0; |
872 |
< |
ConfigFileEntry.disable_auth = 0; |
873 |
< |
ConfigFileEntry.kill_chase_time_limit = 90; |
874 |
< |
ConfigFileEntry.default_floodcount = 8; |
875 |
< |
ConfigFileEntry.failed_oper_notice = 1; |
876 |
< |
ConfigFileEntry.dots_in_ident = 0; |
877 |
< |
ConfigFileEntry.min_nonwildcard = 4; |
878 |
< |
ConfigFileEntry.min_nonwildcard_simple = 3; |
879 |
< |
ConfigFileEntry.max_accept = 20; |
880 |
< |
ConfigFileEntry.anti_nick_flood = 0; |
881 |
< |
ConfigFileEntry.max_nick_time = 20; |
882 |
< |
ConfigFileEntry.max_nick_changes = 5; |
883 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
884 |
< |
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
885 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
886 |
< |
ConfigFileEntry.warn_no_nline = 1; |
887 |
< |
ConfigFileEntry.stats_o_oper_only = 0; |
888 |
< |
ConfigFileEntry.stats_k_oper_only = 1; /* 1 = masked */ |
889 |
< |
ConfigFileEntry.stats_i_oper_only = 1; /* 1 = masked */ |
890 |
< |
ConfigFileEntry.stats_P_oper_only = 0; |
891 |
< |
ConfigFileEntry.stats_u_oper_only = 0; |
892 |
< |
ConfigFileEntry.caller_id_wait = 60; |
893 |
< |
ConfigFileEntry.opers_bypass_callerid = 0; |
894 |
< |
ConfigFileEntry.pace_wait = 10; |
895 |
< |
ConfigFileEntry.pace_wait_simple = 1; |
896 |
< |
ConfigFileEntry.short_motd = 0; |
897 |
< |
ConfigFileEntry.ping_cookie = 0; |
898 |
< |
ConfigFileEntry.no_oper_flood = 0; |
899 |
< |
ConfigFileEntry.true_no_oper_flood = 0; |
900 |
< |
ConfigFileEntry.oper_pass_resv = 1; |
901 |
< |
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
902 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
903 |
< |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
904 |
< |
UMODE_OPERWALL | UMODE_WALLOP; |
905 |
< |
ConfigFileEntry.use_egd = 0; |
906 |
< |
ConfigFileEntry.egdpool_path = NULL; |
907 |
< |
ConfigFileEntry.throttle_time = 10; |
860 |
> |
ConfigGeneral.away_count = 2; |
861 |
> |
ConfigGeneral.away_time = 10; |
862 |
> |
ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
863 |
> |
ConfigGeneral.max_watch = WATCHSIZE_DEFAULT; |
864 |
> |
ConfigGeneral.cycle_on_host_change = 1; |
865 |
> |
ConfigGeneral.glines = 0; |
866 |
> |
ConfigGeneral.gline_time = 12 * 3600; |
867 |
> |
ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
868 |
> |
ConfigGeneral.gline_min_cidr = 16; |
869 |
> |
ConfigGeneral.gline_min_cidr6 = 48; |
870 |
> |
ConfigGeneral.invisible_on_connect = 1; |
871 |
> |
ConfigGeneral.tkline_expire_notices = 1; |
872 |
> |
ConfigGeneral.hide_spoof_ips = 1; |
873 |
> |
ConfigGeneral.ignore_bogus_ts = 0; |
874 |
> |
ConfigGeneral.disable_auth = 0; |
875 |
> |
ConfigGeneral.kill_chase_time_limit = 90; |
876 |
> |
ConfigGeneral.default_floodcount = 8; |
877 |
> |
ConfigGeneral.failed_oper_notice = 1; |
878 |
> |
ConfigGeneral.dots_in_ident = 0; |
879 |
> |
ConfigGeneral.min_nonwildcard = 4; |
880 |
> |
ConfigGeneral.min_nonwildcard_simple = 3; |
881 |
> |
ConfigGeneral.max_accept = 20; |
882 |
> |
ConfigGeneral.anti_nick_flood = 0; |
883 |
> |
ConfigGeneral.max_nick_time = 20; |
884 |
> |
ConfigGeneral.max_nick_changes = 5; |
885 |
> |
ConfigGeneral.anti_spam_exit_message_time = 0; |
886 |
> |
ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
887 |
> |
ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
888 |
> |
ConfigGeneral.warn_no_connect_block = 1; |
889 |
> |
ConfigGeneral.stats_e_disabled = 0; |
890 |
> |
ConfigGeneral.stats_o_oper_only = 0; |
891 |
> |
ConfigGeneral.stats_k_oper_only = 1; /* 1 = masked */ |
892 |
> |
ConfigGeneral.stats_i_oper_only = 1; /* 1 = masked */ |
893 |
> |
ConfigGeneral.stats_P_oper_only = 0; |
894 |
> |
ConfigGeneral.stats_u_oper_only = 0; |
895 |
> |
ConfigGeneral.caller_id_wait = 60; |
896 |
> |
ConfigGeneral.opers_bypass_callerid = 0; |
897 |
> |
ConfigGeneral.pace_wait = 10; |
898 |
> |
ConfigGeneral.pace_wait_simple = 1; |
899 |
> |
ConfigGeneral.short_motd = 0; |
900 |
> |
ConfigGeneral.ping_cookie = 0; |
901 |
> |
ConfigGeneral.no_oper_flood = 0; |
902 |
> |
ConfigGeneral.true_no_oper_flood = 0; |
903 |
> |
ConfigGeneral.oper_pass_resv = 1; |
904 |
> |
ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT; |
905 |
> |
ConfigGeneral.oper_only_umodes = UMODE_DEBUG; |
906 |
> |
ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
907 |
> |
ConfigGeneral.throttle_count = 1; |
908 |
> |
ConfigGeneral.throttle_time = 1; |
909 |
|
} |
910 |
|
|
911 |
|
static void |
912 |
|
validate_conf(void) |
913 |
|
{ |
914 |
< |
if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN) |
915 |
< |
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
914 |
> |
if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN) |
915 |
> |
ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
916 |
|
|
917 |
< |
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
918 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
917 |
> |
if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN) |
918 |
> |
ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
919 |
|
|
920 |
< |
if (ServerInfo.network_name == NULL) |
921 |
< |
ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
920 |
> |
if (ConfigServerInfo.network_name == NULL) |
921 |
> |
ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
922 |
|
|
923 |
< |
if (ServerInfo.network_desc == NULL) |
924 |
< |
ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
923 |
> |
if (ConfigServerInfo.network_desc == NULL) |
924 |
> |
ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
925 |
|
|
926 |
< |
if (ConfigFileEntry.service_name == NULL) |
927 |
< |
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
926 |
> |
if (ConfigGeneral.service_name == NULL) |
927 |
> |
ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
928 |
|
|
929 |
< |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
929 |
> |
ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN); |
930 |
|
} |
931 |
|
|
932 |
|
/* read_conf() |
1000 |
|
int |
1001 |
|
conf_connect_allowed(struct irc_ssaddr *addr, int aftype) |
1002 |
|
{ |
1003 |
< |
struct ip_entry *ip_found; |
1003 |
> |
struct ip_entry *ip_found = NULL; |
1004 |
|
struct MaskItem *conf = find_dline_conf(addr, aftype); |
1005 |
|
|
1006 |
|
/* DLINE exempt also gets you out of static limits/pacing... */ |
1010 |
|
if (conf) |
1011 |
|
return BANNED_CLIENT; |
1012 |
|
|
1013 |
< |
ip_found = find_or_add_ip(addr); |
1013 |
> |
ip_found = ipcache_find_or_add_address(addr); |
1014 |
|
|
1015 |
< |
if ((CurrentTime - ip_found->last_attempt) < |
1278 |
< |
ConfigFileEntry.throttle_time) |
1015 |
> |
if ((CurrentTime - ip_found->last_attempt) < ConfigGeneral.throttle_time) |
1016 |
|
{ |
1017 |
< |
ip_found->last_attempt = CurrentTime; |
1018 |
< |
return TOO_FAST; |
1017 |
> |
if (ip_found->connection_count >= ConfigGeneral.throttle_count) |
1018 |
> |
return TOO_FAST; |
1019 |
> |
|
1020 |
> |
++ip_found->connection_count; |
1021 |
|
} |
1022 |
+ |
else |
1023 |
+ |
ip_found->connection_count = 1; |
1024 |
|
|
1025 |
|
ip_found->last_attempt = CurrentTime; |
1026 |
|
return 0; |
1063 |
|
|
1064 |
|
if (conf->type == CONF_XLINE) |
1065 |
|
{ |
1066 |
< |
if (ConfigFileEntry.tkline_expire_notices) |
1066 |
> |
if (ConfigGeneral.tkline_expire_notices) |
1067 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1068 |
|
"Temporary X-line for [%s] expired", conf->name); |
1069 |
|
conf_free(conf); |
1070 |
|
} |
1071 |
|
else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV) |
1072 |
|
{ |
1073 |
< |
if (ConfigFileEntry.tkline_expire_notices) |
1073 |
> |
if (ConfigGeneral.tkline_expire_notices) |
1074 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1075 |
|
"Temporary RESV for [%s] expired", conf->name); |
1076 |
|
conf_free(conf); |
1094 |
|
{ OPER_FLAG_DIE, 'D' }, |
1095 |
|
{ OPER_FLAG_GLINE, 'G' }, |
1096 |
|
{ OPER_FLAG_REHASH, 'H' }, |
1097 |
< |
{ OPER_FLAG_K, 'K' }, |
1357 |
< |
{ OPER_FLAG_OPERWALL, 'L' }, |
1097 |
> |
{ OPER_FLAG_KLINE, 'K' }, |
1098 |
|
{ OPER_FLAG_KILL, 'N' }, |
1099 |
|
{ OPER_FLAG_KILL_REMOTE, 'O' }, |
1100 |
|
{ OPER_FLAG_CONNECT, 'P' }, |
1126 |
|
} |
1127 |
|
|
1128 |
|
/* |
1129 |
< |
* Input: A client to find the active oper{} name for. |
1129 |
> |
* Input: A client to find the active operator {} name for. |
1130 |
|
* Output: The nick!user@host{oper} of the oper. |
1131 |
|
* "oper" is server name for remote opers |
1132 |
|
* Side effects: None. |
1152 |
|
} |
1153 |
|
} |
1154 |
|
|
1155 |
< |
/* Probably should assert here for now. If there is an oper out there |
1156 |
< |
* with no oper{} conf attached, it would be good for us to know... |
1155 |
> |
/* |
1156 |
> |
* Probably should assert here for now. If there is an oper out there |
1157 |
> |
* with no operator {} conf attached, it would be good for us to know... |
1158 |
|
*/ |
1159 |
< |
assert(0); /* Oper without oper conf! */ |
1159 |
> |
assert(0); /* Oper without oper conf! */ |
1160 |
|
} |
1161 |
|
|
1162 |
|
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
1178 |
|
char chanlimit[IRCD_BUFSIZE] = ""; |
1179 |
|
|
1180 |
|
conf_parser_ctx.boot = cold; |
1181 |
< |
filename = ConfigFileEntry.configfile; |
1181 |
> |
filename = ConfigGeneral.configfile; |
1182 |
|
|
1183 |
|
/* We need to know the initial filename for the yyerror() to report |
1184 |
|
FIXME: The full path is in conffilenamebuf first time since we |
1185 |
< |
dont know anything else |
1185 |
> |
don't know anything else |
1186 |
|
|
1187 |
|
- Gozem 2002-07-21 |
1188 |
|
*/ |
1213 |
|
|
1214 |
|
log_reopen_all(); |
1215 |
|
|
1216 |
< |
add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length); |
1217 |
< |
add_isupport("NETWORK", ServerInfo.network_name, -1); |
1216 |
> |
add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length); |
1217 |
> |
add_isupport("NETWORK", ConfigServerInfo.network_name, -1); |
1218 |
|
|
1219 |
|
snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans); |
1220 |
|
add_isupport("MAXLIST", chanmodes, -1); |
1221 |
< |
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
1221 |
> |
add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets); |
1222 |
|
add_isupport("CHANTYPES", "#", -1); |
1223 |
|
|
1224 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1225 |
< |
ConfigChannel.max_chans_per_user); |
1225 |
> |
ConfigChannel.max_channels); |
1226 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
1227 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS"); |
1227 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1228 |
|
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1229 |
< |
add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length); |
1229 |
> |
add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1230 |
|
add_isupport("CHANMODES", chanmodes, -1); |
1231 |
|
|
1232 |
|
/* |
1296 |
|
/* clean out module paths */ |
1297 |
|
mod_clear_paths(); |
1298 |
|
|
1299 |
< |
/* clean out ServerInfo */ |
1300 |
< |
MyFree(ServerInfo.description); |
1301 |
< |
ServerInfo.description = NULL; |
1302 |
< |
MyFree(ServerInfo.network_name); |
1303 |
< |
ServerInfo.network_name = NULL; |
1304 |
< |
MyFree(ServerInfo.network_desc); |
1305 |
< |
ServerInfo.network_desc = NULL; |
1565 |
< |
MyFree(ConfigFileEntry.egdpool_path); |
1566 |
< |
ConfigFileEntry.egdpool_path = NULL; |
1299 |
> |
/* clean out ConfigServerInfo */ |
1300 |
> |
MyFree(ConfigServerInfo.description); |
1301 |
> |
ConfigServerInfo.description = NULL; |
1302 |
> |
MyFree(ConfigServerInfo.network_name); |
1303 |
> |
ConfigServerInfo.network_name = NULL; |
1304 |
> |
MyFree(ConfigServerInfo.network_desc); |
1305 |
> |
ConfigServerInfo.network_desc = NULL; |
1306 |
|
#ifdef HAVE_LIBCRYPTO |
1307 |
< |
if (ServerInfo.rsa_private_key) |
1307 |
> |
if (ConfigServerInfo.rsa_private_key) |
1308 |
|
{ |
1309 |
< |
RSA_free(ServerInfo.rsa_private_key); |
1310 |
< |
ServerInfo.rsa_private_key = NULL; |
1309 |
> |
RSA_free(ConfigServerInfo.rsa_private_key); |
1310 |
> |
ConfigServerInfo.rsa_private_key = NULL; |
1311 |
|
} |
1312 |
|
|
1313 |
< |
MyFree(ServerInfo.rsa_private_key_file); |
1314 |
< |
ServerInfo.rsa_private_key_file = NULL; |
1576 |
< |
|
1577 |
< |
if (ServerInfo.server_ctx) |
1578 |
< |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
1579 |
< |
SSL_OP_NO_SSLv3| |
1580 |
< |
SSL_OP_NO_TLSv1); |
1581 |
< |
if (ServerInfo.client_ctx) |
1582 |
< |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
1583 |
< |
SSL_OP_NO_SSLv3| |
1584 |
< |
SSL_OP_NO_TLSv1); |
1313 |
> |
MyFree(ConfigServerInfo.rsa_private_key_file); |
1314 |
> |
ConfigServerInfo.rsa_private_key_file = NULL; |
1315 |
|
#endif |
1316 |
|
|
1317 |
< |
/* clean out AdminInfo */ |
1318 |
< |
MyFree(AdminInfo.name); |
1319 |
< |
AdminInfo.name = NULL; |
1320 |
< |
MyFree(AdminInfo.email); |
1321 |
< |
AdminInfo.email = NULL; |
1322 |
< |
MyFree(AdminInfo.description); |
1323 |
< |
AdminInfo.description = NULL; |
1317 |
> |
/* clean out ConfigAdminInfo */ |
1318 |
> |
MyFree(ConfigAdminInfo.name); |
1319 |
> |
ConfigAdminInfo.name = NULL; |
1320 |
> |
MyFree(ConfigAdminInfo.email); |
1321 |
> |
ConfigAdminInfo.email = NULL; |
1322 |
> |
MyFree(ConfigAdminInfo.description); |
1323 |
> |
ConfigAdminInfo.description = NULL; |
1324 |
|
|
1325 |
|
/* clean out listeners */ |
1326 |
|
close_listeners(); |
1327 |
|
|
1328 |
|
/* clean out general */ |
1329 |
< |
MyFree(ConfigFileEntry.service_name); |
1330 |
< |
ConfigFileEntry.service_name = NULL; |
1329 |
> |
MyFree(ConfigGeneral.service_name); |
1330 |
> |
ConfigGeneral.service_name = NULL; |
1331 |
|
} |
1332 |
|
|
1333 |
|
/* conf_add_class_to_conf() |
1464 |
|
{ |
1465 |
|
const unsigned char *p = (const unsigned char *)data; |
1466 |
|
unsigned char tmpch = '\0'; |
1467 |
< |
int nonwild = 0; |
1467 |
> |
unsigned int nonwild = 0; |
1468 |
|
|
1469 |
|
while ((tmpch = *p++)) |
1470 |
|
{ |
1471 |
< |
if (tmpch == '\\') |
1471 |
> |
if (tmpch == '\\' && *p) |
1472 |
|
{ |
1473 |
|
++p; |
1474 |
< |
if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple) |
1474 |
> |
if (++nonwild >= ConfigGeneral.min_nonwildcard_simple) |
1475 |
|
return 1; |
1476 |
|
} |
1477 |
|
else if (!IsMWildChar(tmpch)) |
1478 |
|
{ |
1479 |
< |
if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple) |
1479 |
> |
if (++nonwild >= ConfigGeneral.min_nonwildcard_simple) |
1480 |
|
return 1; |
1481 |
|
} |
1482 |
|
} |
1495 |
|
int |
1496 |
|
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1497 |
|
{ |
1498 |
< |
char tmpch; |
1499 |
< |
int nonwild = 0; |
1498 |
> |
unsigned char tmpch = '\0'; |
1499 |
> |
unsigned int nonwild = 0; |
1500 |
|
va_list args; |
1501 |
|
|
1502 |
|
/* |
1515 |
|
|
1516 |
|
while (count--) |
1517 |
|
{ |
1518 |
< |
const char *p = va_arg(args, const char *); |
1518 |
> |
const unsigned char *p = va_arg(args, const unsigned char *); |
1519 |
|
if (p == NULL) |
1520 |
|
continue; |
1521 |
|
|
1527 |
|
* If we find enough non-wild characters, we can |
1528 |
|
* break - no point in searching further. |
1529 |
|
*/ |
1530 |
< |
if (++nonwild >= ConfigFileEntry.min_nonwildcard) |
1530 |
> |
if (++nonwild >= ConfigGeneral.min_nonwildcard) |
1531 |
|
{ |
1532 |
|
va_end(args); |
1533 |
|
return 1; |
1538 |
|
|
1539 |
|
if (warn) |
1540 |
|
sendto_one_notice(source_p, &me, |
1541 |
< |
":Please include at least %d non-wildcard characters with the mask", |
1542 |
< |
ConfigFileEntry.min_nonwildcard); |
1541 |
> |
":Please include at least %u non-wildcard characters with the mask", |
1542 |
> |
ConfigGeneral.min_nonwildcard); |
1543 |
|
va_end(args); |
1544 |
|
return 0; |
1545 |
|
} |
1581 |
|
char **target_server, char **reason) |
1582 |
|
{ |
1583 |
|
int found_tkline_time=0; |
1584 |
< |
static char def_reason[] = "No Reason"; |
1584 |
> |
static char def_reason[] = CONF_NOREASON; |
1585 |
|
static char user[USERLEN*4+1]; |
1586 |
|
static char host[HOSTLEN*4+1]; |
1587 |
|
|
1747 |
|
/* Okay to use source_p as the first param, because source_p == client_p */ |
1748 |
|
if ((target_p = |
1749 |
|
find_chasing(source_p, user_host_or_nick)) == NULL) |
1750 |
< |
return 0; |
1750 |
> |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
1751 |
|
|
1752 |
|
if (IsExemptKline(target_p)) |
1753 |
|
{ |