ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/conf.c (file contents):
Revision 3347 by michael, Sun Apr 20 14:03:06 2014 UTC vs.
Revision 4460 by michael, Mon Aug 11 19:45:11 2014 UTC

# Line 44 | Line 44
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"
# Line 54 | Line 53
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 };
# Line 71 | Line 64 | dlink_list oconf_items   = { NULL, NULL,
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
# Line 123 | Line 92 | static int ip_entries_count = 0;
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  
# Line 147 | Line 116 | conf_dns_lookup(struct MaskItem *conf)
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;
# Line 322 | Line 295 | verify_access(struct Client *client_p)
295      conf = find_address_conf(client_p->host, client_p->username,
296                               &client_p->localClient->ip,
297                               client_p->localClient->aftype,
298 <                             client_p->localClient->passwd);
298 >                             client_p->localClient->password);
299    }
300    else
301    {
# Line 330 | Line 303 | verify_access(struct Client *client_p)
303      conf = find_address_conf(client_p->host,non_ident,
304                               &client_p->localClient->ip,
305                               client_p->localClient->aftype,
306 <                             client_p->localClient->passwd);
306 >                             client_p->localClient->password);
307    }
308  
309    if (conf)
# Line 351 | Line 324 | verify_access(struct Client *client_p)
324        /* Thanks for spoof idea amm */
325        if (IsConfDoSpoofIp(conf))
326        {
327 <        if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(conf))
327 >        if (!ConfigGeneral.hide_spoof_ips && IsConfSpoofNotice(conf))
328            sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
329                                 "%s spoofing: %s as %s",
330                                 client_p->name, client_p->host, conf->name);
# Line 361 | Line 334 | verify_access(struct Client *client_p)
334  
335        return attach_iline(client_p, conf);
336      }
337 <    else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
337 >    else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf)))
338      {
339        if (IsConfGline(conf))
340          sendto_one_notice(client_p, &me, ":*** G-lined");
# Line 383 | Line 356 | verify_access(struct Client *client_p)
356   static int
357   attach_iline(struct Client *client_p, struct MaskItem *conf)
358   {
359 <  struct ClassItem *class = NULL;
359 >  const struct ClassItem *class = conf->class;
360    struct ip_entry *ip_found;
361    int a_limit_reached = 0;
362    unsigned int local = 0, global = 0, ident = 0;
363  
364 <  assert(conf->class);
392 <
393 <  ip_found = find_or_add_ip(&client_p->localClient->ip);
364 >  ip_found = ipcache_find_or_add_address(&client_p->localClient->ip);
365    ip_found->count++;
366 <  SetIpHash(client_p);
396 <
397 <  class = conf->class;
366 >  AddFlag(client_p, FLAGS_IPHASH);
367  
368    count_user_host(client_p->username, client_p->host,
369                    &global, &local, &ident);
# Line 403 | Line 372 | attach_iline(struct Client *client_p, st
372     * setting a_limit_reached if any limit is reached.
373     * - Dianora
374     */
375 <  if (class->max_total != 0 && class->ref_count >= class->max_total)
375 >  if (class->max_total && class->ref_count >= class->max_total)
376      a_limit_reached = 1;
377 <  else if (class->max_perip != 0 && ip_found->count > class->max_perip)
377 >  else if (class->max_perip && ip_found->count > class->max_perip)
378      a_limit_reached = 1;
379 <  else if (class->max_local != 0 && local >= class->max_local)
379 >  else if (class->max_local && local >= class->max_local)
380      a_limit_reached = 1;
381 <  else if (class->max_global != 0 && global >= class->max_global)
381 >  else if (class->max_global && global >= class->max_global)
382      a_limit_reached = 1;
383 <  else if (class->max_ident != 0 && ident >= class->max_ident &&
383 >  else if (class->max_ident && ident >= class->max_ident &&
384             client_p->username[0] != '~')
385      a_limit_reached = 1;
386  
# Line 427 | Line 396 | attach_iline(struct Client *client_p, st
396    return attach_conf(client_p, conf);
397   }
398  
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 –  int i;
608 –
609 –  *number_ips_stored = 0;
610 –  *mem_ips_stored    = 0;
611 –
612 –  for (i = 0; i < IP_HASH_SIZE; i++)
613 –  {
614 –    for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next)
615 –    {
616 –      *number_ips_stored += 1;
617 –      *mem_ips_stored += sizeof(struct ip_entry);
618 –    }
619 –  }
620 – }
621 –
622 – /* garbage_collect_ip_entries()
623 – *
624 – * input        - NONE
625 – * output       - NONE
626 – * side effects - free up all ip entries with no connections
627 – */
628 – static void
629 – garbage_collect_ip_entries(void)
630 – {
631 –  struct ip_entry *ptr;
632 –  struct ip_entry *last_ptr;
633 –  struct ip_entry *next_ptr;
634 –  int i;
635 –
636 –  for (i = 0; i < IP_HASH_SIZE; i++)
637 –  {
638 –    last_ptr = NULL;
639 –
640 –    for (ptr = ip_hash_table[i]; ptr; ptr = next_ptr)
641 –    {
642 –      next_ptr = ptr->next;
643 –
644 –      if (ptr->count == 0 &&
645 –          (CurrentTime - ptr->last_attempt) >= ConfigFileEntry.throttle_time)
646 –      {
647 –        if (last_ptr != NULL)
648 –          last_ptr->next = ptr->next;
649 –        else
650 –          ip_hash_table[i] = ptr->next;
651 –        mp_pool_release(ptr);
652 –        ip_entries_count--;
653 –      }
654 –      else
655 –        last_ptr = ptr;
656 –    }
657 –  }
658 – }
659 –
399   /* detach_conf()
400   *
401   * inputs       - pointer to client to detach
# Line 783 | Line 522 | find_conf_name(dlink_list *list, const c
522  
523      if (conf->type == type)
524      {
525 <      if (conf->name && (irccmp(conf->name, name) == 0 ||
525 >      if (conf->name && (!irccmp(conf->name, name) ||
526                           !match(conf->name, name)))
527        return conf;
528      }
# Line 977 | Line 716 | find_exact_name_conf(enum maskitem_type
716                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
717                      return conf;
718                break;
980 – #ifdef IPV6
719              case HM_IPV6:
720                if (who->localClient->aftype == AF_INET6)
721                  if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits))
722                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
723                      return conf;
724                break;
987 – #endif
725              default:
726                assert(0);
727            }
# Line 1039 | Line 776 | rehash(int sig)
776  
777    /* don't close listeners until we know we can go ahead with the rehash */
778  
1042 –  /* Check to see if we magically got(or lost) IPv6 support */
1043 –  check_can_use_v6();
1044 –
779    read_conf_files(0);
780  
781 <  if (ServerInfo.description)
782 <    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
781 >  if (ConfigServerInfo.description)
782 >    strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));
783  
784    load_conf_modules();
785 <
1052 <  rehashed_klines = 1;
785 >  check_conf_klines();
786  
787    return 0;
788   }
# Line 1072 | Line 805 | set_default_conf(void)
805    assert(class_default == class_get_list()->tail->data);
806  
807   #ifdef HAVE_LIBCRYPTO
808 <  ServerInfo.rsa_private_key = NULL;
809 <  ServerInfo.rsa_private_key_file = NULL;
808 >  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
809 >  ConfigServerInfo.rsa_private_key = NULL;
810 >  ConfigServerInfo.rsa_private_key_file = NULL;
811   #endif
812  
813 <  /* ServerInfo.name is not rehashable */
814 <  /* ServerInfo.name = ServerInfo.name; */
815 <  ServerInfo.description = NULL;
816 <  ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
817 <  ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
818 <
819 <  memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip));
820 <  ServerInfo.specific_ipv4_vhost = 0;
821 <  memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6));
822 <  ServerInfo.specific_ipv6_vhost = 0;
823 <
824 <  ServerInfo.max_clients = MAXCLIENTS_MAX;
825 <  ServerInfo.max_nick_length = 9;
826 <  ServerInfo.max_topic_length = 80;
827 <
828 <  ServerInfo.hub = 0;
829 <  ServerInfo.dns_host.sin_addr.s_addr = 0;
830 <  ServerInfo.dns_host.sin_port = 0;
831 <  AdminInfo.name = NULL;
1098 <  AdminInfo.email = NULL;
1099 <  AdminInfo.description = NULL;
813 >  /* ConfigServerInfo.name is not rehashable */
814 >  /* ConfigServerInfo.name = ConfigServerInfo.name; */
815 >  ConfigServerInfo.description = NULL;
816 >  ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
817 >  ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
818 >
819 >  memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip));
820 >  ConfigServerInfo.specific_ipv4_vhost = 0;
821 >  memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
822 >  ConfigServerInfo.specific_ipv6_vhost = 0;
823 >
824 >  ConfigServerInfo.max_clients = MAXCLIENTS_MAX;
825 >  ConfigServerInfo.max_nick_length = 9;
826 >  ConfigServerInfo.max_topic_length = 80;
827 >  ConfigServerInfo.hub = 0;
828 >
829 >  ConfigAdminInfo.name = NULL;
830 >  ConfigAdminInfo.email = NULL;
831 >  ConfigAdminInfo.description = NULL;
832  
833    log_del_all();
834  
835 <  ConfigLoggingEntry.use_logging = 1;
835 >  ConfigLog.use_logging = 1;
836  
837    ConfigChannel.disable_fake_channels = 0;
838 <  ConfigChannel.knock_delay = 300;
838 >  ConfigChannel.invite_client_count = 10;
839 >  ConfigChannel.invite_client_time = 300;
840 >  ConfigChannel.knock_client_count = 1;
841 >  ConfigChannel.knock_client_time = 300;
842    ConfigChannel.knock_delay_channel = 60;
843 <  ConfigChannel.max_chans_per_user = 25;
1109 <  ConfigChannel.max_chans_per_oper = 50;
843 >  ConfigChannel.max_channels = 25;
844    ConfigChannel.max_bans = 25;
845    ConfigChannel.default_split_user_count = 0;
846    ConfigChannel.default_split_server_count = 0;
# Line 1122 | Line 856 | set_default_conf(void)
856    ConfigServerHide.hide_server_ips = 0;
857    ConfigServerHide.disable_remote_commands = 0;
858  
859 <  ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
860 <  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
861 <  ConfigFileEntry.cycle_on_host_change = 1;
862 <  ConfigFileEntry.glines = 0;
863 <  ConfigFileEntry.gline_time = 12 * 3600;
864 <  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
865 <  ConfigFileEntry.gline_min_cidr = 16;
866 <  ConfigFileEntry.gline_min_cidr6 = 48;
867 <  ConfigFileEntry.invisible_on_connect = 1;
868 <  ConfigFileEntry.tkline_expire_notices = 1;
869 <  ConfigFileEntry.hide_spoof_ips = 1;
870 <  ConfigFileEntry.ignore_bogus_ts = 0;
871 <  ConfigFileEntry.disable_auth = 0;
872 <  ConfigFileEntry.kill_chase_time_limit = 90;
873 <  ConfigFileEntry.default_floodcount = 8;
874 <  ConfigFileEntry.failed_oper_notice = 1;
875 <  ConfigFileEntry.dots_in_ident = 0;
876 <  ConfigFileEntry.min_nonwildcard = 4;
877 <  ConfigFileEntry.min_nonwildcard_simple = 3;
878 <  ConfigFileEntry.max_accept = 20;
879 <  ConfigFileEntry.anti_nick_flood = 0;
880 <  ConfigFileEntry.max_nick_time = 20;
881 <  ConfigFileEntry.max_nick_changes = 5;
882 <  ConfigFileEntry.anti_spam_exit_message_time = 0;
883 <  ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
884 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
885 <  ConfigFileEntry.warn_no_nline = 1;
886 <  ConfigFileEntry.stats_o_oper_only = 0;
887 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
888 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
889 <  ConfigFileEntry.stats_P_oper_only = 0;
890 <  ConfigFileEntry.stats_u_oper_only = 0;
891 <  ConfigFileEntry.caller_id_wait = 60;
892 <  ConfigFileEntry.opers_bypass_callerid = 0;
893 <  ConfigFileEntry.pace_wait = 10;
894 <  ConfigFileEntry.pace_wait_simple = 1;
895 <  ConfigFileEntry.short_motd = 0;
896 <  ConfigFileEntry.ping_cookie = 0;
897 <  ConfigFileEntry.no_oper_flood = 0;
898 <  ConfigFileEntry.true_no_oper_flood = 0;
899 <  ConfigFileEntry.oper_pass_resv = 1;
900 <  ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
901 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
902 <  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
903 <    UMODE_OPERWALL | UMODE_WALLOP;
904 <  ConfigFileEntry.use_egd = 0;
905 <  ConfigFileEntry.egdpool_path = NULL;
906 <  ConfigFileEntry.throttle_time = 10;
859 >  ConfigGeneral.away_count = 2;
860 >  ConfigGeneral.away_time = 10;
861 >  ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT);
862 >  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
863 >  ConfigGeneral.cycle_on_host_change = 1;
864 >  ConfigGeneral.glines = 0;
865 >  ConfigGeneral.gline_time = 12 * 3600;
866 >  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
867 >  ConfigGeneral.gline_min_cidr = 16;
868 >  ConfigGeneral.gline_min_cidr6 = 48;
869 >  ConfigGeneral.invisible_on_connect = 1;
870 >  ConfigGeneral.tkline_expire_notices = 1;
871 >  ConfigGeneral.hide_spoof_ips = 1;
872 >  ConfigGeneral.ignore_bogus_ts = 0;
873 >  ConfigGeneral.disable_auth = 0;
874 >  ConfigGeneral.kill_chase_time_limit = 90;
875 >  ConfigGeneral.default_floodcount = 8;
876 >  ConfigGeneral.failed_oper_notice = 1;
877 >  ConfigGeneral.dots_in_ident = 0;
878 >  ConfigGeneral.min_nonwildcard = 4;
879 >  ConfigGeneral.min_nonwildcard_simple = 3;
880 >  ConfigGeneral.max_accept = 20;
881 >  ConfigGeneral.anti_nick_flood = 0;
882 >  ConfigGeneral.max_nick_time = 20;
883 >  ConfigGeneral.max_nick_changes = 5;
884 >  ConfigGeneral.anti_spam_exit_message_time = 0;
885 >  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
886 >  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
887 >  ConfigGeneral.warn_no_connect_block = 1;
888 >  ConfigGeneral.stats_e_disabled = 0;
889 >  ConfigGeneral.stats_o_oper_only = 0;
890 >  ConfigGeneral.stats_k_oper_only = 1;  /* 1 = masked */
891 >  ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
892 >  ConfigGeneral.stats_P_oper_only = 0;
893 >  ConfigGeneral.stats_u_oper_only = 0;
894 >  ConfigGeneral.caller_id_wait = 60;
895 >  ConfigGeneral.opers_bypass_callerid = 0;
896 >  ConfigGeneral.pace_wait = 10;
897 >  ConfigGeneral.pace_wait_simple = 1;
898 >  ConfigGeneral.short_motd = 0;
899 >  ConfigGeneral.ping_cookie = 0;
900 >  ConfigGeneral.no_oper_flood = 0;
901 >  ConfigGeneral.true_no_oper_flood = 0;
902 >  ConfigGeneral.oper_pass_resv = 1;
903 >  ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
904 >  ConfigGeneral.oper_only_umodes = UMODE_DEBUG;
905 >  ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
906 >  ConfigGeneral.throttle_count = 1;
907 >  ConfigGeneral.throttle_time = 1;
908   }
909  
910   static void
911   validate_conf(void)
912   {
913 <  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
914 <    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
913 >  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
914 >    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
915  
916 <  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
917 <    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
916 >  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
917 >    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
918  
919 <  if (ServerInfo.network_name == NULL)
920 <    ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
919 >  if (ConfigServerInfo.network_name == NULL)
920 >    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
921  
922 <  if (ServerInfo.network_desc == NULL)
923 <    ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
922 >  if (ConfigServerInfo.network_desc == NULL)
923 >    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
924  
925 <  if (ConfigFileEntry.service_name == NULL)
926 <    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
925 >  if (ConfigGeneral.service_name == NULL)
926 >    ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT);
927  
928 <  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
928 >  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
929   }
930  
931   /* read_conf()
# Line 1204 | Line 939 | read_conf(FILE *file)
939   {
940    lineno = 0;
941  
942 <  set_default_conf(); /* Set default values prior to conf parsing */
942 >  set_default_conf();  /* Set default values prior to conf parsing */
943    conf_parser_ctx.pass = 1;
944 <  yyparse();          /* pick up the classes first */
944 >  yyparse();  /* Pick up the classes first */
945  
946    rewind(file);
947  
948    conf_parser_ctx.pass = 2;
949 <  yyparse();          /* Load the values from the conf */
950 <  validate_conf();    /* Check to make sure some values are still okay. */
951 <                      /* Some global values are also loaded here. */
952 <  class_delete_marked();      /* Make sure classes are valid */
949 >  yyparse();  /* Load the values from the conf */
950 >  validate_conf();  /* Check to make sure some values are still okay. */
951 >                    /* Some global values are also loaded here. */
952 >  class_delete_marked();  /* Delete unused classes that are marked for deletion */
953   }
954  
955   /* lookup_confhost()
# Line 1227 | Line 962 | lookup_confhost(struct MaskItem *conf)
962   {
963    struct addrinfo hints, *res;
964  
965 <  /* Do name lookup now on hostnames given and store the
965 >  /*
966 >   * Do name lookup now on hostnames given and store the
967     * ip numbers in conf structure.
968     */
969    memset(&hints, 0, sizeof(hints));
# Line 1263 | Line 999 | lookup_confhost(struct MaskItem *conf)
999   int
1000   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
1001   {
1002 <  struct ip_entry *ip_found;
1002 >  struct ip_entry *ip_found = NULL;
1003    struct MaskItem *conf = find_dline_conf(addr, aftype);
1004  
1005    /* DLINE exempt also gets you out of static limits/pacing... */
# Line 1273 | Line 1009 | conf_connect_allowed(struct irc_ssaddr *
1009    if (conf)
1010      return BANNED_CLIENT;
1011  
1012 <  ip_found = find_or_add_ip(addr);
1012 >  ip_found = ipcache_find_or_add_address(addr);
1013  
1014 <  if ((CurrentTime - ip_found->last_attempt) <
1279 <      ConfigFileEntry.throttle_time)
1014 >  if ((CurrentTime - ip_found->last_attempt) < ConfigGeneral.throttle_time)
1015    {
1016 <    ip_found->last_attempt = CurrentTime;
1017 <    return TOO_FAST;
1016 >    if (ip_found->connection_count >= ConfigGeneral.throttle_count)
1017 >      return TOO_FAST;
1018 >
1019 >    ++ip_found->connection_count;
1020    }
1021 +  else
1022 +    ip_found->connection_count = 1;
1023  
1024    ip_found->last_attempt = CurrentTime;
1025    return 0;
# Line 1294 | Line 1033 | conf_connect_allowed(struct irc_ssaddr *
1033   *                This is an event started off in ircd.c
1034   */
1035   void
1036 < cleanup_tklines(void *notused)
1036 > cleanup_tklines(void *unused)
1037   {
1038    hostmask_expire_temporary();
1039    expire_tklines(&xconf_items);
# Line 1323 | Line 1062 | expire_tklines(dlink_list *tklist)
1062  
1063      if (conf->type == CONF_XLINE)
1064      {
1065 <      if (ConfigFileEntry.tkline_expire_notices)
1065 >      if (ConfigGeneral.tkline_expire_notices)
1066          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1067                                 "Temporary X-line for [%s] expired", conf->name);
1068        conf_free(conf);
1069      }
1070      else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1071      {
1072 <      if (ConfigFileEntry.tkline_expire_notices)
1072 >      if (ConfigGeneral.tkline_expire_notices)
1073          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1074                                 "Temporary RESV for [%s] expired", conf->name);
1075        conf_free(conf);
# Line 1354 | Line 1093 | static const struct oper_privs
1093    { OPER_FLAG_DIE,            'D' },
1094    { OPER_FLAG_GLINE,          'G' },
1095    { OPER_FLAG_REHASH,         'H' },
1096 <  { OPER_FLAG_K,              'K' },
1358 <  { OPER_FLAG_OPERWALL,       'L' },
1096 >  { OPER_FLAG_KLINE,          'K' },
1097    { OPER_FLAG_KILL,           'N' },
1098    { OPER_FLAG_KILL_REMOTE,    'O' },
1099    { OPER_FLAG_CONNECT,        'P' },
# Line 1387 | Line 1125 | oper_privs_as_string(const unsigned int
1125   }
1126  
1127   /*
1128 < * Input: A client to find the active oper{} name for.
1128 > * Input: A client to find the active operator {} name for.
1129   * Output: The nick!user@host{oper} of the oper.
1130   *         "oper" is server name for remote opers
1131   * Side effects: None.
# Line 1413 | Line 1151 | get_oper_name(const struct Client *clien
1151        }
1152      }
1153  
1154 <    /* Probably should assert here for now. If there is an oper out there
1155 <     * with no oper{} conf attached, it would be good for us to know...
1154 >    /*
1155 >     * Probably should assert here for now. If there is an oper out there
1156 >     * with no operator {} conf attached, it would be good for us to know...
1157       */
1158 <    assert(0); /* Oper without oper conf! */
1158 >    assert(0);  /* Oper without oper conf! */
1159    }
1160  
1161    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
# Line 1433 | Line 1172 | get_oper_name(const struct Client *clien
1172   void
1173   read_conf_files(int cold)
1174   {
1175 <  const char *filename;
1176 <  char chanmodes[IRCD_BUFSIZE];
1177 <  char chanlimit[IRCD_BUFSIZE];
1175 >  const char *filename = NULL;
1176 >  char chanmodes[IRCD_BUFSIZE] = "";
1177 >  char chanlimit[IRCD_BUFSIZE] = "";
1178  
1179    conf_parser_ctx.boot = cold;
1180 <  filename = ConfigFileEntry.configfile;
1180 >  filename = ConfigGeneral.configfile;
1181  
1182    /* We need to know the initial filename for the yyerror() to report
1183       FIXME: The full path is in conffilenamebuf first time since we
1184 <             dont know anything else
1184 >             don't know anything else
1185  
1186       - Gozem 2002-07-21
1187    */
# Line 1473 | Line 1212 | read_conf_files(int cold)
1212  
1213    log_reopen_all();
1214  
1215 <  add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1216 <  add_isupport("NETWORK", ServerInfo.network_name, -1);
1215 >  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1216 >  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1217  
1218    snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1219    add_isupport("MAXLIST", chanmodes, -1);
1220 <  add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
1220 >  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1221    add_isupport("CHANTYPES", "#", -1);
1222  
1223    snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1224 <           ConfigChannel.max_chans_per_user);
1224 >           ConfigChannel.max_channels);
1225    add_isupport("CHANLIMIT", chanlimit, -1);
1226 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1227 <  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1228 <  add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1226 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1227 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1228 >  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1229    add_isupport("CHANMODES", chanmodes, -1);
1230  
1231    /*
# Line 1556 | Line 1295 | clear_out_old_conf(void)
1295    /* clean out module paths */
1296    mod_clear_paths();
1297  
1298 <  /* clean out ServerInfo */
1299 <  MyFree(ServerInfo.description);
1300 <  ServerInfo.description = NULL;
1301 <  MyFree(ServerInfo.network_name);
1302 <  ServerInfo.network_name = NULL;
1303 <  MyFree(ServerInfo.network_desc);
1304 <  ServerInfo.network_desc = NULL;
1566 <  MyFree(ConfigFileEntry.egdpool_path);
1567 <  ConfigFileEntry.egdpool_path = NULL;
1298 >  /* clean out ConfigServerInfo */
1299 >  MyFree(ConfigServerInfo.description);
1300 >  ConfigServerInfo.description = NULL;
1301 >  MyFree(ConfigServerInfo.network_name);
1302 >  ConfigServerInfo.network_name = NULL;
1303 >  MyFree(ConfigServerInfo.network_desc);
1304 >  ConfigServerInfo.network_desc = NULL;
1305   #ifdef HAVE_LIBCRYPTO
1306 <  if (ServerInfo.rsa_private_key)
1306 >  if (ConfigServerInfo.rsa_private_key)
1307    {
1308 <    RSA_free(ServerInfo.rsa_private_key);
1309 <    ServerInfo.rsa_private_key = NULL;
1308 >    RSA_free(ConfigServerInfo.rsa_private_key);
1309 >    ConfigServerInfo.rsa_private_key = NULL;
1310    }
1311  
1312 <  MyFree(ServerInfo.rsa_private_key_file);
1313 <  ServerInfo.rsa_private_key_file = NULL;
1577 <
1578 <  if (ServerInfo.server_ctx)
1579 <    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
1580 <                                               SSL_OP_NO_SSLv3|
1581 <                                               SSL_OP_NO_TLSv1);
1582 <  if (ServerInfo.client_ctx)
1583 <    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
1584 <                                               SSL_OP_NO_SSLv3|
1585 <                                               SSL_OP_NO_TLSv1);
1312 >  MyFree(ConfigServerInfo.rsa_private_key_file);
1313 >  ConfigServerInfo.rsa_private_key_file = NULL;
1314   #endif
1315  
1316 <  /* clean out AdminInfo */
1317 <  MyFree(AdminInfo.name);
1318 <  AdminInfo.name = NULL;
1319 <  MyFree(AdminInfo.email);
1320 <  AdminInfo.email = NULL;
1321 <  MyFree(AdminInfo.description);
1322 <  AdminInfo.description = NULL;
1316 >  /* clean out ConfigAdminInfo */
1317 >  MyFree(ConfigAdminInfo.name);
1318 >  ConfigAdminInfo.name = NULL;
1319 >  MyFree(ConfigAdminInfo.email);
1320 >  ConfigAdminInfo.email = NULL;
1321 >  MyFree(ConfigAdminInfo.description);
1322 >  ConfigAdminInfo.description = NULL;
1323  
1324    /* clean out listeners */
1325    close_listeners();
1326  
1327    /* clean out general */
1328 <  MyFree(ConfigFileEntry.service_name);
1329 <  ConfigFileEntry.service_name = NULL;
1328 >  MyFree(ConfigGeneral.service_name);
1329 >  ConfigGeneral.service_name = NULL;
1330   }
1331  
1332   /* conf_add_class_to_conf()
# Line 1735 | Line 1463 | valid_wild_card_simple(const char *data)
1463   {
1464    const unsigned char *p = (const unsigned char *)data;
1465    unsigned char tmpch = '\0';
1466 <  int nonwild = 0;
1466 >  unsigned int nonwild = 0;
1467  
1468    while ((tmpch = *p++))
1469    {
1470 <    if (tmpch == '\\')
1470 >    if (tmpch == '\\' && *p)
1471      {
1472        ++p;
1473 <      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1473 >      if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1474          return 1;
1475      }
1476      else if (!IsMWildChar(tmpch))
1477      {
1478 <      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1478 >      if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1479          return 1;
1480      }
1481    }
# Line 1766 | Line 1494 | valid_wild_card_simple(const char *data)
1494   int
1495   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1496   {
1497 <  char tmpch;
1498 <  int nonwild = 0;
1497 >  unsigned char tmpch = '\0';
1498 >  unsigned int nonwild = 0;
1499    va_list args;
1500  
1501    /*
# Line 1786 | Line 1514 | valid_wild_card(struct Client *source_p,
1514  
1515    while (count--)
1516    {
1517 <    const char *p = va_arg(args, const char *);
1517 >    const unsigned char *p = va_arg(args, const unsigned char *);
1518      if (p == NULL)
1519        continue;
1520  
# Line 1798 | Line 1526 | valid_wild_card(struct Client *source_p,
1526           * If we find enough non-wild characters, we can
1527           * break - no point in searching further.
1528           */
1529 <        if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1529 >        if (++nonwild >= ConfigGeneral.min_nonwildcard)
1530          {
1531            va_end(args);
1532            return 1;
# Line 1809 | Line 1537 | valid_wild_card(struct Client *source_p,
1537  
1538    if (warn)
1539      sendto_one_notice(source_p, &me,
1540 <                      ":Please include at least %d non-wildcard characters with the mask",
1541 <                      ConfigFileEntry.min_nonwildcard);
1540 >                      ":Please include at least %u non-wildcard characters with the mask",
1541 >                      ConfigGeneral.min_nonwildcard);
1542    va_end(args);
1543    return 0;
1544   }
# Line 1852 | Line 1580 | parse_aline(const char *cmd, struct Clie
1580              char **target_server, char **reason)
1581   {
1582    int found_tkline_time=0;
1583 <  static char def_reason[] = "No Reason";
1583 >  static char def_reason[] = CONF_NOREASON;
1584    static char user[USERLEN*4+1];
1585    static char host[HOSTLEN*4+1];
1586  
# Line 2018 | Line 1746 | find_user_host(struct Client *source_p,
1746      /* Okay to use source_p as the first param, because source_p == client_p */
1747      if ((target_p =
1748          find_chasing(source_p, user_host_or_nick)) == NULL)
1749 <      return 0;
1749 >      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1750  
1751      if (IsExemptKline(target_p))
1752      {
# Line 2104 | Line 1832 | cluster_a_line(struct Client *source_p,
1832                 int capab, int cluster_type, const char *pattern, ...)
1833   {
1834    va_list args;
1835 <  char buffer[IRCD_BUFSIZE];
1835 >  char buffer[IRCD_BUFSIZE] = "";
1836    const dlink_node *ptr = NULL;
1837  
1838    va_start(args, pattern);
# Line 2165 | Line 1893 | split_nuh(struct split_nuh_item *const i
1893    {
1894      *p = '\0';
1895  
1896 <    if (iptr->nickptr && *iptr->nuhmask != '\0')
1896 >    if (iptr->nickptr && *iptr->nuhmask)
1897        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
1898  
1899      if ((q = strchr(++p, '@')))
1900      {
1901        *q++ = '\0';
1902  
1903 <      if (*p != '\0')
1903 >      if (*p)
1904          strlcpy(iptr->userptr, p, iptr->usersize);
1905  
1906 <      if (*q != '\0')
1906 >      if (*q)
1907          strlcpy(iptr->hostptr, q, iptr->hostsize);
1908      }
1909      else
1910      {
1911 <      if (*p != '\0')
1911 >      if (*p)
1912          strlcpy(iptr->userptr, p, iptr->usersize);
1913      }
1914    }
# Line 2192 | Line 1920 | split_nuh(struct split_nuh_item *const i
1920        /* if found a @ */
1921        *p++ = '\0';
1922  
1923 <      if (*iptr->nuhmask != '\0')
1923 >      if (*iptr->nuhmask)
1924          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
1925  
1926 <      if (*p != '\0')
1926 >      if (*p)
1927          strlcpy(iptr->hostptr, p, iptr->hostsize);
1928      }
1929      else

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)