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 4977 by michael, Thu Dec 4 15:12:24 2014 UTC

# Line 15 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 28 | Line 28
28   #include "list.h"
29   #include "ircd_defs.h"
30   #include "conf.h"
31 + #include "conf_pseudo.h"
32   #include "server.h"
33   #include "resv.h"
34   #include "channel.h"
# Line 44 | Line 45
45   #include "log.h"
46   #include "send.h"
47   #include "memory.h"
47 – #include "mempool.h"
48   #include "res.h"
49   #include "userhost.h"
50   #include "user.h"
# Line 54 | Line 54
54   #include "conf_db.h"
55   #include "conf_class.h"
56   #include "motd.h"
57 + #include "ipcache.h"
58  
59  
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 –
60   /* general conf items link list root, other than k lines etc. */
61   dlink_list service_items = { NULL, NULL, 0 };
62   dlink_list server_items  = { NULL, NULL, 0 };
# Line 71 | Line 65 | dlink_list oconf_items   = { NULL, NULL,
65   dlink_list uconf_items   = { NULL, NULL, 0 };
66   dlink_list xconf_items   = { NULL, NULL, 0 };
67   dlink_list nresv_items   = { NULL, NULL, 0 };
68 < dlink_list cresv_items = { NULL, NULL, 0 };
68 > dlink_list cresv_items   = { NULL, NULL, 0 };
69  
70   extern unsigned int lineno;
71   extern char linebuf[];
72   extern char conffilebuf[IRCD_BUFSIZE];
73   extern int yyparse(); /* defined in y.tab.c */
74  
81 – struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
82 –
75   /* internally defined functions */
76   static void read_conf(FILE *);
77   static void clear_out_old_conf(void);
78   static void expire_tklines(dlink_list *);
87 – static void garbage_collect_ip_entries(void);
88 – static int hash_ip(struct irc_ssaddr *);
79   static int verify_access(struct Client *);
80   static int attach_iline(struct Client *, struct MaskItem *);
91 – static struct ip_entry *find_or_add_ip(struct irc_ssaddr *);
81   static dlink_list *map_to_list(enum maskitem_type);
82   static int find_user_host(struct Client *, char *, char *, char *, unsigned int);
83  
84  
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 –
85   /* conf_dns_callback()
86   *
87   * inputs       - pointer to struct MaskItem
# Line 123 | Line 93 | static int ip_entries_count = 0;
93   * if successful save hp in the conf item it was called with
94   */
95   static void
96 < conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
96 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name, size_t namelength)
97   {
98 <  struct MaskItem *conf = vptr;
98 >  struct MaskItem *const conf = vptr;
99  
100    conf->dns_pending = 0;
101  
# Line 147 | Line 117 | conf_dns_lookup(struct MaskItem *conf)
117    if (!conf->dns_pending)
118    {
119      conf->dns_pending = 1;
120 <    gethost_byname(conf_dns_callback, conf, conf->host);
120 >
121 >    if (conf->aftype == AF_INET)
122 >      gethost_byname_type(conf_dns_callback, conf, conf->host, T_A);
123 >    else
124 >      gethost_byname_type(conf_dns_callback, conf, conf->host, T_AAAA);
125    }
126   }
127  
128   struct MaskItem *
129   conf_make(enum maskitem_type type)
130   {
131 <  struct MaskItem *conf = MyMalloc(sizeof(*conf));
131 >  struct MaskItem *const conf = MyCalloc(sizeof(*conf));
132    dlink_list *list = NULL;
133  
134    conf->type   = type;
# Line 169 | Line 143 | conf_make(enum maskitem_type type)
143   void
144   conf_free(struct MaskItem *conf)
145   {
146 <  dlink_node *ptr = NULL, *ptr_next = NULL;
146 >  dlink_node *node = NULL, *node_next = NULL;
147    dlink_list *list = NULL;
148  
149 <  if (conf->node.next)
150 <    if ((list = map_to_list(conf->type)))
177 <      dlinkDelete(&conf->node, list);
149 >  if ((list = map_to_list(conf->type)))
150 >    dlinkFindDelete(list, conf);
151  
152    MyFree(conf->name);
153  
# Line 199 | Line 172 | conf_free(struct MaskItem *conf)
172    if (conf->rsa_public_key)
173      RSA_free(conf->rsa_public_key);
174   #endif
175 <  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head)
175 >  DLINK_FOREACH_SAFE(node, node_next, conf->hub_list.head)
176    {
177 <    MyFree(ptr->data);
178 <    dlinkDelete(ptr, &conf->hub_list);
179 <    free_dlink_node(ptr);
177 >    MyFree(node->data);
178 >    dlinkDelete(node, &conf->hub_list);
179 >    free_dlink_node(node);
180    }
181  
182 <  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head)
182 >  DLINK_FOREACH_SAFE(node, node_next, conf->leaf_list.head)
183    {
184 <    MyFree(ptr->data);
185 <    dlinkDelete(ptr, &conf->leaf_list);
186 <    free_dlink_node(ptr);
184 >    MyFree(node->data);
185 >    dlinkDelete(node, &conf->leaf_list);
186 >    free_dlink_node(node);
187    }
188  
189 <  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->exempt_list.head)
189 >  DLINK_FOREACH_SAFE(node, node_next, conf->exempt_list.head)
190    {
191 <    struct exempt *exptr = ptr->data;
191 >    struct exempt *exptr = node->data;
192  
193 <    dlinkDelete(ptr, &conf->exempt_list);
193 >    dlinkDelete(node, &conf->exempt_list);
194      MyFree(exptr->name);
195      MyFree(exptr->user);
196      MyFree(exptr->host);
# Line 281 | Line 254 | check_client(struct Client *source_p)
254                             "Unauthorized client connection from %s [%s] on [%s/%u].",
255                             get_client_name(source_p, SHOW_IP),
256                             source_p->sockhost,
257 <                           source_p->localClient->listener->name,
258 <                           source_p->localClient->listener->port);
257 >                           source_p->connection->listener->name,
258 >                           source_p->connection->listener->port);
259        ilog(LOG_TYPE_IRCD,
260             "Unauthorized client connection from %s on [%s/%u].",
261             get_client_name(source_p, SHOW_IP),
262 <           source_p->localClient->listener->name,
263 <           source_p->localClient->listener->port);
262 >           source_p->connection->listener->name,
263 >           source_p->connection->listener->port);
264  
265        exit_client(source_p, "You are not authorized to use this server");
266        break;
# Line 320 | Line 293 | verify_access(struct Client *client_p)
293    if (IsGotId(client_p))
294    {
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);
296 >                             &client_p->connection->ip,
297 >                             client_p->connection->aftype,
298 >                             client_p->connection->password);
299    }
300    else
301    {
302      strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
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);
304 >                             &client_p->connection->ip,
305 >                             client_p->connection->aftype,
306 >                             client_p->connection->password);
307    }
308  
309    if (conf)
# Line 345 | Line 318 | verify_access(struct Client *client_p)
318          return NOT_AUTHORIZED;
319        }
320  
348 –      if (IsConfDoIdentd(conf))
349 –        SetNeedId(client_p);
350 –
321        /* Thanks for spoof idea amm */
322        if (IsConfDoSpoofIp(conf))
323        {
324 <        if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(conf))
324 >        if (IsConfSpoofNotice(conf))
325            sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
326                                 "%s spoofing: %s as %s",
327                                 client_p->name, client_p->host, conf->name);
328          strlcpy(client_p->host, conf->name, sizeof(client_p->host));
359 –        AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF);
329        }
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");
# Line 383 | Line 352 | verify_access(struct Client *client_p)
352   static int
353   attach_iline(struct Client *client_p, struct MaskItem *conf)
354   {
355 <  struct ClassItem *class = NULL;
355 >  const struct ClassItem *const 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->connection->ip);
361    ip_found->count++;
362 <  SetIpHash(client_p);
396 <
397 <  class = conf->class;
362 >  AddFlag(client_p, FLAGS_IPHASH);
363  
364    count_user_host(client_p->username, client_p->host,
365                    &global, &local, &ident);
# Line 403 | Line 368 | attach_iline(struct Client *client_p, st
368     * setting a_limit_reached if any limit is reached.
369     * - Dianora
370     */
371 <  if (class->max_total != 0 && class->ref_count >= class->max_total)
371 >  if (class->max_total && class->ref_count >= class->max_total)
372      a_limit_reached = 1;
373 <  else if (class->max_perip != 0 && ip_found->count > class->max_perip)
373 >  else if (class->max_perip && ip_found->count > class->max_perip)
374      a_limit_reached = 1;
375 <  else if (class->max_local != 0 && local >= class->max_local)
375 >  else if (class->max_local && local >= class->max_local)
376      a_limit_reached = 1;
377 <  else if (class->max_global != 0 && global >= class->max_global)
377 >  else if (class->max_global && global >= class->max_global)
378      a_limit_reached = 1;
379 <  else if (class->max_ident != 0 && ident >= class->max_ident &&
379 >  else if (class->max_ident && ident >= class->max_ident &&
380             client_p->username[0] != '~')
381      a_limit_reached = 1;
382  
# Line 427 | Line 392 | attach_iline(struct Client *client_p, st
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 –  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 –
395   /* detach_conf()
396   *
397   * inputs       - pointer to client to detach
# Line 668 | Line 403 | garbage_collect_ip_entries(void)
403   void
404   detach_conf(struct Client *client_p, enum maskitem_type type)
405   {
406 <  dlink_node *ptr = NULL, *ptr_next = NULL;
406 >  dlink_node *node = NULL, *node_next = NULL;
407  
408 <  DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head)
408 >  DLINK_FOREACH_SAFE(node, node_next, client_p->connection->confs.head)
409    {
410 <    struct MaskItem *conf = ptr->data;
410 >    struct MaskItem *conf = node->data;
411  
412      assert(conf->type & (CONF_CLIENT | CONF_OPER | CONF_SERVER));
413      assert(conf->ref_count > 0);
# Line 681 | Line 416 | detach_conf(struct Client *client_p, enu
416      if (!(conf->type & type))
417        continue;
418  
419 <    dlinkDelete(ptr, &client_p->localClient->confs);
420 <    free_dlink_node(ptr);
419 >    dlinkDelete(node, &client_p->connection->confs);
420 >    free_dlink_node(node);
421  
422      if (conf->type == CONF_CLIENT)
423 <      remove_from_cidr_check(&client_p->localClient->ip, conf->class);
423 >      remove_from_cidr_check(&client_p->connection->ip, conf->class);
424  
425      if (--conf->class->ref_count == 0 && conf->class->active == 0)
426      {
# Line 711 | Line 446 | detach_conf(struct Client *client_p, enu
446   int
447   attach_conf(struct Client *client_p, struct MaskItem *conf)
448   {
449 <  if (dlinkFind(&client_p->localClient->confs, conf))
449 >  if (dlinkFind(&client_p->connection->confs, conf))
450      return 1;
451  
452    if (conf->type == CONF_CLIENT)
453      if (cidr_limit_reached(IsConfExemptLimits(conf),
454 <                           &client_p->localClient->ip, conf->class))
454 >                           &client_p->connection->ip, conf->class))
455        return TOO_MANY;    /* Already at maximum allowed */
456  
457    conf->class->ref_count++;
458    conf->ref_count++;
459  
460 <  dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
460 >  dlinkAdd(conf, make_dlink_node(), &client_p->connection->confs);
461  
462    return 0;
463   }
# Line 739 | Line 474 | int
474   attach_connect_block(struct Client *client_p, const char *name,
475                       const char *host)
476   {
477 <  dlink_node *ptr;
743 <  struct MaskItem *conf = NULL;
477 >  dlink_node *node = NULL;
478  
479    assert(client_p != NULL);
480    assert(host != NULL);
# Line 748 | Line 482 | attach_connect_block(struct Client *clie
482    if (client_p == NULL || host == NULL)
483      return 0;
484  
485 <  DLINK_FOREACH(ptr, server_items.head)
485 >  DLINK_FOREACH(node, server_items.head)
486    {
487 <    conf = ptr->data;
487 >    struct MaskItem *conf = node->data;
488  
489      if (match(conf->name, name) || match(conf->host, host))
490        continue;
# Line 774 | Line 508 | attach_connect_block(struct Client *clie
508   struct MaskItem *
509   find_conf_name(dlink_list *list, const char *name, enum maskitem_type type)
510   {
511 <  dlink_node *ptr;
778 <  struct MaskItem* conf;
511 >  dlink_node *node = NULL;
512  
513 <  DLINK_FOREACH(ptr, list->head)
513 >  DLINK_FOREACH(node, list->head)
514    {
515 <    conf = ptr->data;
515 >    struct MaskItem *conf = node->data;
516  
517      if (conf->type == type)
518      {
519 <      if (conf->name && (irccmp(conf->name, name) == 0 ||
520 <                         !match(conf->name, name)))
788 <      return conf;
519 >      if (conf->name && !irccmp(conf->name, name))
520 >        return conf;
521      }
522    }
523  
# Line 845 | Line 577 | struct MaskItem *
577   find_matching_name_conf(enum maskitem_type type, const char *name, const char *user,
578                          const char *host, unsigned int flags)
579   {
580 <  dlink_node *ptr=NULL;
581 <  struct MaskItem *conf=NULL;
582 <  dlink_list *list_p = map_to_list(type);
580 >  dlink_node *node = NULL;
581 >  dlink_list *list = map_to_list(type);
582 >  struct MaskItem *conf = NULL;
583  
584    switch (type)
585    {
586    case CONF_SERVICE:
587 <    DLINK_FOREACH(ptr, list_p->head)
587 >    DLINK_FOREACH(node, list->head)
588      {
589 <      conf = ptr->data;
589 >      conf = node->data;
590  
591        if (EmptyString(conf->name))
592          continue;
# Line 867 | Line 599 | find_matching_name_conf(enum maskitem_ty
599    case CONF_ULINE:
600    case CONF_NRESV:
601    case CONF_CRESV:
602 <    DLINK_FOREACH(ptr, list_p->head)
602 >    DLINK_FOREACH(node, list->head)
603      {
604 <      conf = ptr->data;
604 >      conf = node->data;
605  
606        if (EmptyString(conf->name))
607          continue;
# Line 888 | Line 620 | find_matching_name_conf(enum maskitem_ty
620        break;
621  
622    case CONF_SERVER:
623 <    DLINK_FOREACH(ptr, list_p->head)
623 >    DLINK_FOREACH(node, list->head)
624      {
625 <      conf = ptr->data;
625 >      conf = node->data;
626  
627        if ((name != NULL) && !match(name, conf->name))
628          return conf;
# Line 918 | Line 650 | struct MaskItem *
650   find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name,
651                       const char *user, const char *host)
652   {
653 <  dlink_node *ptr = NULL;
654 <  struct MaskItem *conf;
655 <  dlink_list *list_p = map_to_list(type);
653 >  dlink_node *node = NULL;
654 >  dlink_list *list = map_to_list(type);
655 >  struct MaskItem *conf = NULL;
656  
657    switch(type)
658    {
# Line 929 | Line 661 | find_exact_name_conf(enum maskitem_type
661    case CONF_NRESV:
662    case CONF_CRESV:
663  
664 <    DLINK_FOREACH(ptr, list_p->head)
664 >    DLINK_FOREACH(node, list->head)
665      {
666 <      conf = ptr->data;
666 >      conf = node->data;
667  
668        if (EmptyString(conf->name))
669          continue;
# Line 949 | Line 681 | find_exact_name_conf(enum maskitem_type
681      break;
682  
683    case CONF_OPER:
684 <    DLINK_FOREACH(ptr, list_p->head)
684 >    DLINK_FOREACH(node, list->head)
685      {
686 <      conf = ptr->data;
686 >      conf = node->data;
687  
688        if (EmptyString(conf->name))
689          continue;
# Line 972 | Line 704 | find_exact_name_conf(enum maskitem_type
704                    return conf;
705                break;
706              case HM_IPV4:
707 <              if (who->localClient->aftype == AF_INET)
708 <                if (match_ipv4(&who->localClient->ip, &conf->addr, conf->bits))
707 >              if (who->connection->aftype == AF_INET)
708 >                if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
709                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
710                      return conf;
711                break;
980 – #ifdef IPV6
712              case HM_IPV6:
713 <              if (who->localClient->aftype == AF_INET6)
714 <                if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits))
713 >              if (who->connection->aftype == AF_INET6)
714 >                if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
715                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
716                      return conf;
717                break;
987 – #endif
718              default:
719                assert(0);
720            }
# Line 995 | Line 725 | find_exact_name_conf(enum maskitem_type
725      break;
726  
727    case CONF_SERVER:
728 <    DLINK_FOREACH(ptr, list_p->head)
728 >    DLINK_FOREACH(node, list->head)
729      {
730 <      conf = ptr->data;
730 >      conf = node->data;
731  
732        if (EmptyString(conf->name))
733          continue;
# Line 1039 | Line 769 | rehash(int sig)
769  
770    /* don't close listeners until we know we can go ahead with the rehash */
771  
1042 –  /* Check to see if we magically got(or lost) IPv6 support */
1043 –  check_can_use_v6();
1044 –
772    read_conf_files(0);
773  
1047 –  if (ServerInfo.description)
1048 –    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1049 –
774    load_conf_modules();
775 <
1052 <  rehashed_klines = 1;
775 >  check_conf_klines();
776  
777    return 0;
778   }
# Line 1072 | Line 795 | set_default_conf(void)
795    assert(class_default == class_get_list()->tail->data);
796  
797   #ifdef HAVE_LIBCRYPTO
798 <  ServerInfo.rsa_private_key = NULL;
799 <  ServerInfo.rsa_private_key_file = NULL;
798 > #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
799 >  {
800 >    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
801 >
802 >    if (key)
803 >    {
804 >      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
805 >      EC_KEY_free(key);
806 >    }
807 >  }
808 >
809 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
810   #endif
811  
812 <  /* ServerInfo.name is not rehashable */
813 <  /* ServerInfo.name = ServerInfo.name; */
814 <  ServerInfo.description = NULL;
815 <  ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
816 <  ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
817 <
818 <  memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip));
819 <  ServerInfo.specific_ipv4_vhost = 0;
820 <  memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6));
821 <  ServerInfo.specific_ipv6_vhost = 0;
822 <
823 <  ServerInfo.max_clients = MAXCLIENTS_MAX;
824 <  ServerInfo.max_nick_length = 9;
825 <  ServerInfo.max_topic_length = 80;
826 <
827 <  ServerInfo.hub = 0;
828 <  ServerInfo.dns_host.sin_addr.s_addr = 0;
829 <  ServerInfo.dns_host.sin_port = 0;
830 <  AdminInfo.name = NULL;
831 <  AdminInfo.email = NULL;
832 <  AdminInfo.description = NULL;
812 >  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
813 >  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
814 >  ConfigServerInfo.rsa_private_key = NULL;
815 >  ConfigServerInfo.rsa_private_key_file = NULL;
816 > #endif
817 >
818 >  /* ConfigServerInfo.name is not rehashable */
819 >  /* ConfigServerInfo.name = ConfigServerInfo.name; */
820 >  ConfigServerInfo.description = NULL;
821 >  ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
822 >  ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
823 >
824 >  memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip));
825 >  ConfigServerInfo.specific_ipv4_vhost = 0;
826 >  memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
827 >  ConfigServerInfo.specific_ipv6_vhost = 0;
828 >
829 >  ConfigServerInfo.max_clients = MAXCLIENTS_MAX;
830 >  ConfigServerInfo.max_nick_length = 9;
831 >  ConfigServerInfo.max_topic_length = 80;
832 >  ConfigServerInfo.hub = 0;
833 >
834 >  ConfigAdminInfo.name = NULL;
835 >  ConfigAdminInfo.email = NULL;
836 >  ConfigAdminInfo.description = NULL;
837  
838    log_del_all();
839  
840 <  ConfigLoggingEntry.use_logging = 1;
840 >  ConfigLog.use_logging = 1;
841  
842    ConfigChannel.disable_fake_channels = 0;
843 <  ConfigChannel.knock_delay = 300;
843 >  ConfigChannel.invite_client_count = 10;
844 >  ConfigChannel.invite_client_time = 300;
845 >  ConfigChannel.knock_client_count = 1;
846 >  ConfigChannel.knock_client_time = 300;
847    ConfigChannel.knock_delay_channel = 60;
848 <  ConfigChannel.max_chans_per_user = 25;
1109 <  ConfigChannel.max_chans_per_oper = 50;
848 >  ConfigChannel.max_channels = 25;
849    ConfigChannel.max_bans = 25;
850    ConfigChannel.default_split_user_count = 0;
851    ConfigChannel.default_split_server_count = 0;
# Line 1122 | Line 861 | set_default_conf(void)
861    ConfigServerHide.hide_server_ips = 0;
862    ConfigServerHide.disable_remote_commands = 0;
863  
864 <  ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
865 <  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
866 <  ConfigFileEntry.cycle_on_host_change = 1;
867 <  ConfigFileEntry.glines = 0;
868 <  ConfigFileEntry.gline_time = 12 * 3600;
869 <  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
870 <  ConfigFileEntry.gline_min_cidr = 16;
871 <  ConfigFileEntry.gline_min_cidr6 = 48;
872 <  ConfigFileEntry.invisible_on_connect = 1;
873 <  ConfigFileEntry.tkline_expire_notices = 1;
874 <  ConfigFileEntry.hide_spoof_ips = 1;
875 <  ConfigFileEntry.ignore_bogus_ts = 0;
876 <  ConfigFileEntry.disable_auth = 0;
877 <  ConfigFileEntry.kill_chase_time_limit = 90;
878 <  ConfigFileEntry.default_floodcount = 8;
879 <  ConfigFileEntry.failed_oper_notice = 1;
880 <  ConfigFileEntry.dots_in_ident = 0;
881 <  ConfigFileEntry.min_nonwildcard = 4;
882 <  ConfigFileEntry.min_nonwildcard_simple = 3;
883 <  ConfigFileEntry.max_accept = 20;
884 <  ConfigFileEntry.anti_nick_flood = 0;
885 <  ConfigFileEntry.max_nick_time = 20;
886 <  ConfigFileEntry.max_nick_changes = 5;
887 <  ConfigFileEntry.anti_spam_exit_message_time = 0;
888 <  ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
889 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
890 <  ConfigFileEntry.warn_no_nline = 1;
891 <  ConfigFileEntry.stats_o_oper_only = 0;
892 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
893 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
894 <  ConfigFileEntry.stats_P_oper_only = 0;
895 <  ConfigFileEntry.stats_u_oper_only = 0;
896 <  ConfigFileEntry.caller_id_wait = 60;
897 <  ConfigFileEntry.opers_bypass_callerid = 0;
898 <  ConfigFileEntry.pace_wait = 10;
899 <  ConfigFileEntry.pace_wait_simple = 1;
900 <  ConfigFileEntry.short_motd = 0;
901 <  ConfigFileEntry.ping_cookie = 0;
902 <  ConfigFileEntry.no_oper_flood = 0;
903 <  ConfigFileEntry.true_no_oper_flood = 0;
904 <  ConfigFileEntry.oper_pass_resv = 1;
905 <  ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
906 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
907 <  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
908 <    UMODE_OPERWALL | UMODE_WALLOP;
909 <  ConfigFileEntry.use_egd = 0;
910 <  ConfigFileEntry.egdpool_path = NULL;
1172 <  ConfigFileEntry.throttle_time = 10;
864 >  ConfigGeneral.away_count = 2;
865 >  ConfigGeneral.away_time = 10;
866 >  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
867 >  ConfigGeneral.cycle_on_host_change = 1;
868 >  ConfigGeneral.glines = 0;
869 >  ConfigGeneral.gline_time = 12 * 3600;
870 >  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
871 >  ConfigGeneral.gline_min_cidr = 16;
872 >  ConfigGeneral.gline_min_cidr6 = 48;
873 >  ConfigGeneral.invisible_on_connect = 1;
874 >  ConfigGeneral.tkline_expire_notices = 1;
875 >  ConfigGeneral.ignore_bogus_ts = 0;
876 >  ConfigGeneral.disable_auth = 0;
877 >  ConfigGeneral.kill_chase_time_limit = 90;
878 >  ConfigGeneral.default_floodcount = 8;
879 >  ConfigGeneral.failed_oper_notice = 1;
880 >  ConfigGeneral.dots_in_ident = 0;
881 >  ConfigGeneral.min_nonwildcard = 4;
882 >  ConfigGeneral.min_nonwildcard_simple = 3;
883 >  ConfigGeneral.max_accept = 20;
884 >  ConfigGeneral.anti_nick_flood = 0;
885 >  ConfigGeneral.max_nick_time = 20;
886 >  ConfigGeneral.max_nick_changes = 5;
887 >  ConfigGeneral.anti_spam_exit_message_time = 0;
888 >  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
889 >  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
890 >  ConfigGeneral.warn_no_connect_block = 1;
891 >  ConfigGeneral.stats_e_disabled = 0;
892 >  ConfigGeneral.stats_o_oper_only = 0;
893 >  ConfigGeneral.stats_k_oper_only = 1;  /* 1 = masked */
894 >  ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
895 >  ConfigGeneral.stats_P_oper_only = 0;
896 >  ConfigGeneral.stats_u_oper_only = 0;
897 >  ConfigGeneral.caller_id_wait = 60;
898 >  ConfigGeneral.opers_bypass_callerid = 0;
899 >  ConfigGeneral.pace_wait = 10;
900 >  ConfigGeneral.pace_wait_simple = 1;
901 >  ConfigGeneral.short_motd = 0;
902 >  ConfigGeneral.ping_cookie = 0;
903 >  ConfigGeneral.no_oper_flood = 0;
904 >  ConfigGeneral.true_no_oper_flood = 0;
905 >  ConfigGeneral.oper_pass_resv = 1;
906 >  ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
907 >  ConfigGeneral.oper_only_umodes = UMODE_DEBUG;
908 >  ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
909 >  ConfigGeneral.throttle_count = 1;
910 >  ConfigGeneral.throttle_time = 1;
911   }
912  
913   static void
914   validate_conf(void)
915   {
916 <  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
917 <    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1180 <
1181 <  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1182 <    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
916 >  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
917 >    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
918  
919 <  if (ServerInfo.network_name == NULL)
920 <    ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
919 >  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
920 >    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
921  
922 <  if (ServerInfo.network_desc == NULL)
923 <    ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
922 >  if (ConfigServerInfo.network_name == NULL)
923 >    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
924  
925 <  if (ConfigFileEntry.service_name == NULL)
926 <    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
925 >  if (ConfigServerInfo.network_desc == NULL)
926 >    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_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;
1003 <  struct MaskItem *conf = find_dline_conf(addr, aftype);
1002 >  struct ip_entry *ip_found = NULL;
1003 >  struct MaskItem *const conf = find_dline_conf(addr, aftype);
1004  
1005    /* DLINE exempt also gets you out of static limits/pacing... */
1006    if (conf && (conf->type == CONF_EXEMPT))
# 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 1309 | Line 1048 | cleanup_tklines(void *notused)
1048   * side effects - expire tklines
1049   */
1050   static void
1051 < expire_tklines(dlink_list *tklist)
1051 > expire_tklines(dlink_list *list)
1052   {
1053 <  dlink_node *ptr = NULL, *ptr_next = NULL;
1315 <  struct MaskItem *conf = NULL;
1053 >  dlink_node *node = NULL, *node_next = NULL;
1054  
1055 <  DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head)
1055 >  DLINK_FOREACH_SAFE(node, node_next, list->head)
1056    {
1057 <    conf = ptr->data;
1057 >    struct MaskItem *conf = node->data;
1058  
1059      if (!conf->until || conf->until > CurrentTime)
1060        continue;
1061  
1062      if (conf->type == CONF_XLINE)
1063      {
1064 <      if (ConfigFileEntry.tkline_expire_notices)
1064 >      if (ConfigGeneral.tkline_expire_notices)
1065          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1066                                 "Temporary X-line for [%s] expired", conf->name);
1067        conf_free(conf);
1068      }
1069      else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1070      {
1071 <      if (ConfigFileEntry.tkline_expire_notices)
1071 >      if (ConfigGeneral.tkline_expire_notices)
1072          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1073                                 "Temporary RESV for [%s] expired", conf->name);
1074        conf_free(conf);
# Line 1354 | Line 1092 | static const struct oper_privs
1092    { OPER_FLAG_DIE,            'D' },
1093    { OPER_FLAG_GLINE,          'G' },
1094    { OPER_FLAG_REHASH,         'H' },
1095 <  { OPER_FLAG_K,              'K' },
1358 <  { OPER_FLAG_OPERWALL,       'L' },
1095 >  { OPER_FLAG_KLINE,          'K' },
1096    { OPER_FLAG_KILL,           'N' },
1097    { OPER_FLAG_KILL_REMOTE,    'O' },
1098    { OPER_FLAG_CONNECT,        'P' },
# Line 1387 | Line 1124 | oper_privs_as_string(const unsigned int
1124   }
1125  
1126   /*
1127 < * Input: A client to find the active oper{} name for.
1127 > * Input: A client to find the active operator {} name for.
1128   * Output: The nick!user@host{oper} of the oper.
1129   *         "oper" is server name for remote opers
1130   * Side effects: None.
# Line 1395 | Line 1132 | oper_privs_as_string(const unsigned int
1132   const char *
1133   get_oper_name(const struct Client *client_p)
1134   {
1398 –  const dlink_node *cnode = NULL;
1135    /* +5 for !,@,{,} and null */
1136    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1137  
1138 +  if (IsServer(client_p))
1139 +    return client_p->name;
1140 +
1141    if (MyConnect(client_p))
1142    {
1143 <    if ((cnode = client_p->localClient->confs.head))
1143 >    const dlink_node *const node = client_p->connection->confs.head;
1144 >
1145 >    if (node)
1146      {
1147 <      const struct MaskItem *conf = cnode->data;
1147 >      const struct MaskItem *const conf = node->data;
1148  
1149 <      if (IsConfOperator(conf))
1149 >      if (conf->type == CONF_OPER)
1150        {
1151          snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1152                   client_p->username, client_p->host, conf->name);
# Line 1413 | Line 1154 | get_oper_name(const struct Client *clien
1154        }
1155      }
1156  
1157 <    /* Probably should assert here for now. If there is an oper out there
1158 <     * with no oper{} conf attached, it would be good for us to know...
1157 >    /*
1158 >     * Probably should assert here for now. If there is an oper out there
1159 >     * with no operator {} conf attached, it would be good for us to know...
1160       */
1161 <    assert(0); /* Oper without oper conf! */
1161 >    assert(0);  /* Oper without oper conf! */
1162    }
1163  
1164    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
# Line 1433 | Line 1175 | get_oper_name(const struct Client *clien
1175   void
1176   read_conf_files(int cold)
1177   {
1178 <  const char *filename;
1179 <  char chanmodes[IRCD_BUFSIZE];
1180 <  char chanlimit[IRCD_BUFSIZE];
1178 >  const char *filename = NULL;
1179 >  char chanmodes[IRCD_BUFSIZE] = "";
1180 >  char chanlimit[IRCD_BUFSIZE] = "";
1181  
1182    conf_parser_ctx.boot = cold;
1183 <  filename = ConfigFileEntry.configfile;
1183 >  filename = ConfigGeneral.configfile;
1184  
1185    /* We need to know the initial filename for the yyerror() to report
1186       FIXME: The full path is in conffilenamebuf first time since we
1187 <             dont know anything else
1187 >             don't know anything else
1188  
1189       - Gozem 2002-07-21
1190    */
# Line 1473 | Line 1215 | read_conf_files(int cold)
1215  
1216    log_reopen_all();
1217  
1218 <  add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1219 <  add_isupport("NETWORK", ServerInfo.network_name, -1);
1218 >  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1219 >  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1220  
1221    snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1222    add_isupport("MAXLIST", chanmodes, -1);
1223 <  add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
1223 >  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1224    add_isupport("CHANTYPES", "#", -1);
1225  
1226    snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1227 <           ConfigChannel.max_chans_per_user);
1227 >           ConfigChannel.max_channels);
1228    add_isupport("CHANLIMIT", chanlimit, -1);
1229 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1230 <  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1231 <  add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1229 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1230 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1231 >  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1232    add_isupport("CHANMODES", chanmodes, -1);
1233  
1234    /*
# Line 1505 | Line 1247 | read_conf_files(int cold)
1247   static void
1248   clear_out_old_conf(void)
1249   {
1250 <  dlink_node *ptr = NULL, *next_ptr = NULL;
1509 <  struct MaskItem *conf;
1250 >  dlink_node *node = NULL, *node_next = NULL;
1251    dlink_list *free_items [] = {
1252      &server_items,   &oconf_items,
1253       &uconf_items,   &xconf_items,
# Line 1521 | Line 1262 | clear_out_old_conf(void)
1262  
1263    for (; *iterator != NULL; iterator++)
1264    {
1265 <    DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
1265 >    DLINK_FOREACH_SAFE(node, node_next, (*iterator)->head)
1266      {
1267 <      conf = ptr->data;
1267 >      struct MaskItem *conf = node->data;
1268  
1269 <      dlinkDelete(&conf->node, map_to_list(conf->type));
1269 >      conf->active = 0;
1270 >      dlinkDelete(&conf->node, *iterator);
1271  
1272        /* XXX This is less than pretty */
1273        if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
# Line 1556 | Line 1298 | clear_out_old_conf(void)
1298    /* clean out module paths */
1299    mod_clear_paths();
1300  
1301 <  /* clean out ServerInfo */
1302 <  MyFree(ServerInfo.description);
1303 <  ServerInfo.description = NULL;
1304 <  MyFree(ServerInfo.network_name);
1305 <  ServerInfo.network_name = NULL;
1306 <  MyFree(ServerInfo.network_desc);
1307 <  ServerInfo.network_desc = NULL;
1308 <  MyFree(ConfigFileEntry.egdpool_path);
1309 <  ConfigFileEntry.egdpool_path = NULL;
1301 >  pseudo_clear();
1302 >
1303 >  /* clean out ConfigServerInfo */
1304 >  MyFree(ConfigServerInfo.description);
1305 >  ConfigServerInfo.description = NULL;
1306 >  MyFree(ConfigServerInfo.network_name);
1307 >  ConfigServerInfo.network_name = NULL;
1308 >  MyFree(ConfigServerInfo.network_desc);
1309 >  ConfigServerInfo.network_desc = NULL;
1310   #ifdef HAVE_LIBCRYPTO
1311 <  if (ServerInfo.rsa_private_key)
1311 >  if (ConfigServerInfo.rsa_private_key)
1312    {
1313 <    RSA_free(ServerInfo.rsa_private_key);
1314 <    ServerInfo.rsa_private_key = NULL;
1313 >    RSA_free(ConfigServerInfo.rsa_private_key);
1314 >    ConfigServerInfo.rsa_private_key = NULL;
1315    }
1316  
1317 <  MyFree(ServerInfo.rsa_private_key_file);
1318 <  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);
1317 >  MyFree(ConfigServerInfo.rsa_private_key_file);
1318 >  ConfigServerInfo.rsa_private_key_file = NULL;
1319   #endif
1320  
1321 <  /* clean out AdminInfo */
1322 <  MyFree(AdminInfo.name);
1323 <  AdminInfo.name = NULL;
1324 <  MyFree(AdminInfo.email);
1325 <  AdminInfo.email = NULL;
1326 <  MyFree(AdminInfo.description);
1327 <  AdminInfo.description = NULL;
1321 >  /* clean out ConfigAdminInfo */
1322 >  MyFree(ConfigAdminInfo.name);
1323 >  ConfigAdminInfo.name = NULL;
1324 >  MyFree(ConfigAdminInfo.email);
1325 >  ConfigAdminInfo.email = NULL;
1326 >  MyFree(ConfigAdminInfo.description);
1327 >  ConfigAdminInfo.description = NULL;
1328  
1329    /* clean out listeners */
1330    close_listeners();
1598 –
1599 –  /* clean out general */
1600 –  MyFree(ConfigFileEntry.service_name);
1601 –  ConfigFileEntry.service_name = NULL;
1331   }
1332  
1333   /* conf_add_class_to_conf()
# Line 1614 | Line 1343 | conf_add_class_to_conf(struct MaskItem *
1343    {
1344      conf->class = class_default;
1345  
1346 <    if (conf->type == CONF_CLIENT)
1346 >    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1347        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1348                             "Warning *** Defaulting to default class for %s@%s",
1349                             conf->user, conf->host);
# Line 1628 | Line 1357 | conf_add_class_to_conf(struct MaskItem *
1357  
1358    if (conf->class == NULL)
1359    {
1360 <    if (conf->type == CONF_CLIENT)
1360 >    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1361        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1362                             "Warning *** Defaulting to default class for %s@%s",
1363                             conf->user, conf->host);
# Line 1735 | Line 1464 | valid_wild_card_simple(const char *data)
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    }
# Line 1766 | Line 1495 | valid_wild_card_simple(const char *data)
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    /*
# Line 1786 | Line 1515 | valid_wild_card(struct Client *source_p,
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  
# Line 1798 | Line 1527 | valid_wild_card(struct Client *source_p,
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;
# Line 1809 | Line 1538 | valid_wild_card(struct Client *source_p,
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   }
# Line 1852 | Line 1581 | parse_aline(const char *cmd, struct Clie
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  
# Line 2018 | Line 1747 | find_user_host(struct Client *source_p,
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      {
1754 <      if (!IsServer(source_p))
1754 >      if (IsClient(source_p))
1755          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
1756        return 0;
1757      }
# Line 2036 | Line 1765 | find_user_host(struct Client *source_p,
1765      if (target_p->username[0] == '~')
1766        luser[0] = '*';
1767  
1768 <    if (target_p->sockhost[0] == '\0' ||
2040 <        (target_p->sockhost[0] == '0' && target_p->sockhost[1] == '\0'))
1768 >    if (!strcmp(target_p->sockhost, "0"))
1769        strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1770      else
1771        strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
# 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];
1836 <  const dlink_node *ptr = NULL;
1835 >  char buffer[IRCD_BUFSIZE] = "";
1836 >  const dlink_node *node = NULL;
1837  
1838    va_start(args, pattern);
1839    vsnprintf(buffer, sizeof(buffer), pattern, args);
1840    va_end(args);
1841  
1842 <  DLINK_FOREACH(ptr, cluster_items.head)
1842 >  DLINK_FOREACH(node, cluster_items.head)
1843    {
1844 <    const struct MaskItem *conf = ptr->data;
1844 >    const struct MaskItem *conf = node->data;
1845  
1846      if (conf->flags & cluster_type)
1847        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
# 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)