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 4941 by michael, Thu Nov 27 15:17:09 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 (!ConfigGeneral.hide_spoof_ips && 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);
# Line 361 | Line 331 | verify_access(struct Client *client_p)
331  
332        return attach_iline(client_p, conf);
333      }
334 <    else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf)))
334 >    else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf)))
335      {
336        if (IsConfGline(conf))
337          sendto_one_notice(client_p, &me, ":*** G-lined");
# Line 383 | Line 353 | verify_access(struct Client *client_p)
353   static int
354   attach_iline(struct Client *client_p, struct MaskItem *conf)
355   {
356 <  struct ClassItem *class = NULL;
356 >  const struct ClassItem *const class = conf->class;
357    struct ip_entry *ip_found;
358    int a_limit_reached = 0;
359    unsigned int local = 0, global = 0, ident = 0;
360  
361 <  assert(conf->class);
392 <
393 <  ip_found = find_or_add_ip(&client_p->localClient->ip);
361 >  ip_found = ipcache_find_or_add_address(&client_p->connection->ip);
362    ip_found->count++;
363 <  SetIpHash(client_p);
396 <
397 <  class = conf->class;
363 >  AddFlag(client_p, FLAGS_IPHASH);
364  
365    count_user_host(client_p->username, client_p->host,
366                    &global, &local, &ident);
# Line 403 | Line 369 | attach_iline(struct Client *client_p, st
369     * setting a_limit_reached if any limit is reached.
370     * - Dianora
371     */
372 <  if (class->max_total != 0 && class->ref_count >= class->max_total)
372 >  if (class->max_total && class->ref_count >= class->max_total)
373      a_limit_reached = 1;
374 <  else if (class->max_perip != 0 && ip_found->count > class->max_perip)
374 >  else if (class->max_perip && ip_found->count > class->max_perip)
375      a_limit_reached = 1;
376 <  else if (class->max_local != 0 && local >= class->max_local)
376 >  else if (class->max_local && local >= class->max_local)
377      a_limit_reached = 1;
378 <  else if (class->max_global != 0 && global >= class->max_global)
378 >  else if (class->max_global && global >= class->max_global)
379      a_limit_reached = 1;
380 <  else if (class->max_ident != 0 && ident >= class->max_ident &&
380 >  else if (class->max_ident && ident >= class->max_ident &&
381             client_p->username[0] != '~')
382      a_limit_reached = 1;
383  
# Line 427 | Line 393 | attach_iline(struct Client *client_p, st
393    return attach_conf(client_p, conf);
394   }
395  
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 –
396   /* detach_conf()
397   *
398   * inputs       - pointer to client to detach
# Line 668 | Line 404 | garbage_collect_ip_entries(void)
404   void
405   detach_conf(struct Client *client_p, enum maskitem_type type)
406   {
407 <  dlink_node *ptr = NULL, *ptr_next = NULL;
407 >  dlink_node *node = NULL, *node_next = NULL;
408  
409 <  DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head)
409 >  DLINK_FOREACH_SAFE(node, node_next, client_p->connection->confs.head)
410    {
411 <    struct MaskItem *conf = ptr->data;
411 >    struct MaskItem *conf = node->data;
412  
413      assert(conf->type & (CONF_CLIENT | CONF_OPER | CONF_SERVER));
414      assert(conf->ref_count > 0);
# Line 681 | Line 417 | detach_conf(struct Client *client_p, enu
417      if (!(conf->type & type))
418        continue;
419  
420 <    dlinkDelete(ptr, &client_p->localClient->confs);
421 <    free_dlink_node(ptr);
420 >    dlinkDelete(node, &client_p->connection->confs);
421 >    free_dlink_node(node);
422  
423      if (conf->type == CONF_CLIENT)
424 <      remove_from_cidr_check(&client_p->localClient->ip, conf->class);
424 >      remove_from_cidr_check(&client_p->connection->ip, conf->class);
425  
426      if (--conf->class->ref_count == 0 && conf->class->active == 0)
427      {
# Line 711 | Line 447 | detach_conf(struct Client *client_p, enu
447   int
448   attach_conf(struct Client *client_p, struct MaskItem *conf)
449   {
450 <  if (dlinkFind(&client_p->localClient->confs, conf))
450 >  if (dlinkFind(&client_p->connection->confs, conf))
451      return 1;
452  
453    if (conf->type == CONF_CLIENT)
454      if (cidr_limit_reached(IsConfExemptLimits(conf),
455 <                           &client_p->localClient->ip, conf->class))
455 >                           &client_p->connection->ip, conf->class))
456        return TOO_MANY;    /* Already at maximum allowed */
457  
458    conf->class->ref_count++;
459    conf->ref_count++;
460  
461 <  dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
461 >  dlinkAdd(conf, make_dlink_node(), &client_p->connection->confs);
462  
463    return 0;
464   }
# Line 739 | Line 475 | int
475   attach_connect_block(struct Client *client_p, const char *name,
476                       const char *host)
477   {
478 <  dlink_node *ptr;
743 <  struct MaskItem *conf = NULL;
478 >  dlink_node *node = NULL;
479  
480    assert(client_p != NULL);
481    assert(host != NULL);
# Line 748 | Line 483 | attach_connect_block(struct Client *clie
483    if (client_p == NULL || host == NULL)
484      return 0;
485  
486 <  DLINK_FOREACH(ptr, server_items.head)
486 >  DLINK_FOREACH(node, server_items.head)
487    {
488 <    conf = ptr->data;
488 >    struct MaskItem *conf = node->data;
489  
490      if (match(conf->name, name) || match(conf->host, host))
491        continue;
# Line 774 | Line 509 | attach_connect_block(struct Client *clie
509   struct MaskItem *
510   find_conf_name(dlink_list *list, const char *name, enum maskitem_type type)
511   {
512 <  dlink_node *ptr;
778 <  struct MaskItem* conf;
512 >  dlink_node *node = NULL;
513  
514 <  DLINK_FOREACH(ptr, list->head)
514 >  DLINK_FOREACH(node, list->head)
515    {
516 <    conf = ptr->data;
516 >    struct MaskItem *conf = node->data;
517  
518      if (conf->type == type)
519      {
520 <      if (conf->name && (irccmp(conf->name, name) == 0 ||
521 <                         !match(conf->name, name)))
788 <      return conf;
520 >      if (conf->name && !irccmp(conf->name, name))
521 >        return conf;
522      }
523    }
524  
# Line 845 | Line 578 | struct MaskItem *
578   find_matching_name_conf(enum maskitem_type type, const char *name, const char *user,
579                          const char *host, unsigned int flags)
580   {
581 <  dlink_node *ptr=NULL;
582 <  struct MaskItem *conf=NULL;
583 <  dlink_list *list_p = map_to_list(type);
581 >  dlink_node *node = NULL;
582 >  dlink_list *list = map_to_list(type);
583 >  struct MaskItem *conf = NULL;
584  
585    switch (type)
586    {
587    case CONF_SERVICE:
588 <    DLINK_FOREACH(ptr, list_p->head)
588 >    DLINK_FOREACH(node, list->head)
589      {
590 <      conf = ptr->data;
590 >      conf = node->data;
591  
592        if (EmptyString(conf->name))
593          continue;
# Line 867 | Line 600 | find_matching_name_conf(enum maskitem_ty
600    case CONF_ULINE:
601    case CONF_NRESV:
602    case CONF_CRESV:
603 <    DLINK_FOREACH(ptr, list_p->head)
603 >    DLINK_FOREACH(node, list->head)
604      {
605 <      conf = ptr->data;
605 >      conf = node->data;
606  
607        if (EmptyString(conf->name))
608          continue;
# Line 888 | Line 621 | find_matching_name_conf(enum maskitem_ty
621        break;
622  
623    case CONF_SERVER:
624 <    DLINK_FOREACH(ptr, list_p->head)
624 >    DLINK_FOREACH(node, list->head)
625      {
626 <      conf = ptr->data;
626 >      conf = node->data;
627  
628        if ((name != NULL) && !match(name, conf->name))
629          return conf;
# Line 918 | Line 651 | struct MaskItem *
651   find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name,
652                       const char *user, const char *host)
653   {
654 <  dlink_node *ptr = NULL;
655 <  struct MaskItem *conf;
656 <  dlink_list *list_p = map_to_list(type);
654 >  dlink_node *node = NULL;
655 >  dlink_list *list = map_to_list(type);
656 >  struct MaskItem *conf = NULL;
657  
658    switch(type)
659    {
# Line 929 | Line 662 | find_exact_name_conf(enum maskitem_type
662    case CONF_NRESV:
663    case CONF_CRESV:
664  
665 <    DLINK_FOREACH(ptr, list_p->head)
665 >    DLINK_FOREACH(node, list->head)
666      {
667 <      conf = ptr->data;
667 >      conf = node->data;
668  
669        if (EmptyString(conf->name))
670          continue;
# Line 949 | Line 682 | find_exact_name_conf(enum maskitem_type
682      break;
683  
684    case CONF_OPER:
685 <    DLINK_FOREACH(ptr, list_p->head)
685 >    DLINK_FOREACH(node, list->head)
686      {
687 <      conf = ptr->data;
687 >      conf = node->data;
688  
689        if (EmptyString(conf->name))
690          continue;
# Line 972 | Line 705 | find_exact_name_conf(enum maskitem_type
705                    return conf;
706                break;
707              case HM_IPV4:
708 <              if (who->localClient->aftype == AF_INET)
709 <                if (match_ipv4(&who->localClient->ip, &conf->addr, conf->bits))
708 >              if (who->connection->aftype == AF_INET)
709 >                if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
710                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
711                      return conf;
712                break;
980 – #ifdef IPV6
713              case HM_IPV6:
714 <              if (who->localClient->aftype == AF_INET6)
715 <                if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits))
714 >              if (who->connection->aftype == AF_INET6)
715 >                if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
716                    if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
717                      return conf;
718                break;
987 – #endif
719              default:
720                assert(0);
721            }
# Line 995 | Line 726 | find_exact_name_conf(enum maskitem_type
726      break;
727  
728    case CONF_SERVER:
729 <    DLINK_FOREACH(ptr, list_p->head)
729 >    DLINK_FOREACH(node, list->head)
730      {
731 <      conf = ptr->data;
731 >      conf = node->data;
732  
733        if (EmptyString(conf->name))
734          continue;
# Line 1039 | Line 770 | rehash(int sig)
770  
771    /* don't close listeners until we know we can go ahead with the rehash */
772  
1042 –  /* Check to see if we magically got(or lost) IPv6 support */
1043 –  check_can_use_v6();
1044 –
773    read_conf_files(0);
774  
1047 –  if (ServerInfo.description)
1048 –    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1049 –
775    load_conf_modules();
776 <
1052 <  rehashed_klines = 1;
776 >  check_conf_klines();
777  
778    return 0;
779   }
# Line 1072 | Line 796 | set_default_conf(void)
796    assert(class_default == class_get_list()->tail->data);
797  
798   #ifdef HAVE_LIBCRYPTO
799 <  ServerInfo.rsa_private_key = NULL;
800 <  ServerInfo.rsa_private_key_file = NULL;
799 > #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
800 >  {
801 >    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
802 >
803 >    if (key)
804 >    {
805 >      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
806 >      EC_KEY_free(key);
807 >    }
808 >  }
809 >
810 >  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
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;
832 <  AdminInfo.email = NULL;
833 <  AdminInfo.description = NULL;
813 >  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
814 >  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
815 >  ConfigServerInfo.rsa_private_key = NULL;
816 >  ConfigServerInfo.rsa_private_key_file = NULL;
817 > #endif
818 >
819 >  /* ConfigServerInfo.name is not rehashable */
820 >  /* ConfigServerInfo.name = ConfigServerInfo.name; */
821 >  ConfigServerInfo.description = NULL;
822 >  ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
823 >  ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
824 >
825 >  memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip));
826 >  ConfigServerInfo.specific_ipv4_vhost = 0;
827 >  memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
828 >  ConfigServerInfo.specific_ipv6_vhost = 0;
829 >
830 >  ConfigServerInfo.max_clients = MAXCLIENTS_MAX;
831 >  ConfigServerInfo.max_nick_length = 9;
832 >  ConfigServerInfo.max_topic_length = 80;
833 >  ConfigServerInfo.hub = 0;
834 >
835 >  ConfigAdminInfo.name = NULL;
836 >  ConfigAdminInfo.email = NULL;
837 >  ConfigAdminInfo.description = NULL;
838  
839    log_del_all();
840  
841 <  ConfigLoggingEntry.use_logging = 1;
841 >  ConfigLog.use_logging = 1;
842  
843    ConfigChannel.disable_fake_channels = 0;
844 <  ConfigChannel.knock_delay = 300;
844 >  ConfigChannel.invite_client_count = 10;
845 >  ConfigChannel.invite_client_time = 300;
846 >  ConfigChannel.knock_client_count = 1;
847 >  ConfigChannel.knock_client_time = 300;
848    ConfigChannel.knock_delay_channel = 60;
849 <  ConfigChannel.max_chans_per_user = 25;
1109 <  ConfigChannel.max_chans_per_oper = 50;
849 >  ConfigChannel.max_channels = 25;
850    ConfigChannel.max_bans = 25;
851    ConfigChannel.default_split_user_count = 0;
852    ConfigChannel.default_split_server_count = 0;
# Line 1122 | Line 862 | set_default_conf(void)
862    ConfigServerHide.hide_server_ips = 0;
863    ConfigServerHide.disable_remote_commands = 0;
864  
865 <  ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
866 <  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
867 <  ConfigFileEntry.cycle_on_host_change = 1;
868 <  ConfigFileEntry.glines = 0;
869 <  ConfigFileEntry.gline_time = 12 * 3600;
870 <  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
871 <  ConfigFileEntry.gline_min_cidr = 16;
872 <  ConfigFileEntry.gline_min_cidr6 = 48;
873 <  ConfigFileEntry.invisible_on_connect = 1;
874 <  ConfigFileEntry.tkline_expire_notices = 1;
875 <  ConfigFileEntry.hide_spoof_ips = 1;
876 <  ConfigFileEntry.ignore_bogus_ts = 0;
877 <  ConfigFileEntry.disable_auth = 0;
878 <  ConfigFileEntry.kill_chase_time_limit = 90;
879 <  ConfigFileEntry.default_floodcount = 8;
880 <  ConfigFileEntry.failed_oper_notice = 1;
881 <  ConfigFileEntry.dots_in_ident = 0;
882 <  ConfigFileEntry.min_nonwildcard = 4;
883 <  ConfigFileEntry.min_nonwildcard_simple = 3;
884 <  ConfigFileEntry.max_accept = 20;
885 <  ConfigFileEntry.anti_nick_flood = 0;
886 <  ConfigFileEntry.max_nick_time = 20;
887 <  ConfigFileEntry.max_nick_changes = 5;
888 <  ConfigFileEntry.anti_spam_exit_message_time = 0;
889 <  ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
890 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
891 <  ConfigFileEntry.warn_no_nline = 1;
892 <  ConfigFileEntry.stats_o_oper_only = 0;
893 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
894 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
895 <  ConfigFileEntry.stats_P_oper_only = 0;
896 <  ConfigFileEntry.stats_u_oper_only = 0;
897 <  ConfigFileEntry.caller_id_wait = 60;
898 <  ConfigFileEntry.opers_bypass_callerid = 0;
899 <  ConfigFileEntry.pace_wait = 10;
900 <  ConfigFileEntry.pace_wait_simple = 1;
901 <  ConfigFileEntry.short_motd = 0;
902 <  ConfigFileEntry.ping_cookie = 0;
903 <  ConfigFileEntry.no_oper_flood = 0;
904 <  ConfigFileEntry.true_no_oper_flood = 0;
905 <  ConfigFileEntry.oper_pass_resv = 1;
906 <  ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
907 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
908 <  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
909 <    UMODE_OPERWALL | UMODE_WALLOP;
910 <  ConfigFileEntry.use_egd = 0;
911 <  ConfigFileEntry.egdpool_path = NULL;
912 <  ConfigFileEntry.throttle_time = 10;
865 >  ConfigGeneral.away_count = 2;
866 >  ConfigGeneral.away_time = 10;
867 >  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
868 >  ConfigGeneral.cycle_on_host_change = 1;
869 >  ConfigGeneral.glines = 0;
870 >  ConfigGeneral.gline_time = 12 * 3600;
871 >  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
872 >  ConfigGeneral.gline_min_cidr = 16;
873 >  ConfigGeneral.gline_min_cidr6 = 48;
874 >  ConfigGeneral.invisible_on_connect = 1;
875 >  ConfigGeneral.tkline_expire_notices = 1;
876 >  ConfigGeneral.hide_spoof_ips = 1;
877 >  ConfigGeneral.ignore_bogus_ts = 0;
878 >  ConfigGeneral.disable_auth = 0;
879 >  ConfigGeneral.kill_chase_time_limit = 90;
880 >  ConfigGeneral.default_floodcount = 8;
881 >  ConfigGeneral.failed_oper_notice = 1;
882 >  ConfigGeneral.dots_in_ident = 0;
883 >  ConfigGeneral.min_nonwildcard = 4;
884 >  ConfigGeneral.min_nonwildcard_simple = 3;
885 >  ConfigGeneral.max_accept = 20;
886 >  ConfigGeneral.anti_nick_flood = 0;
887 >  ConfigGeneral.max_nick_time = 20;
888 >  ConfigGeneral.max_nick_changes = 5;
889 >  ConfigGeneral.anti_spam_exit_message_time = 0;
890 >  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
891 >  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
892 >  ConfigGeneral.warn_no_connect_block = 1;
893 >  ConfigGeneral.stats_e_disabled = 0;
894 >  ConfigGeneral.stats_o_oper_only = 0;
895 >  ConfigGeneral.stats_k_oper_only = 1;  /* 1 = masked */
896 >  ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
897 >  ConfigGeneral.stats_P_oper_only = 0;
898 >  ConfigGeneral.stats_u_oper_only = 0;
899 >  ConfigGeneral.caller_id_wait = 60;
900 >  ConfigGeneral.opers_bypass_callerid = 0;
901 >  ConfigGeneral.pace_wait = 10;
902 >  ConfigGeneral.pace_wait_simple = 1;
903 >  ConfigGeneral.short_motd = 0;
904 >  ConfigGeneral.ping_cookie = 0;
905 >  ConfigGeneral.no_oper_flood = 0;
906 >  ConfigGeneral.true_no_oper_flood = 0;
907 >  ConfigGeneral.oper_pass_resv = 1;
908 >  ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
909 >  ConfigGeneral.oper_only_umodes = UMODE_DEBUG;
910 >  ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
911 >  ConfigGeneral.throttle_count = 1;
912 >  ConfigGeneral.throttle_time = 1;
913   }
914  
915   static void
916   validate_conf(void)
917   {
918 <  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
919 <    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;
918 >  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
919 >    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
920  
921 <  if (ServerInfo.network_name == NULL)
922 <    ServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
921 >  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
922 >    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
923  
924 <  if (ServerInfo.network_desc == NULL)
925 <    ServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
924 >  if (ConfigServerInfo.network_name == NULL)
925 >    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
926  
927 <  if (ConfigFileEntry.service_name == NULL)
928 <    ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT);
927 >  if (ConfigServerInfo.network_desc == NULL)
928 >    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
929  
930 <  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
930 >  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
931   }
932  
933   /* read_conf()
# Line 1204 | Line 941 | read_conf(FILE *file)
941   {
942    lineno = 0;
943  
944 <  set_default_conf(); /* Set default values prior to conf parsing */
944 >  set_default_conf();  /* Set default values prior to conf parsing */
945    conf_parser_ctx.pass = 1;
946 <  yyparse();          /* pick up the classes first */
946 >  yyparse();  /* Pick up the classes first */
947  
948    rewind(file);
949  
950    conf_parser_ctx.pass = 2;
951 <  yyparse();          /* Load the values from the conf */
952 <  validate_conf();    /* Check to make sure some values are still okay. */
953 <                      /* Some global values are also loaded here. */
954 <  class_delete_marked();      /* Make sure classes are valid */
951 >  yyparse();  /* Load the values from the conf */
952 >  validate_conf();  /* Check to make sure some values are still okay. */
953 >                    /* Some global values are also loaded here. */
954 >  class_delete_marked();  /* Delete unused classes that are marked for deletion */
955   }
956  
957   /* lookup_confhost()
# Line 1227 | Line 964 | lookup_confhost(struct MaskItem *conf)
964   {
965    struct addrinfo hints, *res;
966  
967 <  /* Do name lookup now on hostnames given and store the
967 >  /*
968 >   * Do name lookup now on hostnames given and store the
969     * ip numbers in conf structure.
970     */
971    memset(&hints, 0, sizeof(hints));
# Line 1263 | Line 1001 | lookup_confhost(struct MaskItem *conf)
1001   int
1002   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
1003   {
1004 <  struct ip_entry *ip_found;
1005 <  struct MaskItem *conf = find_dline_conf(addr, aftype);
1004 >  struct ip_entry *ip_found = NULL;
1005 >  struct MaskItem *const conf = find_dline_conf(addr, aftype);
1006  
1007    /* DLINE exempt also gets you out of static limits/pacing... */
1008    if (conf && (conf->type == CONF_EXEMPT))
# Line 1273 | Line 1011 | conf_connect_allowed(struct irc_ssaddr *
1011    if (conf)
1012      return BANNED_CLIENT;
1013  
1014 <  ip_found = find_or_add_ip(addr);
1014 >  ip_found = ipcache_find_or_add_address(addr);
1015  
1016 <  if ((CurrentTime - ip_found->last_attempt) <
1279 <      ConfigFileEntry.throttle_time)
1016 >  if ((CurrentTime - ip_found->last_attempt) < ConfigGeneral.throttle_time)
1017    {
1018 <    ip_found->last_attempt = CurrentTime;
1019 <    return TOO_FAST;
1018 >    if (ip_found->connection_count >= ConfigGeneral.throttle_count)
1019 >      return TOO_FAST;
1020 >
1021 >    ++ip_found->connection_count;
1022    }
1023 +  else
1024 +    ip_found->connection_count = 1;
1025  
1026    ip_found->last_attempt = CurrentTime;
1027    return 0;
# Line 1294 | Line 1035 | conf_connect_allowed(struct irc_ssaddr *
1035   *                This is an event started off in ircd.c
1036   */
1037   void
1038 < cleanup_tklines(void *notused)
1038 > cleanup_tklines(void *unused)
1039   {
1040    hostmask_expire_temporary();
1041    expire_tklines(&xconf_items);
# Line 1309 | Line 1050 | cleanup_tklines(void *notused)
1050   * side effects - expire tklines
1051   */
1052   static void
1053 < expire_tklines(dlink_list *tklist)
1053 > expire_tklines(dlink_list *list)
1054   {
1055 <  dlink_node *ptr = NULL, *ptr_next = NULL;
1315 <  struct MaskItem *conf = NULL;
1055 >  dlink_node *node = NULL, *node_next = NULL;
1056  
1057 <  DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head)
1057 >  DLINK_FOREACH_SAFE(node, node_next, list->head)
1058    {
1059 <    conf = ptr->data;
1059 >    struct MaskItem *conf = node->data;
1060  
1061      if (!conf->until || conf->until > CurrentTime)
1062        continue;
1063  
1064      if (conf->type == CONF_XLINE)
1065      {
1066 <      if (ConfigFileEntry.tkline_expire_notices)
1066 >      if (ConfigGeneral.tkline_expire_notices)
1067          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1068                                 "Temporary X-line for [%s] expired", conf->name);
1069        conf_free(conf);
1070      }
1071      else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1072      {
1073 <      if (ConfigFileEntry.tkline_expire_notices)
1073 >      if (ConfigGeneral.tkline_expire_notices)
1074          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1075                                 "Temporary RESV for [%s] expired", conf->name);
1076        conf_free(conf);
# Line 1354 | Line 1094 | static const struct oper_privs
1094    { OPER_FLAG_DIE,            'D' },
1095    { OPER_FLAG_GLINE,          'G' },
1096    { OPER_FLAG_REHASH,         'H' },
1097 <  { OPER_FLAG_K,              'K' },
1358 <  { OPER_FLAG_OPERWALL,       'L' },
1097 >  { OPER_FLAG_KLINE,          'K' },
1098    { OPER_FLAG_KILL,           'N' },
1099    { OPER_FLAG_KILL_REMOTE,    'O' },
1100    { OPER_FLAG_CONNECT,        'P' },
# Line 1387 | Line 1126 | oper_privs_as_string(const unsigned int
1126   }
1127  
1128   /*
1129 < * Input: A client to find the active oper{} name for.
1129 > * Input: A client to find the active operator {} name for.
1130   * Output: The nick!user@host{oper} of the oper.
1131   *         "oper" is server name for remote opers
1132   * Side effects: None.
# Line 1395 | Line 1134 | oper_privs_as_string(const unsigned int
1134   const char *
1135   get_oper_name(const struct Client *client_p)
1136   {
1137 <  const dlink_node *cnode = NULL;
1137 >  const dlink_node *node = NULL;
1138    /* +5 for !,@,{,} and null */
1139    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
1140  
1141 +  if (IsServer(client_p))
1142 +    return client_p->name;
1143 +
1144    if (MyConnect(client_p))
1145    {
1146 <    if ((cnode = client_p->localClient->confs.head))
1146 >    if ((node = client_p->connection->confs.head))
1147      {
1148 <      const struct MaskItem *conf = cnode->data;
1148 >      const struct MaskItem *const conf = node->data;
1149  
1150 <      if (IsConfOperator(conf))
1150 >      if (conf->type == CONF_OPER)
1151        {
1152          snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
1153                   client_p->username, client_p->host, conf->name);
# Line 1413 | Line 1155 | get_oper_name(const struct Client *clien
1155        }
1156      }
1157  
1158 <    /* Probably should assert here for now. If there is an oper out there
1159 <     * with no oper{} conf attached, it would be good for us to know...
1158 >    /*
1159 >     * Probably should assert here for now. If there is an oper out there
1160 >     * with no operator {} conf attached, it would be good for us to know...
1161       */
1162 <    assert(0); /* Oper without oper conf! */
1162 >    assert(0);  /* Oper without oper conf! */
1163    }
1164  
1165    snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
# Line 1433 | Line 1176 | get_oper_name(const struct Client *clien
1176   void
1177   read_conf_files(int cold)
1178   {
1179 <  const char *filename;
1180 <  char chanmodes[IRCD_BUFSIZE];
1181 <  char chanlimit[IRCD_BUFSIZE];
1179 >  const char *filename = NULL;
1180 >  char chanmodes[IRCD_BUFSIZE] = "";
1181 >  char chanlimit[IRCD_BUFSIZE] = "";
1182  
1183    conf_parser_ctx.boot = cold;
1184 <  filename = ConfigFileEntry.configfile;
1184 >  filename = ConfigGeneral.configfile;
1185  
1186    /* We need to know the initial filename for the yyerror() to report
1187       FIXME: The full path is in conffilenamebuf first time since we
1188 <             dont know anything else
1188 >             don't know anything else
1189  
1190       - Gozem 2002-07-21
1191    */
# Line 1473 | Line 1216 | read_conf_files(int cold)
1216  
1217    log_reopen_all();
1218  
1219 <  add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1220 <  add_isupport("NETWORK", ServerInfo.network_name, -1);
1219 >  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1220 >  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1221  
1222    snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1223    add_isupport("MAXLIST", chanmodes, -1);
1224 <  add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
1224 >  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1225    add_isupport("CHANTYPES", "#", -1);
1226  
1227    snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1228 <           ConfigChannel.max_chans_per_user);
1228 >           ConfigChannel.max_channels);
1229    add_isupport("CHANLIMIT", chanlimit, -1);
1230 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1231 <  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1232 <  add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1230 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1231 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1232 >  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1233    add_isupport("CHANMODES", chanmodes, -1);
1234  
1235    /*
# Line 1505 | Line 1248 | read_conf_files(int cold)
1248   static void
1249   clear_out_old_conf(void)
1250   {
1251 <  dlink_node *ptr = NULL, *next_ptr = NULL;
1509 <  struct MaskItem *conf;
1251 >  dlink_node *node = NULL, *node_next = NULL;
1252    dlink_list *free_items [] = {
1253      &server_items,   &oconf_items,
1254       &uconf_items,   &xconf_items,
# Line 1521 | Line 1263 | clear_out_old_conf(void)
1263  
1264    for (; *iterator != NULL; iterator++)
1265    {
1266 <    DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
1266 >    DLINK_FOREACH_SAFE(node, node_next, (*iterator)->head)
1267      {
1268 <      conf = ptr->data;
1268 >      struct MaskItem *conf = node->data;
1269  
1270 <      dlinkDelete(&conf->node, map_to_list(conf->type));
1270 >      conf->active = 0;
1271 >      dlinkDelete(&conf->node, *iterator);
1272  
1273        /* XXX This is less than pretty */
1274        if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
# Line 1556 | Line 1299 | clear_out_old_conf(void)
1299    /* clean out module paths */
1300    mod_clear_paths();
1301  
1302 <  /* clean out ServerInfo */
1303 <  MyFree(ServerInfo.description);
1304 <  ServerInfo.description = NULL;
1305 <  MyFree(ServerInfo.network_name);
1306 <  ServerInfo.network_name = NULL;
1307 <  MyFree(ServerInfo.network_desc);
1308 <  ServerInfo.network_desc = NULL;
1309 <  MyFree(ConfigFileEntry.egdpool_path);
1310 <  ConfigFileEntry.egdpool_path = NULL;
1302 >  pseudo_clear();
1303 >
1304 >  /* clean out ConfigServerInfo */
1305 >  MyFree(ConfigServerInfo.description);
1306 >  ConfigServerInfo.description = NULL;
1307 >  MyFree(ConfigServerInfo.network_name);
1308 >  ConfigServerInfo.network_name = NULL;
1309 >  MyFree(ConfigServerInfo.network_desc);
1310 >  ConfigServerInfo.network_desc = NULL;
1311   #ifdef HAVE_LIBCRYPTO
1312 <  if (ServerInfo.rsa_private_key)
1312 >  if (ConfigServerInfo.rsa_private_key)
1313    {
1314 <    RSA_free(ServerInfo.rsa_private_key);
1315 <    ServerInfo.rsa_private_key = NULL;
1314 >    RSA_free(ConfigServerInfo.rsa_private_key);
1315 >    ConfigServerInfo.rsa_private_key = NULL;
1316    }
1317  
1318 <  MyFree(ServerInfo.rsa_private_key_file);
1319 <  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);
1318 >  MyFree(ConfigServerInfo.rsa_private_key_file);
1319 >  ConfigServerInfo.rsa_private_key_file = NULL;
1320   #endif
1321  
1322 <  /* clean out AdminInfo */
1323 <  MyFree(AdminInfo.name);
1324 <  AdminInfo.name = NULL;
1325 <  MyFree(AdminInfo.email);
1326 <  AdminInfo.email = NULL;
1327 <  MyFree(AdminInfo.description);
1328 <  AdminInfo.description = NULL;
1322 >  /* clean out ConfigAdminInfo */
1323 >  MyFree(ConfigAdminInfo.name);
1324 >  ConfigAdminInfo.name = NULL;
1325 >  MyFree(ConfigAdminInfo.email);
1326 >  ConfigAdminInfo.email = NULL;
1327 >  MyFree(ConfigAdminInfo.description);
1328 >  ConfigAdminInfo.description = NULL;
1329  
1330    /* clean out listeners */
1331    close_listeners();
1598 –
1599 –  /* clean out general */
1600 –  MyFree(ConfigFileEntry.service_name);
1601 –  ConfigFileEntry.service_name = NULL;
1332   }
1333  
1334   /* conf_add_class_to_conf()
# Line 1614 | Line 1344 | conf_add_class_to_conf(struct MaskItem *
1344    {
1345      conf->class = class_default;
1346  
1347 <    if (conf->type == CONF_CLIENT)
1347 >    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1348        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1349                             "Warning *** Defaulting to default class for %s@%s",
1350                             conf->user, conf->host);
# Line 1628 | Line 1358 | conf_add_class_to_conf(struct MaskItem *
1358  
1359    if (conf->class == NULL)
1360    {
1361 <    if (conf->type == CONF_CLIENT)
1361 >    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1362        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1363                             "Warning *** Defaulting to default class for %s@%s",
1364                             conf->user, conf->host);
# Line 1735 | Line 1465 | valid_wild_card_simple(const char *data)
1465   {
1466    const unsigned char *p = (const unsigned char *)data;
1467    unsigned char tmpch = '\0';
1468 <  int nonwild = 0;
1468 >  unsigned int nonwild = 0;
1469  
1470    while ((tmpch = *p++))
1471    {
1472 <    if (tmpch == '\\')
1472 >    if (tmpch == '\\' && *p)
1473      {
1474        ++p;
1475 <      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1475 >      if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1476          return 1;
1477      }
1478      else if (!IsMWildChar(tmpch))
1479      {
1480 <      if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple)
1480 >      if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1481          return 1;
1482      }
1483    }
# Line 1766 | Line 1496 | valid_wild_card_simple(const char *data)
1496   int
1497   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1498   {
1499 <  char tmpch;
1500 <  int nonwild = 0;
1499 >  unsigned char tmpch = '\0';
1500 >  unsigned int nonwild = 0;
1501    va_list args;
1502  
1503    /*
# Line 1786 | Line 1516 | valid_wild_card(struct Client *source_p,
1516  
1517    while (count--)
1518    {
1519 <    const char *p = va_arg(args, const char *);
1519 >    const unsigned char *p = va_arg(args, const unsigned char *);
1520      if (p == NULL)
1521        continue;
1522  
# Line 1798 | Line 1528 | valid_wild_card(struct Client *source_p,
1528           * If we find enough non-wild characters, we can
1529           * break - no point in searching further.
1530           */
1531 <        if (++nonwild >= ConfigFileEntry.min_nonwildcard)
1531 >        if (++nonwild >= ConfigGeneral.min_nonwildcard)
1532          {
1533            va_end(args);
1534            return 1;
# Line 1809 | Line 1539 | valid_wild_card(struct Client *source_p,
1539  
1540    if (warn)
1541      sendto_one_notice(source_p, &me,
1542 <                      ":Please include at least %d non-wildcard characters with the mask",
1543 <                      ConfigFileEntry.min_nonwildcard);
1542 >                      ":Please include at least %u non-wildcard characters with the mask",
1543 >                      ConfigGeneral.min_nonwildcard);
1544    va_end(args);
1545    return 0;
1546   }
# Line 1852 | Line 1582 | parse_aline(const char *cmd, struct Clie
1582              char **target_server, char **reason)
1583   {
1584    int found_tkline_time=0;
1585 <  static char def_reason[] = "No Reason";
1585 >  static char def_reason[] = CONF_NOREASON;
1586    static char user[USERLEN*4+1];
1587    static char host[HOSTLEN*4+1];
1588  
# Line 2018 | Line 1748 | find_user_host(struct Client *source_p,
1748      /* Okay to use source_p as the first param, because source_p == client_p */
1749      if ((target_p =
1750          find_chasing(source_p, user_host_or_nick)) == NULL)
1751 <      return 0;
1751 >      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1752  
1753      if (IsExemptKline(target_p))
1754      {
1755 <      if (!IsServer(source_p))
1755 >      if (IsClient(source_p))
1756          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
1757        return 0;
1758      }
# Line 2036 | Line 1766 | find_user_host(struct Client *source_p,
1766      if (target_p->username[0] == '~')
1767        luser[0] = '*';
1768  
1769 <    if (target_p->sockhost[0] == '\0' ||
2040 <        (target_p->sockhost[0] == '0' && target_p->sockhost[1] == '\0'))
1769 >    if (!strcmp(target_p->sockhost, "0"))
1770        strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1771      else
1772        strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
# Line 2104 | Line 1833 | cluster_a_line(struct Client *source_p,
1833                 int capab, int cluster_type, const char *pattern, ...)
1834   {
1835    va_list args;
1836 <  char buffer[IRCD_BUFSIZE];
1837 <  const dlink_node *ptr = NULL;
1836 >  char buffer[IRCD_BUFSIZE] = "";
1837 >  const dlink_node *node = NULL;
1838  
1839    va_start(args, pattern);
1840    vsnprintf(buffer, sizeof(buffer), pattern, args);
1841    va_end(args);
1842  
1843 <  DLINK_FOREACH(ptr, cluster_items.head)
1843 >  DLINK_FOREACH(node, cluster_items.head)
1844    {
1845 <    const struct MaskItem *conf = ptr->data;
1845 >    const struct MaskItem *conf = node->data;
1846  
1847      if (conf->flags & cluster_type)
1848        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
# Line 2165 | Line 1894 | split_nuh(struct split_nuh_item *const i
1894    {
1895      *p = '\0';
1896  
1897 <    if (iptr->nickptr && *iptr->nuhmask != '\0')
1897 >    if (iptr->nickptr && *iptr->nuhmask)
1898        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
1899  
1900      if ((q = strchr(++p, '@')))
1901      {
1902        *q++ = '\0';
1903  
1904 <      if (*p != '\0')
1904 >      if (*p)
1905          strlcpy(iptr->userptr, p, iptr->usersize);
1906  
1907 <      if (*q != '\0')
1907 >      if (*q)
1908          strlcpy(iptr->hostptr, q, iptr->hostsize);
1909      }
1910      else
1911      {
1912 <      if (*p != '\0')
1912 >      if (*p)
1913          strlcpy(iptr->userptr, p, iptr->usersize);
1914      }
1915    }
# Line 2192 | Line 1921 | split_nuh(struct split_nuh_item *const i
1921        /* if found a @ */
1922        *p++ = '\0';
1923  
1924 <      if (*iptr->nuhmask != '\0')
1924 >      if (*iptr->nuhmask)
1925          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
1926  
1927 <      if (*p != '\0')
1927 >      if (*p)
1928          strlcpy(iptr->hostptr, p, iptr->hostsize);
1929      }
1930      else

Diff Legend

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