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-7.2/src/s_conf.c (file contents), Revision 151 by db, Sun Oct 16 18:21:11 2005 UTC vs.
ircd-hybrid-8/src/conf.c (file contents), Revision 1518 by michael, Sun Sep 2 16:50:40 2012 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_conf.c: Configuration file functions.
3 > *  conf.c: Configuration file functions.
4   *
5   *  Copyright (C) 2002 by the past and present ircd coders, and others.
6   *
# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 + #include "list.h"
27   #include "ircd_defs.h"
28 < #include "tools.h"
29 < #include "s_conf.h"
28 > #include "balloc.h"
29 > #include "conf.h"
30   #include "s_serv.h"
31   #include "resv.h"
31 – #include "s_stats.h"
32   #include "channel.h"
33   #include "client.h"
34 – #include "common.h"
34   #include "event.h"
36 – #include "hash.h"
35   #include "hook.h"
36   #include "irc_string.h"
39 – #include "sprintf_irc.h"
37   #include "s_bsd.h"
41 – #include "irc_getnameinfo.h"
42 – #include "irc_getaddrinfo.h"
38   #include "ircd.h"
44 – #include "list.h"
39   #include "listener.h"
40   #include "hostmask.h"
41   #include "modules.h"
42   #include "numeric.h"
43   #include "fdlist.h"
44 < #include "s_log.h"
44 > #include "log.h"
45   #include "send.h"
46   #include "s_gline.h"
53 – #include "fileio.h"
47   #include "memory.h"
48   #include "irc_res.h"
49   #include "userhost.h"
50   #include "s_user.h"
51   #include "channel_mode.h"
52 + #include "parse.h"
53 + #include "s_misc.h"
54  
55   struct Callback *client_check_cb = NULL;
56   struct config_server_hide ConfigServerHide;
57  
58   /* general conf items link list root, other than k lines etc. */
59 + dlink_list service_items = { NULL, NULL, 0 };
60   dlink_list server_items  = { NULL, NULL, 0 };
61   dlink_list cluster_items = { NULL, NULL, 0 };
66 – dlink_list hub_items     = { NULL, NULL, 0 };
67 – dlink_list leaf_items    = { NULL, NULL, 0 };
62   dlink_list oconf_items   = { NULL, NULL, 0 };
63   dlink_list uconf_items   = { NULL, NULL, 0 };
64   dlink_list xconf_items   = { NULL, NULL, 0 };
# Line 72 | Line 66 | dlink_list rxconf_items  = { NULL, NULL,
66   dlink_list rkconf_items  = { NULL, NULL, 0 };
67   dlink_list nresv_items   = { NULL, NULL, 0 };
68   dlink_list class_items   = { NULL, NULL, 0 };
75 – dlink_list gdeny_items   = { NULL, NULL, 0 };
69  
77 – dlink_list temporary_klines  = { NULL, NULL, 0 };
78 – dlink_list temporary_dlines  = { NULL, NULL, 0 };
70   dlink_list temporary_xlines  = { NULL, NULL, 0 };
80 – dlink_list temporary_rklines = { NULL, NULL, 0 };
81 – dlink_list temporary_glines  = { NULL, NULL, 0 };
82 – dlink_list temporary_rxlines = { NULL, NULL, 0 };
71   dlink_list temporary_resv = { NULL, NULL, 0 };
72  
73   extern unsigned int lineno;
74   extern char linebuf[];
75   extern char conffilebuf[IRCD_BUFSIZE];
88 – extern char yytext[];
76   extern int yyparse(); /* defined in y.tab.c */
77 < unsigned int scount = 0; /* used by yyparse(), etc */
78 < int ypass  = 1; /* used by yyparse()      */
77 >
78 > struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
79  
80   /* internally defined functions */
81 < static void lookup_confhost(struct ConfItem *);
95 < static void set_default_conf(void);
96 < static void validate_conf(void);
97 < static void read_conf(FBFILE *);
81 > static void read_conf(FILE *);
82   static void clear_out_old_conf(void);
83   static void flush_deleted_I_P(void);
84   static void expire_tklines(dlink_list *);
# Line 117 | Line 101 | static void destroy_cidr_class(struct Cl
101  
102   static void flags_to_ascii(unsigned int, const unsigned int[], char *, int);
103  
120 – FBFILE *conf_fbfile_in = NULL;
121 –
104   /* address of default class conf */
105   static struct ConfItem *class_default;
106  
# Line 141 | Line 123 | static BlockHeap *ip_entry_heap = NULL;
123   static int ip_entries_count = 0;
124  
125  
126 < inline void *
126 > void *
127   map_to_conf(struct ConfItem *aconf)
128   {
129    void *conf;
130 <  conf = (void *)((unsigned long)aconf +
131 <                  (unsigned long)sizeof(struct ConfItem));
130 >  conf = (void *)((uintptr_t)aconf +
131 >                  (uintptr_t)sizeof(struct ConfItem));
132    return(conf);
133   }
134  
135 < inline struct ConfItem *
135 > struct ConfItem *
136   unmap_conf_item(void *aconf)
137   {
138    struct ConfItem *conf;
139  
140 <  conf = (struct ConfItem *)((unsigned long)aconf -
141 <                             (unsigned long)sizeof(struct ConfItem));
140 >  conf = (struct ConfItem *)((uintptr_t)aconf -
141 >                             (uintptr_t)sizeof(struct ConfItem));
142    return(conf);
143   }
144  
# Line 171 | Line 153 | unmap_conf_item(void *aconf)
153   * if successful save hp in the conf item it was called with
154   */
155   static void
156 < conf_dns_callback(void *vptr, struct DNSReply *reply)
156 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
157   {
158 <  struct AccessItem *aconf = (struct AccessItem *)vptr;
177 <  struct ConfItem *conf;
158 >  struct AccessItem *aconf = vptr;
159  
160 <  MyFree(aconf->dns_query);
180 <  aconf->dns_query = NULL;
160 >  aconf->dns_pending = 0;
161  
162 <  if (reply != NULL)
163 <    memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr));
164 <  else {
165 <    ilog(L_NOTICE, "Host not found: %s, ignoring connect{} block",
186 <         aconf->host);
187 <    conf = unmap_conf_item(aconf);
188 <    sendto_realops_flags(UMODE_ALL, L_ALL,
189 <                         "Ignoring connect{} block for %s - host not found",
190 <                         conf->name);
191 <    delete_conf_item(conf);
192 <  }
162 >  if (addr != NULL)
163 >    memcpy(&aconf->addr, addr, sizeof(aconf->addr));
164 >  else
165 >    aconf->dns_failed = 1;
166   }
167  
168   /* conf_dns_lookup()
# Line 201 | Line 174 | conf_dns_callback(void *vptr, struct DNS
174   static void
175   conf_dns_lookup(struct AccessItem *aconf)
176   {
177 <  if (aconf->dns_query == NULL)
177 >  if (!aconf->dns_pending)
178    {
179 <    aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
180 <    aconf->dns_query->ptr = aconf;
208 <    aconf->dns_query->callback = conf_dns_callback;
209 <    gethost_byname(aconf->host, aconf->dns_query);
179 >    aconf->dns_pending = 1;
180 >    gethost_byname(conf_dns_callback, aconf, aconf->host);
181    }
182   }
183  
# Line 277 | Line 248 | make_conf_item(ConfType type)
248      aconf->status = status;
249      break;
250  
280 –  case LEAF_TYPE:
281 –    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
282 –                                       sizeof(struct MatchItem));
283 –    dlinkAdd(conf, &conf->node, &leaf_items);
284 –    break;
285 –
286 –  case HUB_TYPE:
287 –    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
288 –                                       sizeof(struct MatchItem));
289 –    dlinkAdd(conf, &conf->node, &hub_items);
290 –    break;
291 –
251    case ULINE_TYPE:
252      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
253                                         sizeof(struct MatchItem));
254      dlinkAdd(conf, &conf->node, &uconf_items);
255      break;
256  
298 –  case GDENY_TYPE:
299 –    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
300 –                                       sizeof(struct AccessItem));
301 –    dlinkAdd(conf, &conf->node, &gdeny_items);
302 –    break;
303 –
257    case XLINE_TYPE:
258      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
259                                         sizeof(struct MatchItem));
260      dlinkAdd(conf, &conf->node, &xconf_items);
261      break;
262 <
262 > #ifdef HAVE_LIBPCRE
263    case RXLINE_TYPE:
264      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
265                                         sizeof(struct MatchItem));
# Line 320 | Line 273 | make_conf_item(ConfType type)
273      aconf->status = CONF_KLINE;
274      dlinkAdd(conf, &conf->node, &rkconf_items);
275      break;
276 <
276 > #endif
277    case CLUSTER_TYPE:
278      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem));
279      dlinkAdd(conf, &conf->node, &cluster_items);
# Line 337 | Line 290 | make_conf_item(ConfType type)
290      dlinkAdd(conf, &conf->node, &nresv_items);
291      break;
292  
293 +  case SERVICE_TYPE:
294 +    status = CONF_SERVICE;
295 +    conf = MyMalloc(sizeof(struct ConfItem));
296 +    dlinkAdd(conf, &conf->node, &service_items);
297 +    break;
298 +
299    case CLASS_TYPE:
300 <    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
301 <                                       sizeof(struct ClassItem));
300 >    conf = MyMalloc(sizeof(struct ConfItem) +
301 >                           sizeof(struct ClassItem));
302      dlinkAdd(conf, &conf->node, &class_items);
303 <    aclass = (struct ClassItem *)map_to_conf(conf);
304 <    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
305 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
306 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
307 <    MaxSendq(aclass) = DEFAULT_SENDQ;
308 <    CurrUserCount(aclass) = 0;
303 >
304 >    aclass = map_to_conf(conf);
305 >    aclass->active = 1;
306 >    aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
307 >    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
308 >    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
309 >    aclass->max_sendq = DEFAULT_SENDQ;
310 >    aclass->max_recvq = DEFAULT_RECVQ;
311 >
312      break;
313  
314    default:
# Line 357 | Line 319 | make_conf_item(ConfType type)
319    /* XXX Yes, this will core if default is hit. I want it to for now - db */
320    conf->type = type;
321  
322 <  return(conf);
322 >  return conf;
323   }
324  
325   void
326   delete_conf_item(struct ConfItem *conf)
327   {
328 +  dlink_node *m = NULL, *m_next = NULL;
329    struct MatchItem *match_item;
330    struct AccessItem *aconf;
331    ConfType type = conf->type;
# Line 381 | Line 344 | delete_conf_item(struct ConfItem *conf)
344    case SERVER_TYPE:
345      aconf = map_to_conf(conf);
346  
347 <    if (aconf->dns_query != NULL)
348 <    {
386 <      delete_resolver_queries(aconf->dns_query);
387 <      MyFree(aconf->dns_query);
388 <    }
347 >    if (aconf->dns_pending)
348 >      delete_resolver_queries(aconf);
349      if (aconf->passwd != NULL)
350        memset(aconf->passwd, 0, strlen(aconf->passwd));
351      if (aconf->spasswd != NULL)
# Line 398 | Line 358 | delete_conf_item(struct ConfItem *conf)
358      MyFree(aconf->oper_reason);
359      MyFree(aconf->user);
360      MyFree(aconf->host);
401 –    MyFree(aconf->fakename);
361   #ifdef HAVE_LIBCRYPTO
362 +    MyFree(aconf->cipher_list);
363 +
364      if (aconf->rsa_public_key)
365        RSA_free(aconf->rsa_public_key);
366      MyFree(aconf->rsa_public_key_file);
# Line 425 | Line 386 | delete_conf_item(struct ConfItem *conf)
386  
387      case SERVER_TYPE:
388        aconf = map_to_conf(conf);
389 +
390 +      DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head)
391 +      {
392 +        MyFree(m->data);
393 +        free_dlink_node(m);
394 +      }
395 +
396 +      DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head)
397 +      {
398 +        MyFree(m->data);
399 +        free_dlink_node(m);  
400 +      }
401 +
402        if (!IsConfIllegal(aconf))
403          dlinkDelete(&conf->node, &server_items);
404        MyFree(conf);
# Line 435 | Line 409 | delete_conf_item(struct ConfItem *conf)
409      }
410      break;
411  
438 –  case HUB_TYPE:
439 –    match_item = map_to_conf(conf);
440 –    MyFree(match_item->user);
441 –    MyFree(match_item->host);
442 –    MyFree(match_item->reason);
443 –    MyFree(match_item->oper_reason);
444 –    /* If marked illegal, its already been pulled off of the hub_items list */
445 –    if (!match_item->illegal)
446 –      dlinkDelete(&conf->node, &hub_items);
447 –    MyFree(conf);
448 –    break;
449 –
450 –  case LEAF_TYPE:
451 –    match_item = map_to_conf(conf);
452 –    MyFree(match_item->user);
453 –    MyFree(match_item->host);
454 –    MyFree(match_item->reason);
455 –    MyFree(match_item->oper_reason);
456 –    /* If marked illegal, its already been pulled off of the leaf_items list */
457 –    if (!match_item->illegal)
458 –      dlinkDelete(&conf->node, &leaf_items);
459 –    MyFree(conf);
460 –    break;
461 –
412    case ULINE_TYPE:
413      match_item = map_to_conf(conf);
414      MyFree(match_item->user);
# Line 478 | Line 428 | delete_conf_item(struct ConfItem *conf)
428      dlinkDelete(&conf->node, &xconf_items);
429      MyFree(conf);
430      break;
431 <
431 > #ifdef HAVE_LIBPCRE
432    case RKLINE_TYPE:
433      aconf = map_to_conf(conf);
434      MyFree(aconf->regexuser);
# Line 501 | Line 451 | delete_conf_item(struct ConfItem *conf)
451      dlinkDelete(&conf->node, &rxconf_items);
452      MyFree(conf);
453      break;
454 <
454 > #endif
455    case NRESV_TYPE:
456      match_item = map_to_conf(conf);
457      MyFree(match_item->user);
# Line 509 | Line 459 | delete_conf_item(struct ConfItem *conf)
459      MyFree(match_item->reason);
460      MyFree(match_item->oper_reason);
461      dlinkDelete(&conf->node, &nresv_items);
512 –    MyFree(conf);
513 –    break;
462  
463 <  case GDENY_TYPE:
464 <    aconf = map_to_conf(conf);
465 <    MyFree(aconf->user);
466 <    MyFree(aconf->host);
519 <    dlinkDelete(&conf->node, &gdeny_items);
463 >    if (conf->flags & CONF_FLAGS_TEMPORARY)
464 >      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
465 >        free_dlink_node(m);
466 >
467      MyFree(conf);
468      break;
469  
# Line 526 | Line 473 | delete_conf_item(struct ConfItem *conf)
473      break;
474  
475    case CRESV_TYPE:
476 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
477 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
478 +        free_dlink_node(m);
479 +
480      MyFree(conf);
481      break;
482  
# Line 534 | Line 485 | delete_conf_item(struct ConfItem *conf)
485      MyFree(conf);
486      break;
487  
488 +  case SERVICE_TYPE:
489 +    dlinkDelete(&conf->node, &service_items);
490 +    MyFree(conf);
491 +    break;
492 +
493    default:
494      break;
495    }
# Line 567 | Line 523 | static const unsigned int shared_bit_tab
523   * side effects -
524   */
525   void
526 < report_confitem_types(struct Client *source_p, ConfType type, int temp)
526 > report_confitem_types(struct Client *source_p, ConfType type)
527   {
528 <  dlink_node *ptr = NULL;
528 >  dlink_node *ptr = NULL, *dptr = NULL;
529    struct ConfItem *conf = NULL;
530    struct AccessItem *aconf = NULL;
531    struct MatchItem *matchitem = NULL;
# Line 579 | Line 535 | report_confitem_types(struct Client *sou
535  
536    switch (type)
537    {
582 –  case GDENY_TYPE:
583 –    DLINK_FOREACH(ptr, gdeny_items.head)
584 –    {
585 –      conf = ptr->data;
586 –      aconf = map_to_conf(conf);
587 –
588 –      p = buf;
589 –
590 –      if (aconf->flags & GDENY_BLOCK)
591 –        *p++ = 'B';
592 –      else
593 –        *p++ = 'b';
594 –
595 –      if (aconf->flags & GDENY_REJECT)
596 –        *p++ = 'R';
597 –      else
598 –        *p++ = 'r';
599 –
600 –      *p = '\0';
601 –
602 –      sendto_one(source_p, ":%s %d %s V %s@%s %s %s",
603 –                 me.name, RPL_STATSDEBUG, source_p->name,
604 –                 aconf->user, aconf->host, conf->name, buf);
605 –    }
606 –    break;
607 –
538    case XLINE_TYPE:
539      DLINK_FOREACH(ptr, xconf_items.head)
540      {
# Line 618 | Line 548 | report_confitem_types(struct Client *sou
548      }
549      break;
550  
551 + #ifdef HAVE_LIBPCRE
552    case RXLINE_TYPE:
553      DLINK_FOREACH(ptr, rxconf_items.head)
554      {
# Line 626 | Line 557 | report_confitem_types(struct Client *sou
557  
558        sendto_one(source_p, form_str(RPL_STATSXLINE),
559                   me.name, source_p->name,
560 <                 matchitem->hold ? "xR": "XR", matchitem->count,
560 >                 "XR", matchitem->count,
561                   conf->name, matchitem->reason);
562      }
563      break;
564  
565    case RKLINE_TYPE:
635 –    p = temp ? "Rk" : "RK";
636 –
566      DLINK_FOREACH(ptr, rkconf_items.head)
567      {
568        aconf = map_to_conf((conf = ptr->data));
569  
641 –      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
642 –        continue;
643 –
570        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
571 <                 source_p->name, p, aconf->host, aconf->user,
571 >                 source_p->name, "KR", aconf->host, aconf->user,
572                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
573      }
574      break;
575 + #endif
576  
577    case ULINE_TYPE:
578      DLINK_FOREACH(ptr, uconf_items.head)
# Line 690 | Line 617 | report_confitem_types(struct Client *sou
617        aconf = map_to_conf(conf);
618  
619        /* Don't allow non opers to see oper privs */
620 <      if (IsOper(source_p))
620 >      if (HasUMode(source_p, UMODE_OPER))
621          sendto_one(source_p, form_str(RPL_STATSOLINE),
622                     me.name, source_p->name, 'O', aconf->user, aconf->host,
623                     conf->name, oper_privs_as_string(aconf->port),
# Line 710 | Line 637 | report_confitem_types(struct Client *sou
637        classitem = map_to_conf(conf);
638        sendto_one(source_p, form_str(RPL_STATSYLINE),
639                   me.name, source_p->name, 'Y',
640 <                 conf->name, PingFreq(classitem),
641 <                 ConFreq(classitem),
642 <                 MaxTotal(classitem), MaxSendq(classitem));
640 >                 conf->name, classitem->ping_freq,
641 >                 classitem->con_freq,
642 >                 classitem->max_total, classitem->max_sendq,
643 >                 classitem->max_recvq,
644 >                 classitem->curr_user_count,
645 >                 classitem->number_per_cidr, classitem->cidr_bitlen_ipv4,
646 >                 classitem->number_per_cidr, classitem->cidr_bitlen_ipv6,
647 >                 classitem->active ? "active" : "disabled");
648      }
649      break;
650  
# Line 720 | Line 652 | report_confitem_types(struct Client *sou
652    case CLIENT_TYPE:
653      break;
654  
655 +  case SERVICE_TYPE:
656 +    DLINK_FOREACH(ptr, service_items.head)
657 +    {
658 +      conf = ptr->data;
659 +      sendto_one(source_p, form_str(RPL_STATSSERVICE),
660 +                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
661 +    }
662 +    break;
663 +
664    case SERVER_TYPE:
665      DLINK_FOREACH(ptr, server_items.head)
666      {
# Line 732 | Line 673 | report_confitem_types(struct Client *sou
673  
674        if (IsConfAllowAutoConn(aconf))
675          *p++ = 'A';
676 <      if (IsConfCryptLink(aconf))
677 <        *p++ = 'C';
737 <      if (IsConfLazyLink(aconf))
738 <        *p++ = 'L';
739 <      if (aconf->fakename)
740 <        *p++ = 'M';
676 >      if (IsConfSSL(aconf))
677 >        *p++ = 'S';
678        if (IsConfTopicBurst(aconf))
679          *p++ = 'T';
743 –      if (IsConfCompressed(aconf))
744 –        *p++ = 'Z';
680        if (buf[0] == '\0')
681          *p++ = '*';
682  
683        *p = '\0';
684  
685 <      /* Allow admins to see actual ips
686 <       * unless hide_server_ips is enabled
685 >      /*
686 >       * Allow admins to see actual ips unless hide_server_ips is enabled
687         */
688 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
688 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
689          sendto_one(source_p, form_str(RPL_STATSCLINE),
690                     me.name, source_p->name, 'C', aconf->host,
691                     buf, conf->name, aconf->port,
# Line 764 | Line 699 | report_confitem_types(struct Client *sou
699      break;
700  
701    case HUB_TYPE:
702 <    DLINK_FOREACH(ptr, hub_items.head)
702 >    DLINK_FOREACH(ptr, server_items.head)
703      {
704        conf = ptr->data;
705 <      matchitem = map_to_conf(conf);
706 <      sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
707 <                 source_p->name, 'H', matchitem->host, conf->name, 0, "*");
705 >      aconf = map_to_conf(conf);
706 >
707 >      DLINK_FOREACH(dptr, aconf->hub_list.head)
708 >        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
709 >                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
710      }
711      break;
712  
713    case LEAF_TYPE:
714 <    DLINK_FOREACH(ptr, leaf_items.head)
714 >    DLINK_FOREACH(ptr, server_items.head)
715      {
716        conf = ptr->data;
717 <      matchitem = map_to_conf(conf);
718 <      sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
719 <                 source_p->name, 'L', matchitem->host, conf->name, 0, "*");
717 >      aconf = map_to_conf(conf);
718 >
719 >      DLINK_FOREACH(dptr, aconf->leaf_list.head)
720 >        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
721 >                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
722      }
723      break;
724  
# Line 790 | Line 729 | report_confitem_types(struct Client *sou
729    case CRESV_TYPE:
730    case NRESV_TYPE:
731    case CLUSTER_TYPE:
732 +  default:
733      break;
734    }
735   }
# Line 816 | Line 756 | check_client(va_list args)
756  
757    /* I'm already in big trouble if source_p->localClient is NULL -db */
758    if ((i = verify_access(source_p, username)))
759 <  {
820 <    ilog(L_INFO, "Access denied: %s[%s]",
759 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
760           source_p->name, source_p->sockhost);
822 –  }
761  
762    switch (i)
763    {
826 –    case IRCD_SOCKET_ERROR:
827 –      exit_client(source_p, &me, "Socket Error");
828 –      break;
829 –
764      case TOO_MANY:
765        sendto_realops_flags(UMODE_FULL, L_ALL,
766                             "Too many on IP for %s (%s).",
767                             get_client_name(source_p, SHOW_IP),
768                             source_p->sockhost);
769 <      ilog(L_INFO,"Too many connections on IP from %s.",
769 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
770             get_client_name(source_p, SHOW_IP));
771 <      ServerStats->is_ref++;
771 >      ++ServerStats.is_ref;
772        exit_client(source_p, &me, "No more connections allowed on that IP");
773        break;
774  
# Line 843 | Line 777 | check_client(va_list args)
777                             "I-line is full for %s (%s).",
778                             get_client_name(source_p, SHOW_IP),
779                             source_p->sockhost);
780 <      ilog(L_INFO,"Too many connections from %s.",
780 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
781             get_client_name(source_p, SHOW_IP));
782 <       ServerStats->is_ref++;
782 >      ++ServerStats.is_ref;
783        exit_client(source_p, &me,
784                  "No more connections allowed in your connection class");
785        break;
786  
787      case NOT_AUTHORIZED:
788 <    {
855 <      static char ipaddr[HOSTIPLEN];
856 <      ServerStats->is_ref++;
788 >      ++ServerStats.is_ref;
789        /* jdc - lists server name & port connections are on */
790        /*       a purely cosmetical change */
859 –      irc_getnameinfo((struct sockaddr*)&source_p->localClient->ip,
860 –            source_p->localClient->ip.ss_len, ipaddr, HOSTIPLEN, NULL, 0,
861 –            NI_NUMERICHOST);
791        sendto_realops_flags(UMODE_UNAUTH, L_ALL,
792                             "Unauthorized client connection from %s [%s] on [%s/%u].",
793                             get_client_name(source_p, SHOW_IP),
794 <                           ipaddr,
794 >                           source_p->sockhost,
795                             source_p->localClient->listener->name,
796                             source_p->localClient->listener->port);
797 <      ilog(L_INFO,
797 >      ilog(LOG_TYPE_IRCD,
798            "Unauthorized client connection from %s on [%s/%u].",
799            get_client_name(source_p, SHOW_IP),
800            source_p->localClient->listener->name,
# Line 875 | Line 804 | check_client(va_list args)
804         * capture reject code here or rely on the connecting too fast code.
805         * - Dianora
806         */
807 <      if(REJECT_HOLD_TIME > 0)
807 >      if (REJECT_HOLD_TIME > 0)
808        {
809          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
810                     me.name, source_p->name);
# Line 885 | Line 814 | check_client(va_list args)
814        else
815          exit_client(source_p, &me, "You are not authorized to use this server");
816        break;
817 <    }
889 <
817 >
818     case BANNED_CLIENT:
819       /*
820        * Don't exit them immediately, play with them a bit.
# Line 899 | Line 827 | check_client(va_list args)
827       }
828       else
829         exit_client(source_p, &me, "Banned");
830 <     ServerStats->is_ref++;
830 >     ++ServerStats.is_ref;
831       break;
832  
833     case 0:
# Line 1016 | Line 944 | attach_iline(struct Client *client_p, st
944    ip_found->count++;
945    SetIpHash(client_p);
946  
947 <  aconf = (struct AccessItem *)map_to_conf(conf);
947 >  aconf = map_to_conf(conf);
948    if (aconf->class_ptr == NULL)
949      return NOT_AUTHORIZED;  /* If class is missing, this is best */
950  
951 <  aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
951 >  aclass = map_to_conf(aconf->class_ptr);
952  
953    count_user_host(client_p->username, client_p->host,
954                    &global, &local, &ident);
# Line 1029 | Line 957 | attach_iline(struct Client *client_p, st
957     * setting a_limit_reached if any limit is reached.
958     * - Dianora
959     */
960 <  if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
960 >  if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
961      a_limit_reached = 1;
962 <  else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass))
962 >  else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
963      a_limit_reached = 1;
964 <  else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
964 >  else if (aclass->max_local != 0 && local >= aclass->max_local)
965      a_limit_reached = 1;
966 <  else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))
966 >  else if (aclass->max_global != 0 && global >= aclass->max_global)
967      a_limit_reached = 1;
968 <  else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&
968 >  else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
969             client_p->username[0] != '~')
970      a_limit_reached = 1;
971  
972    if (a_limit_reached)
973    {
974      if (!IsConfExemptLimits(aconf))
975 <      return TOO_MANY;  /* Already at maximum allowed */
975 >      return TOO_MANY;   /* Already at maximum allowed */
976  
977      sendto_one(client_p,
978                 ":%s NOTICE %s :*** Your connection class is full, "
# Line 1193 | Line 1121 | hash_ip(struct irc_ssaddr *addr)
1121    {
1122      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
1123      int hash;
1124 <    u_int32_t ip;
1124 >    uint32_t ip;
1125  
1126      ip   = ntohl(v4->sin_addr.s_addr);
1127      hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
# Line 1204 | Line 1132 | hash_ip(struct irc_ssaddr *addr)
1132    {
1133      int hash;
1134      struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
1135 <    u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr;
1135 >    uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
1136  
1137      hash  = ip[0] ^ ip[3];
1138      hash ^= hash >> 16;  
# Line 1228 | Line 1156 | hash_ip(struct irc_ssaddr *addr)
1156   * used in the hash.
1157   */
1158   void
1159 < count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored)
1159 > count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
1160   {
1161    struct ip_entry *ptr;
1162    int i;
# Line 1316 | Line 1244 | detach_conf(struct Client *client_p, Con
1244        case CLIENT_TYPE:
1245        case OPER_TYPE:
1246        case SERVER_TYPE:
1247 <        aconf = (struct AccessItem *)map_to_conf(conf);
1248 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1247 >        aconf = map_to_conf(conf);
1248 >
1249 >        assert(aconf->clients > 0);
1250 >
1251 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1252          {
1253 <          aclass = (struct ClassItem *)map_to_conf(aclass_conf);
1253 >          aclass = map_to_conf(aclass_conf);
1254 >
1255 >          assert(aclass->curr_user_count > 0);
1256  
1257            if (conf->type == CLIENT_TYPE)
1258              remove_from_cidr_check(&client_p->localClient->ip, aclass);
1259 <
1327 <          if (CurrUserCount(aclass) > 0)
1328 <            aclass->curr_user_count--;
1329 <          if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0)
1259 >          if (--aclass->curr_user_count == 0 && aclass->active == 0)
1260              delete_conf_item(aclass_conf);
1261          }
1262  
1263 <        /* Please, no ioccc entries - Dianora */
1334 <        if (aconf->clients > 0)
1335 <          --aconf->clients;
1336 <        if (aconf->clients == 0 && IsConfIllegal(aconf))
1337 <          delete_conf_item(conf);
1338 <        break;
1339 <      case LEAF_TYPE:
1340 <      case HUB_TYPE:
1341 <        match_item = (struct MatchItem *)map_to_conf(conf);
1342 <        if (match_item->ref_count == 0 && match_item->illegal)
1263 >        if (--aconf->clients == 0 && IsConfIllegal(aconf))
1264            delete_conf_item(conf);
1265 +
1266          break;
1267        default:
1268          break;
# Line 1367 | Line 1289 | detach_conf(struct Client *client_p, Con
1289   int
1290   attach_conf(struct Client *client_p, struct ConfItem *conf)
1291   {
1292 <  struct AccessItem *aconf;
1293 <  struct MatchItem *match_item;
1292 >  struct AccessItem *aconf = map_to_conf(conf);
1293 >  struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1294  
1295    if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
1296      return 1;
1297  
1298 <  if (conf->type == CLIENT_TYPE ||
1299 <      conf->type == SERVER_TYPE ||
1378 <      conf->type == OPER_TYPE)
1379 <  {
1380 <    aconf = (struct AccessItem *)map_to_conf(conf);
1298 >  if (IsConfIllegal(aconf)) /* TBV: can't happen */
1299 >    return NOT_AUTHORIZED;
1300  
1301 <    if (IsConfIllegal(aconf))
1302 <      return NOT_AUTHORIZED;
1303 <
1304 <    if (conf->type == CLIENT_TYPE)
1386 <    {
1387 <      struct ClassItem *aclass;
1388 <      aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1389 <
1390 <      if (cidr_limit_reached(IsConfExemptLimits(aconf),
1391 <                             &client_p->localClient->ip, aclass))
1392 <        return TOO_MANY;  /* Already at maximum allowed */
1393 <
1394 <      CurrUserCount(aclass)++;
1395 <    }
1301 >  if (conf->type == CLIENT_TYPE)
1302 >    if (cidr_limit_reached(IsConfExemptLimits(aconf),
1303 >                           &client_p->localClient->ip, aclass))
1304 >      return TOO_MANY;    /* Already at maximum allowed */
1305  
1306 <    aconf->clients++;
1307 <  }
1399 <  else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
1400 <  {
1401 <    match_item = (struct MatchItem *)map_to_conf(conf);
1402 <    match_item->ref_count++;
1403 <  }
1306 >  aclass->curr_user_count++;
1307 >  aconf->clients++;
1308  
1309    dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
1310  
# Line 1432 | Line 1336 | attach_connect_block(struct Client *clie
1336    DLINK_FOREACH(ptr, server_items.head)
1337    {
1338      conf = ptr->data;
1339 <    aconf = (struct AccessItem *)map_to_conf(conf);
1339 >    aconf = map_to_conf(conf);
1340  
1341      if (match(conf->name, name) == 0 || match(aconf->host, host) == 0)
1342        continue;
# Line 1472 | Line 1376 | find_conf_exact(ConfType type, const cha
1376  
1377      if (conf->name == NULL)
1378        continue;
1379 <    aconf = (struct AccessItem *)map_to_conf(conf);
1379 >    aconf = map_to_conf(conf);
1380      if (aconf->host == NULL)
1381        continue;
1382      if (irccmp(conf->name, name) != 0)
# Line 1483 | Line 1387 | find_conf_exact(ConfType type, const cha
1387      ** socket host) matches *either* host or name field
1388      ** of the configuration.
1389      */
1390 <    if (!match(aconf->host, host) || !match(aconf->user,user)
1487 <        || irccmp(conf->name, name) )
1390 >    if (!match(aconf->host, host) || !match(aconf->user, user))
1391        continue;
1392      if (type == OPER_TYPE)
1393      {
1394 <      struct ClassItem *aclass;
1394 >      struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1395  
1396 <      aclass = (struct ClassItem *)aconf->class_ptr;
1494 <      if (aconf->clients < MaxTotal(aclass))
1495 <        return conf;
1496 <      else
1396 >      if (aconf->clients >= aclass->max_total)
1397          continue;
1398      }
1399 <    else
1400 <      return conf;
1399 >
1400 >    return conf;
1401    }
1402 +
1403    return NULL;
1404   }
1405  
# Line 1564 | Line 1465 | map_to_list(ConfType type)
1465    case SERVER_TYPE:
1466      return(&server_items);
1467      break;
1468 +  case SERVICE_TYPE:
1469 +    return(&service_items);
1470 +    break;
1471    case CLUSTER_TYPE:
1472      return(&cluster_items);
1473      break;
# Line 1599 | Line 1503 | find_matching_name_conf(ConfType type, c
1503  
1504    switch (type)
1505    {
1506 <    case RXLINE_TYPE:
1506 > #ifdef HAVE_LIBPCRE
1507 >  case RXLINE_TYPE:
1508        DLINK_FOREACH(ptr, list_p->head)
1509        {
1510          conf = ptr->data;
# Line 1609 | Line 1514 | find_matching_name_conf(ConfType type, c
1514            return conf;
1515        }
1516        break;
1517 + #endif
1518 +  case SERVICE_TYPE:
1519 +    DLINK_FOREACH(ptr, list_p->head)
1520 +    {
1521 +      conf = ptr->data;
1522 +
1523 +      if (EmptyString(conf->name))
1524 +        continue;
1525 +      if ((name != NULL) && !irccmp(name, conf->name))
1526 +        return conf;
1527 +    }
1528 +    break;
1529  
1530    case XLINE_TYPE:
1531    case ULINE_TYPE:
# Line 1663 | Line 1580 | find_matching_name_conf(ConfType type, c
1580   * side effects - looks for an exact match on name field
1581   */
1582   struct ConfItem *
1583 < find_exact_name_conf(ConfType type, const char *name,
1583 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1584                       const char *user, const char *host)
1585   {
1586    dlink_node *ptr = NULL;
# Line 1704 | Line 1621 | find_exact_name_conf(ConfType type, cons
1621      DLINK_FOREACH(ptr, list_p->head)
1622      {
1623        conf = ptr->data;
1624 <      aconf = (struct AccessItem *)map_to_conf(conf);
1624 >      aconf = map_to_conf(conf);
1625 >
1626        if (EmptyString(conf->name))
1627 <        continue;
1628 <    
1629 <      if (irccmp(conf->name, name) == 0)
1627 >        continue;
1628 >
1629 >      if (!irccmp(conf->name, name))
1630        {
1631 <        if ((user == NULL && (host == NULL)))
1632 <          return (conf);
1633 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1634 <          return (conf);
1635 <        if (match(aconf->user, user) && match(aconf->host, host))
1636 <          return (conf);
1631 >        if (!who)
1632 >          return conf;
1633 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1634 >          return conf;
1635 >        if (match(aconf->user, who->username))
1636 >        {
1637 >          switch (aconf->type)
1638 >          {
1639 >            case HM_HOST:
1640 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1641 >                return conf;
1642 >              break;
1643 >            case HM_IPV4:
1644 >              if (who->localClient->aftype == AF_INET)
1645 >                if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits))
1646 >                  return conf;
1647 >              break;
1648 > #ifdef IPV6
1649 >            case HM_IPV6:
1650 >              if (who->localClient->aftype == AF_INET6)
1651 >                if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits))
1652 >                  return conf;
1653 >              break;
1654 > #endif
1655 >            default:
1656 >              assert(0);
1657 >          }
1658 >        }
1659        }
1660      }
1661 +
1662      break;
1663  
1664    case SERVER_TYPE:
# Line 1773 | Line 1714 | rehash(int sig)
1714      sendto_realops_flags(UMODE_ALL, L_ALL,
1715                           "Got signal SIGHUP, reloading ircd.conf file");
1716  
1776 – #ifndef _WIN32
1717    restart_resolver();
1718 < #endif
1718 >
1719    /* don't close listeners until we know we can go ahead with the rehash */
1720  
1721    /* Check to see if we magically got(or lost) IPv6 support */
# Line 1786 | Line 1726 | rehash(int sig)
1726    if (ServerInfo.description != NULL)
1727      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1728  
1789 – #ifndef STATIC_MODULES
1729    load_conf_modules();
1791 – #endif
1730  
1731    flush_deleted_I_P();
1732  
1733    rehashed_klines = 1;
1734 <
1734 > /* XXX */
1735    if (ConfigLoggingEntry.use_logging)
1736 <    reopen_log(logFileName);
1736 >    log_close_all();
1737  
1738    return(0);
1739   }
# Line 1834 | Line 1772 | set_default_conf(void)
1772    ServerInfo.specific_ipv6_vhost = 0;
1773  
1774    ServerInfo.max_clients = MAXCLIENTS_MAX;
1775 <  /* Don't reset hub, as that will break lazylinks */
1776 <  /* ServerInfo.hub = NO; */
1775 >
1776 >  ServerInfo.hub = 0;
1777    ServerInfo.dns_host.sin_addr.s_addr = 0;
1778    ServerInfo.dns_host.sin_port = 0;
1779    AdminInfo.name = NULL;
1780    AdminInfo.email = NULL;
1781    AdminInfo.description = NULL;
1782  
1783 <  set_log_level(L_NOTICE);
1783 >  log_close_all();
1784 >
1785    ConfigLoggingEntry.use_logging = 1;
1786 <  ConfigLoggingEntry.operlog[0] = '\0';
1787 <  ConfigLoggingEntry.userlog[0] = '\0';
1788 <  ConfigLoggingEntry.klinelog[0] = '\0';
1850 <  ConfigLoggingEntry.glinelog[0] = '\0';
1851 <  ConfigLoggingEntry.killlog[0] = '\0';
1852 <  ConfigLoggingEntry.operspylog[0] = '\0';
1853 <  ConfigLoggingEntry.ioerrlog[0] = '\0';
1854 <  ConfigLoggingEntry.failed_operlog[0] = '\0';
1855 <
1856 <  ConfigChannel.restrict_channels = NO;
1857 <  ConfigChannel.disable_local_channels = NO;
1858 <  ConfigChannel.use_invex = YES;
1859 <  ConfigChannel.use_except = YES;
1860 <  ConfigChannel.use_knock = YES;
1786 >
1787 >  ConfigChannel.disable_fake_channels = 0;
1788 >  ConfigChannel.restrict_channels = 0;
1789    ConfigChannel.knock_delay = 300;
1790    ConfigChannel.knock_delay_channel = 60;
1791 <  ConfigChannel.invite_ops_only = YES;
1792 <  ConfigChannel.max_chans_per_user = 15;
1793 <  ConfigChannel.quiet_on_ban = YES;
1791 >  ConfigChannel.max_chans_per_user = 25;
1792 >  ConfigChannel.max_chans_per_oper = 50;
1793 >  ConfigChannel.quiet_on_ban = 1;
1794    ConfigChannel.max_bans = 25;
1795    ConfigChannel.default_split_user_count = 0;
1796    ConfigChannel.default_split_server_count = 0;
1797 <  ConfigChannel.no_join_on_split = NO;
1798 <  ConfigChannel.no_create_on_split = NO;
1871 <  ConfigChannel.burst_topicwho = YES;
1797 >  ConfigChannel.no_join_on_split = 0;
1798 >  ConfigChannel.no_create_on_split = 0;
1799  
1800 <  ConfigServerHide.flatten_links = NO;
1800 >  ConfigServerHide.flatten_links = 0;
1801    ConfigServerHide.links_delay = 300;
1802 <  ConfigServerHide.hidden = NO;
1803 <  ConfigServerHide.disable_hidden = NO;
1877 <  ConfigServerHide.hide_servers = NO;
1802 >  ConfigServerHide.hidden = 0;
1803 >  ConfigServerHide.hide_servers = 0;
1804    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1805 <  ConfigServerHide.hide_server_ips = NO;
1805 >  ConfigServerHide.hide_server_ips = 0;
1806  
1807 +  
1808 +  DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1809 +  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1810 +  ConfigFileEntry.glines = 0;
1811 +  ConfigFileEntry.gline_time = 12 * 3600;
1812 +  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
1813    ConfigFileEntry.gline_min_cidr = 16;
1814    ConfigFileEntry.gline_min_cidr6 = 48;
1815 <  ConfigFileEntry.invisible_on_connect = YES;
1816 <  ConfigFileEntry.burst_away = NO;
1817 <  ConfigFileEntry.use_whois_actually = YES;
1818 <  ConfigFileEntry.tkline_expire_notices = YES;
1819 <  ConfigFileEntry.hide_spoof_ips = YES;
1820 <  ConfigFileEntry.ignore_bogus_ts = NO;
1821 <  ConfigFileEntry.disable_auth = NO;
1822 <  ConfigFileEntry.disable_remote = NO;
1815 >  ConfigFileEntry.invisible_on_connect = 1;
1816 >  ConfigFileEntry.burst_away = 0;
1817 >  ConfigFileEntry.use_whois_actually = 1;
1818 >  ConfigFileEntry.tkline_expire_notices = 1;
1819 >  ConfigFileEntry.hide_spoof_ips = 1;
1820 >  ConfigFileEntry.ignore_bogus_ts = 0;
1821 >  ConfigFileEntry.disable_auth = 0;
1822 >  ConfigFileEntry.disable_remote = 0;
1823    ConfigFileEntry.kill_chase_time_limit = 90;
1824 <  ConfigFileEntry.default_floodcount = 8; /* XXX */
1825 <  ConfigFileEntry.failed_oper_notice = YES;
1826 <  ConfigFileEntry.dots_in_ident = 0;      /* XXX */
1895 <  ConfigFileEntry.dot_in_ip6_addr = YES;
1824 >  ConfigFileEntry.default_floodcount = 8;
1825 >  ConfigFileEntry.failed_oper_notice = 1;
1826 >  ConfigFileEntry.dots_in_ident = 0;
1827    ConfigFileEntry.min_nonwildcard = 4;
1828    ConfigFileEntry.min_nonwildcard_simple = 3;
1829    ConfigFileEntry.max_accept = 20;
1830 <  ConfigFileEntry.anti_nick_flood = NO;   /* XXX */
1830 >  ConfigFileEntry.anti_nick_flood = 0;
1831    ConfigFileEntry.max_nick_time = 20;
1832    ConfigFileEntry.max_nick_changes = 5;
1833 <  ConfigFileEntry.anti_spam_exit_message_time = 0;  /* XXX */
1833 >  ConfigFileEntry.anti_spam_exit_message_time = 0;
1834    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1835 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;  /* XXX */
1836 <  ConfigFileEntry.kline_with_reason = YES;
1835 >  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1836 >  ConfigFileEntry.kline_with_reason = 1;
1837    ConfigFileEntry.kline_reason = NULL;
1838 <  ConfigFileEntry.warn_no_nline = YES;
1839 <  ConfigFileEntry.stats_o_oper_only = NO; /* XXX */
1838 >  ConfigFileEntry.warn_no_nline = 1;
1839 >  ConfigFileEntry.stats_o_oper_only = 0;
1840    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1841    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1842 <  ConfigFileEntry.stats_P_oper_only = NO;
1842 >  ConfigFileEntry.stats_P_oper_only = 0;
1843    ConfigFileEntry.caller_id_wait = 60;
1844 <  ConfigFileEntry.opers_bypass_callerid = NO;
1844 >  ConfigFileEntry.opers_bypass_callerid = 0;
1845    ConfigFileEntry.pace_wait = 10;
1846    ConfigFileEntry.pace_wait_simple = 1;
1847 <  ConfigFileEntry.short_motd = NO;
1848 <  ConfigFileEntry.ping_cookie = NO;
1849 <  ConfigFileEntry.no_oper_flood = NO;     /* XXX */
1850 <  ConfigFileEntry.true_no_oper_flood = NO;  /* XXX */
1851 <  ConfigFileEntry.oper_pass_resv = YES;
1921 <  ConfigFileEntry.glines = NO;            /* XXX */
1922 <  ConfigFileEntry.gline_time = 12 * 3600; /* XXX */
1923 <  ConfigFileEntry.idletime = 0;
1847 >  ConfigFileEntry.short_motd = 0;
1848 >  ConfigFileEntry.ping_cookie = 0;
1849 >  ConfigFileEntry.no_oper_flood = 0;
1850 >  ConfigFileEntry.true_no_oper_flood = 0;
1851 >  ConfigFileEntry.oper_pass_resv = 1;
1852    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1853 <  ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1854 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;  /* XXX */
1855 <  ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE |
1856 <    UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1929 <  DupString(ConfigFileEntry.servlink_path, SLPATH);
1930 < #ifdef HAVE_LIBCRYPTO
1931 <  /* jdc -- This is our default value for a cipher.  According to the
1932 <   *        CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
1933 <   *        under all circumstances if cryptlinks are enabled.  So,
1934 <   *        this will be our default.
1935 <   *
1936 <   *        NOTE: I apologise for the hard-coded value of "1" (BF/128).
1937 <   *              This should be moved into a find_cipher() routine.
1938 <   */
1939 <  ConfigFileEntry.default_cipher_preference = &CipherTable[1];
1940 < #endif
1941 <  ConfigFileEntry.use_egd = NO;
1853 >  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1854 >  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1855 >    UMODE_OPERWALL | UMODE_WALLOP;
1856 >  ConfigFileEntry.use_egd = 0;
1857    ConfigFileEntry.egdpool_path = NULL;
1943 – #ifdef HAVE_LIBZ
1944 –  ConfigFileEntry.compression_level = 0;
1945 – #endif
1858    ConfigFileEntry.throttle_time = 10;
1859   }
1860  
1861 + static void
1862 + validate_conf(void)
1863 + {
1864 +  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
1865 +    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1866 +
1867 +  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1868 +    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1869 +
1870 +  if (ServerInfo.network_name == NULL)
1871 +    DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1872 +
1873 +  if (ServerInfo.network_desc == NULL)
1874 +    DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1875 +
1876 +  if (ConfigFileEntry.service_name == NULL)
1877 +    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1878 +
1879 +  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1880 + }
1881 +
1882   /* read_conf()
1883   *
1884   * inputs       - file descriptor pointing to config file to use
# Line 1953 | Line 1886 | set_default_conf(void)
1886   * side effects - Read configuration file.
1887   */
1888   static void
1889 < read_conf(FBFILE *file)
1889 > read_conf(FILE *file)
1890   {
1891 <  scount = lineno = 0;
1891 >  lineno = 0;
1892  
1893    set_default_conf(); /* Set default values prior to conf parsing */
1894 <  ypass = 1;
1894 >  conf_parser_ctx.pass = 1;
1895    yyparse();          /* pick up the classes first */
1896  
1897 <  fbrewind(file);
1897 >  rewind(file);
1898  
1899 <  ypass = 2;
1899 >  conf_parser_ctx.pass = 2;
1900    yyparse();          /* Load the values from the conf */
1901    validate_conf();    /* Check to make sure some values are still okay. */
1902                        /* Some global values are also loaded here. */
1903    check_class();      /* Make sure classes are valid */
1904   }
1905  
1973 – static void
1974 – validate_conf(void)
1975 – {
1976 –  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
1977 –    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1978 –
1979 –  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1980 –    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1981 –
1982 –  if (ConfigFileEntry.servlink_path == NULL)
1983 –    DupString(ConfigFileEntry.servlink_path, SLPATH);
1984 –
1985 –  if (ServerInfo.network_name == NULL)
1986 –    DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1987 –
1988 –  if (ServerInfo.network_desc == NULL)
1989 –    DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1990 –
1991 –  if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
1992 –      (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
1993 –    ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
1994 – }
1995 –
1906   /* lookup_confhost()
1907   *
1908   * start DNS lookups of all hostnames in the conf
# Line 2006 | Line 1916 | lookup_confhost(struct ConfItem *conf)
1916  
1917    aconf = map_to_conf(conf);
1918  
1919 <  if (EmptyString(aconf->host) ||
2010 <      EmptyString(aconf->user))
1919 >  if (has_wildcards(aconf->host))
1920    {
1921 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
1921 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
1922           aconf->host, conf->name);
1923      return;
1924    }
1925  
2017 –  if (strchr(aconf->host, '*') ||
2018 –      strchr(aconf->host, '?'))
2019 –    return;
2020 –
1926    /* Do name lookup now on hostnames given and store the
1927     * ip numbers in conf structure.
1928     */
# Line 2029 | Line 1934 | lookup_confhost(struct ConfItem *conf)
1934    /* Get us ready for a bind() and don't bother doing dns lookup */
1935    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1936  
1937 <  if (irc_getaddrinfo(aconf->host, NULL, &hints, &res))
1937 >  if (getaddrinfo(aconf->host, NULL, &hints, &res))
1938    {
1939      conf_dns_lookup(aconf);
1940      return;
# Line 2037 | Line 1942 | lookup_confhost(struct ConfItem *conf)
1942  
1943    assert(res != NULL);
1944  
1945 <  memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
1946 <  aconf->ipnum.ss_len = res->ai_addrlen;
1947 <  aconf->ipnum.ss.ss_family = res->ai_family;
1948 <  irc_freeaddrinfo(res);
1945 >  memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen);
1946 >  aconf->addr.ss_len = res->ai_addrlen;
1947 >  aconf->addr.ss.ss_family = res->ai_family;
1948 >  freeaddrinfo(res);
1949   }
1950  
1951   /* conf_connect_allowed()
# Line 2079 | Line 1984 | conf_connect_allowed(struct irc_ssaddr *
1984   static struct AccessItem *
1985   find_regexp_kline(const char *uhi[])
1986   {
1987 + #ifdef HAVE_LIBPCRE
1988    const dlink_node *ptr = NULL;
1989  
1990    DLINK_FOREACH(ptr, rkconf_items.head)
# Line 2093 | Line 1999 | find_regexp_kline(const char *uhi[])
1999           !ircd_pcre_exec(aptr->regexhost, uhi[2])))
2000        return aptr;
2001    }
2002 <
2002 > #endif
2003    return NULL;
2004   }
2005  
# Line 2116 | Line 2022 | find_kill(struct Client *client_p)
2022  
2023    assert(client_p != NULL);
2024  
2025 <  aconf = find_kline_conf(client_p->host, client_p->username,
2026 <                          &client_p->localClient->ip,
2027 <                          client_p->localClient->aftype);
2025 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2026 >                               CONF_KLINE, client_p->localClient->aftype,
2027 >                               client_p->username, NULL, 1);
2028    if (aconf == NULL)
2029      aconf = find_regexp_kline(uhi);
2030  
2031 <  if (aconf && (aconf->status & CONF_KLINE))
2126 <    return aconf;
2127 <
2128 <  return NULL;
2031 >  return aconf;
2032   }
2033  
2034   struct AccessItem *
# Line 2135 | Line 2038 | find_gline(struct Client *client_p)
2038  
2039    assert(client_p != NULL);
2040  
2041 <  aconf = find_gline_conf(client_p->host, client_p->username,
2042 <                          &client_p->localClient->ip,
2043 <                          client_p->localClient->aftype);
2044 <
2142 <  if (aconf && (aconf->status & CONF_GLINE))
2143 <    return aconf;
2144 <
2145 <  return NULL;
2041 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2042 >                               CONF_GLINE, client_p->localClient->aftype,
2043 >                               client_p->username, NULL, 1);
2044 >  return aconf;
2045   }
2046  
2047   /* add_temp_line()
# Line 2155 | Line 2054 | find_gline(struct Client *client_p)
2054   void
2055   add_temp_line(struct ConfItem *conf)
2056   {
2057 <  struct AccessItem *aconf;
2159 <
2160 <  if (conf->type == DLINE_TYPE)
2161 <  {
2162 <    aconf = map_to_conf(conf);
2163 <    SetConfTemporary(aconf);
2164 <    dlinkAdd(conf, &conf->node, &temporary_dlines);
2165 <    MyFree(aconf->user);
2166 <    aconf->user = NULL;
2167 <    add_conf_by_address(CONF_DLINE, aconf);
2168 <  }
2169 <  else if (conf->type == KLINE_TYPE)
2170 <  {
2171 <    aconf = map_to_conf(conf);
2172 <    SetConfTemporary(aconf);
2173 <    dlinkAdd(conf, &conf->node, &temporary_klines);
2174 <    add_conf_by_address(CONF_KILL, aconf);
2175 <  }
2176 <  else if (conf->type == GLINE_TYPE)
2177 <  {
2178 <    aconf = map_to_conf(conf);
2179 <    SetConfTemporary(aconf);
2180 <    dlinkAdd(conf, &conf->node, &temporary_glines);
2181 <    add_conf_by_address(CONF_GLINE, aconf);
2182 <  }
2183 <  else if (conf->type == XLINE_TYPE)
2057 >  if (conf->type == XLINE_TYPE)
2058    {
2059      conf->flags |= CONF_FLAGS_TEMPORARY;
2060      dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2061    }
2188 –  else if (conf->type == RXLINE_TYPE)
2189 –  {
2190 –    conf->flags |= CONF_FLAGS_TEMPORARY;
2191 –    dlinkAdd(conf, make_dlink_node(), &temporary_rxlines);
2192 –  }
2193 –  else if (conf->type == RKLINE_TYPE)
2194 –  {
2195 –    conf->flags |= CONF_FLAGS_TEMPORARY;
2196 –    dlinkAdd(conf, make_dlink_node(), &temporary_rklines);
2197 –  }
2062    else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2063    {
2064      conf->flags |= CONF_FLAGS_TEMPORARY;
# Line 2212 | Line 2076 | add_temp_line(struct ConfItem *conf)
2076   void
2077   cleanup_tklines(void *notused)
2078   {
2079 <  expire_tklines(&temporary_glines);
2216 <  expire_tklines(&temporary_klines);
2217 <  expire_tklines(&temporary_dlines);
2079 >  hostmask_expire_temporary();
2080    expire_tklines(&temporary_xlines);
2219 –  expire_tklines(&temporary_rxlines);
2220 –  expire_tklines(&temporary_rklines);
2081    expire_tklines(&temporary_resv);
2082   }
2083  
# Line 2235 | Line 2095 | expire_tklines(dlink_list *tklist)
2095    struct ConfItem *conf;
2096    struct MatchItem *xconf;
2097    struct MatchItem *nconf;
2238 –  struct AccessItem *aconf;
2098    struct ResvChannel *cconf;
2099  
2100    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2101    {
2102      conf = ptr->data;
2244 –    if (conf->type == GLINE_TYPE ||
2245 –        conf->type == KLINE_TYPE ||
2246 –        conf->type == DLINE_TYPE)
2247 –    {
2248 –      aconf = (struct AccessItem *)map_to_conf(conf);
2249 –      if (aconf->hold <= CurrentTime)
2250 –      {
2251 –        /* XXX - Do we want GLINE expiry notices?? */
2252 –        /* Alert opers that a TKline expired - Hwy */
2253 –        if (ConfigFileEntry.tkline_expire_notices)
2254 –        {
2255 –          if (aconf->status & CONF_KILL)
2256 –          {
2257 –            sendto_realops_flags(UMODE_ALL, L_ALL,
2258 –                                 "Temporary K-line for [%s@%s] expired",
2259 –                                 (aconf->user) ? aconf->user : "*",
2260 –                                 (aconf->host) ? aconf->host : "*");
2261 –          }
2262 –          else if (conf->type == DLINE_TYPE)
2263 –          {
2264 –            sendto_realops_flags(UMODE_ALL, L_ALL,
2265 –                                 "Temporary D-line for [%s] expired",
2266 –                                 (aconf->host) ? aconf->host : "*");
2267 –          }
2268 –        }
2103  
2104 <        delete_one_address_conf(aconf->host, aconf);
2271 <        dlinkDelete(ptr, tklist);
2272 <      }
2273 <    }
2274 <    else if (conf->type == XLINE_TYPE ||
2275 <             conf->type == RXLINE_TYPE)
2104 >    if (conf->type == XLINE_TYPE)
2105      {
2106        xconf = (struct MatchItem *)map_to_conf(conf);
2107        if (xconf->hold <= CurrentTime)
2108        {
2109          if (ConfigFileEntry.tkline_expire_notices)
2110            sendto_realops_flags(UMODE_ALL, L_ALL,
2111 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2283 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2111 >                               "Temporary X-line for [%s] sexpired", conf->name);
2112          dlinkDelete(ptr, tklist);
2113          free_dlink_node(ptr);
2114          delete_conf_item(conf);
2115        }
2116      }
2289 –    else if (conf->type == RKLINE_TYPE)
2290 –    {
2291 –      aconf = map_to_conf(conf);
2292 –      if (aconf->hold <= CurrentTime)
2293 –      {
2294 –        if (ConfigFileEntry.tkline_expire_notices)
2295 –           sendto_realops_flags(UMODE_ALL, L_ALL,
2296 –                                "Temporary K-line for [%s@%s] (REGEX) expired",
2297 –                                (aconf->user) ? aconf->user : "*",
2298 –                                (aconf->host) ? aconf->host : "*");
2299 –        dlinkDelete(ptr, tklist);
2300 –        free_dlink_node(ptr);
2301 –        delete_conf_item(conf);
2302 –      }
2303 –    }
2117      else if (conf->type == NRESV_TYPE)
2118      {
2119        nconf = (struct MatchItem *)map_to_conf(conf);
# Line 2322 | Line 2135 | expire_tklines(dlink_list *tklist)
2135          if (ConfigFileEntry.tkline_expire_notices)
2136            sendto_realops_flags(UMODE_ALL, L_ALL,
2137                                 "Temporary RESV for [%s] expired", cconf->name);
2138 <        dlinkDelete(ptr, tklist);
2326 <        free_dlink_node(ptr);
2327 <        delete_conf_item(conf);
2138 >        delete_channel_resv(cconf);
2139        }
2140      }
2141    }
# Line 2339 | Line 2150 | expire_tklines(dlink_list *tklist)
2150   static const struct oper_privs
2151   {
2152    const unsigned int oprivs;
2342 –  const unsigned int hidden;
2153    const unsigned char c;
2154   } flag_list[] = {
2155 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2156 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2157 <  { OPER_FLAG_DIE,         0,                       'D' },
2158 <  { OPER_FLAG_GLINE,       0,                       'G' },
2159 <  { OPER_FLAG_REHASH,      0,                       'H' },
2160 <  { OPER_FLAG_K,           0,                       'K' },
2161 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2162 <  { OPER_FLAG_N,           0,                       'N' },
2163 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2164 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2165 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2166 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2167 <  { OPER_FLAG_X,           0,                       'X' },
2168 <  { 0, 0, '\0' }
2155 >  { OPER_FLAG_ADMIN,       'A' },
2156 >  { OPER_FLAG_REMOTEBAN,   'B' },
2157 >  { OPER_FLAG_DIE,         'D' },
2158 >  { OPER_FLAG_GLINE,       'G' },
2159 >  { OPER_FLAG_REHASH,      'H' },
2160 >  { OPER_FLAG_K,           'K' },
2161 >  { OPER_FLAG_OPERWALL,    'L' },
2162 >  { OPER_FLAG_N,           'N' },
2163 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2164 >  { OPER_FLAG_REMOTE,      'R' },
2165 >  { OPER_FLAG_OPER_SPY,    'S' },
2166 >  { OPER_FLAG_UNKLINE,     'U' },
2167 >  { OPER_FLAG_X,           'X' },
2168 >  { 0, '\0' }
2169   };
2170  
2171   char *
# Line 2367 | Line 2177 | oper_privs_as_string(const unsigned int
2177  
2178    for (; flag_list[i].oprivs; ++i)
2179    {
2180 <    if ((port & flag_list[i].oprivs) &&
2371 <        (port & flag_list[i].hidden) == 0)
2180 >    if (port & flag_list[i].oprivs)
2181        *privs_ptr++ = flag_list[i].c;
2182      else
2183        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2385 | Line 2194 | oper_privs_as_string(const unsigned int
2194   *         "oper" is server name for remote opers
2195   * Side effects: None.
2196   */
2197 < char *
2197 > const char *
2198   get_oper_name(const struct Client *client_p)
2199   {
2200 <  dlink_node *cnode;
2392 <  struct ConfItem *conf;
2393 <  struct AccessItem *aconf;
2394 <
2200 >  dlink_node *cnode = NULL;
2201    /* +5 for !,@,{,} and null */
2202 <  static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
2202 >  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2203  
2204    if (MyConnect(client_p))
2205    {
2206 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2206 >    if ((cnode = client_p->localClient->confs.head))
2207      {
2208 <      conf = cnode->data;
2209 <      aconf = map_to_conf(conf);
2208 >      struct ConfItem *conf = cnode->data;
2209 >      const struct AccessItem *aconf = map_to_conf(conf);
2210  
2211        if (IsConfOperator(aconf))
2212        {
2213 <        ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2214 <                   client_p->username, client_p->host,
2409 <                   conf->name);
2213 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2214 >                 client_p->username, client_p->host, conf->name);
2215          return buffer;
2216        }
2217      }
# Line 2417 | Line 2222 | get_oper_name(const struct Client *clien
2222      assert(0); /* Oper without oper conf! */
2223    }
2224  
2225 <  ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2226 <             client_p->username, client_p->host, client_p->servptr->name);
2225 >  snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2226 >           client_p->username, client_p->host, client_p->servptr->name);
2227    return buffer;
2228   }
2229  
# Line 2435 | Line 2240 | read_conf_files(int cold)
2240    char chanmodes[32];
2241    char chanlimit[32];
2242  
2243 +  conf_parser_ctx.boot = cold;
2244    filename = get_conf_name(CONF_TYPE);
2245  
2246    /* We need to know the initial filename for the yyerror() to report
# Line 2445 | Line 2251 | read_conf_files(int cold)
2251    */
2252    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2253  
2254 <  if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
2254 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2255    {
2256      if (cold)
2257      {
2258 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2258 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2259             filename, strerror(errno));
2260        exit(-1);
2261      }
# Line 2465 | Line 2271 | read_conf_files(int cold)
2271    if (!cold)
2272      clear_out_old_conf();
2273  
2274 <  read_conf(conf_fbfile_in);
2275 <  fbclose(conf_fbfile_in);
2274 >  read_conf(conf_parser_ctx.conf_file);
2275 >  fclose(conf_parser_ctx.conf_file);
2276  
2277    add_isupport("NETWORK", ServerInfo.network_name, -1);
2278 <  ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "",
2279 <             ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2278 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%d",
2279 >           ConfigChannel.max_bans);
2280    add_isupport("MAXLIST", chanmodes, -1);
2281    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2282 <  if (ConfigChannel.disable_local_channels)
2283 <    add_isupport("CHANTYPES", "#", -1);
2284 <  else
2285 <    add_isupport("CHANTYPES", "#&", -1);
2286 <  ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&",
2481 <             ConfigChannel.max_chans_per_user);
2282 >
2283 >  add_isupport("CHANTYPES", "#", -1);
2284 >
2285 >  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
2286 >           ConfigChannel.max_chans_per_user);
2287    add_isupport("CHANLIMIT", chanlimit, -1);
2288 <  ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2289 <             ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2288 >  snprintf(chanmodes, sizeof(chanmodes), "%s",
2289 >           "beI,k,l,imnprstORS");
2290    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2291 <  if (ConfigChannel.use_except)
2292 <    add_isupport("EXCEPTS", "e", -1);
2293 <  if (ConfigChannel.use_invex)
2489 <    add_isupport("INVEX", "I", -1);
2291 >
2292 >  add_isupport("EXCEPTS", "e", -1);
2293 >  add_isupport("INVEX", "I", -1);
2294    add_isupport("CHANMODES", chanmodes, -1);
2295  
2296    /*
# Line 2495 | Line 2299 | read_conf_files(int cold)
2299     */
2300    rebuild_isupport_message_line();
2301  
2302 <  parse_conf_file(KLINE_TYPE, cold);
2302 > #ifdef HAVE_LIBPCRE
2303    parse_conf_file(RKLINE_TYPE, cold);
2304 +  parse_conf_file(RXLINE_TYPE, cold);
2305 + #endif
2306 +  parse_conf_file(KLINE_TYPE, cold);
2307    parse_conf_file(DLINE_TYPE, cold);
2308    parse_conf_file(XLINE_TYPE, cold);
2502 –  parse_conf_file(RXLINE_TYPE, cold);
2309    parse_conf_file(NRESV_TYPE, cold);
2310    parse_conf_file(CRESV_TYPE, cold);
2311   }
# Line 2513 | Line 2319 | read_conf_files(int cold)
2319   static void
2320   parse_conf_file(int type, int cold)
2321   {
2322 <  FBFILE *file = NULL;
2322 >  FILE *file = NULL;
2323    const char *filename = get_conf_name(type);
2324  
2325 <  if ((file = fbopen(filename, "r")) == NULL)
2325 >  if ((file = fopen(filename, "r")) == NULL)
2326    {
2327      if (cold)
2328 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2328 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2329             filename, strerror(errno));
2330      else
2331        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2529 | Line 2335 | parse_conf_file(int type, int cold)
2335    else
2336    {
2337      parse_csv_file(file, type);
2338 <    fbclose(file);
2338 >    fclose(file);
2339    }
2340   }
2341  
# Line 2548 | Line 2354 | clear_out_old_conf(void)
2354    struct ClassItem *cltmp;
2355    struct MatchItem *match_item;
2356    dlink_list *free_items [] = {
2357 <    &server_items,   &oconf_items,    &hub_items, &leaf_items,
2357 >    &server_items,   &oconf_items,
2358       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2359 <     &nresv_items, &cluster_items,  &gdeny_items, NULL
2359 >     &nresv_items, &cluster_items,  &service_items, NULL
2360    };
2361  
2362    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2567 | Line 2373 | clear_out_old_conf(void)
2373        /* XXX This is less than pretty */
2374        if (conf->type == SERVER_TYPE)
2375        {
2376 <        aconf = (struct AccessItem *)map_to_conf(conf);
2376 >        aconf = map_to_conf(conf);
2377 >
2378          if (aconf->clients != 0)
2379          {
2380            SetConfIllegal(aconf);
# Line 2580 | Line 2387 | clear_out_old_conf(void)
2387        }
2388        else if (conf->type == OPER_TYPE)
2389        {
2390 <        aconf = (struct AccessItem *)map_to_conf(conf);
2390 >        aconf = map_to_conf(conf);
2391 >
2392          if (aconf->clients != 0)
2393          {
2394            SetConfIllegal(aconf);
# Line 2591 | Line 2399 | clear_out_old_conf(void)
2399            delete_conf_item(conf);
2400          }
2401        }
2594 –      else if (conf->type == CLIENT_TYPE)
2595 –      {
2596 –        aconf = (struct AccessItem *)map_to_conf(conf);
2597 –        if (aconf->clients != 0)
2598 –        {
2599 –          SetConfIllegal(aconf);
2600 –        }
2601 –        else
2602 –        {
2603 –          delete_conf_item(conf);
2604 –        }
2605 –      }
2402        else if (conf->type == XLINE_TYPE  ||
2403                 conf->type == RXLINE_TYPE ||
2404                 conf->type == RKLINE_TYPE)
# Line 2616 | Line 2412 | clear_out_old_conf(void)
2412        }
2413        else
2414        {
2619 –        if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2620 –        {
2621 –          match_item = (struct MatchItem *)map_to_conf(conf);
2622 –          if ((match_item->ref_count <= 0))
2623 –            delete_conf_item(conf);
2624 –          else
2625 –          {
2626 –            match_item->illegal = 1;
2627 –            dlinkDelete(&conf->node, *iterator);
2628 –          }
2629 –        }
2630 –        else
2415            delete_conf_item(conf);
2416        }
2417      }
2418    }
2419  
2420 <  /* don't delete the class table, rather mark all entries
2420 >  /*
2421 >   * don't delete the class table, rather mark all entries
2422     * for deletion. The table is cleaned up by check_class. - avalon
2423     */
2424    DLINK_FOREACH(ptr, class_items.head)
2425    {
2426 <    conf = ptr->data;
2427 <    cltmp = (struct ClassItem *)map_to_conf(conf);
2426 >    cltmp = map_to_conf(ptr->data);
2427 >
2428      if (ptr != class_items.tail)  /* never mark the "default" class */
2429 <      MaxTotal(cltmp) = -1;
2429 >      cltmp->active = 0;
2430    }
2431  
2432    clear_out_address_conf();
2433  
2434    /* clean out module paths */
2650 – #ifndef STATIC_MODULES
2435    mod_clear_paths();
2652 – #endif
2436  
2437    /* clean out ServerInfo */
2438    MyFree(ServerInfo.description);
# Line 2669 | Line 2452 | clear_out_old_conf(void)
2452  
2453    MyFree(ServerInfo.rsa_private_key_file);
2454    ServerInfo.rsa_private_key_file = NULL;
2455 +
2456 +  if (ServerInfo.server_ctx)
2457 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2458 +                                               SSL_OP_NO_SSLv3|
2459 +                                               SSL_OP_NO_TLSv1);
2460 +  if (ServerInfo.client_ctx)
2461 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2462 +                                               SSL_OP_NO_SSLv3|
2463 +                                               SSL_OP_NO_TLSv1);
2464   #endif
2465  
2466    /* clean out old resvs from the conf */
# Line 2691 | Line 2483 | clear_out_old_conf(void)
2483     */
2484  
2485    /* clean out general */
2486 <  MyFree(ConfigFileEntry.servlink_path);
2487 <  ConfigFileEntry.servlink_path = NULL;
2488 < #ifdef HAVE_LIBCRYPTO
2697 <  ConfigFileEntry.default_cipher_preference = NULL;
2698 < #endif /* HAVE_LIBCRYPTO */
2486 >  MyFree(ConfigFileEntry.service_name);
2487 >  ConfigFileEntry.service_name = NULL;
2488 >
2489    delete_isupport("INVEX");
2490    delete_isupport("EXCEPTS");
2491   }
# Line 2756 | Line 2546 | get_conf_name(ConfType type)
2546      case KLINE_TYPE:
2547        return ConfigFileEntry.klinefile;
2548        break;
2759 –    case RKLINE_TYPE:
2760 –      return ConfigFileEntry.rklinefile;
2761 –      break;
2549      case DLINE_TYPE:
2550        return ConfigFileEntry.dlinefile;
2551        break;
2552      case XLINE_TYPE:
2553        return ConfigFileEntry.xlinefile;
2554        break;
2768 –    case RXLINE_TYPE:
2769 –      return ConfigFileEntry.rxlinefile;
2770 –      break;
2555      case CRESV_TYPE:
2556        return ConfigFileEntry.cresvfile;
2557        break;
2558      case NRESV_TYPE:
2559        return ConfigFileEntry.nresvfile;
2560        break;
2777 –    case GLINE_TYPE:
2778 –      return ConfigFileEntry.glinefile;
2779 –      break;
2780 –
2561      default:
2562        return NULL;  /* This should NEVER HAPPEN since we call this function
2563                         only with the above values, this will cause us to core
# Line 2806 | Line 2586 | get_conf_ping(struct ConfItem *conf, int
2586      if (aconf->class_ptr != NULL)
2587      {
2588        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2589 <      *pingwarn = PingWarning(aclass);
2590 <      return PingFreq(aclass);
2589 >      *pingwarn = aclass->ping_warning;
2590 >      return aclass->ping_freq;
2591      }
2592    }
2593  
# Line 2823 | Line 2603 | get_conf_ping(struct ConfItem *conf, int
2603   const char *
2604   get_client_class(struct Client *target_p)
2605   {
2606 <  dlink_node *ptr;
2607 <  struct ConfItem *conf;
2608 <  struct AccessItem *aconf;
2606 >  dlink_node *cnode = NULL;
2607 >  struct AccessItem *aconf = NULL;
2608 >
2609 >  assert(!IsMe(target_p));
2610  
2611 <  if (target_p != NULL && !IsMe(target_p) &&
2831 <      target_p->localClient->confs.head != NULL)
2611 >  if ((cnode = target_p->localClient->confs.head))
2612    {
2613 <    DLINK_FOREACH(ptr, target_p->localClient->confs.head)
2834 <    {
2835 <      conf = ptr->data;
2613 >    struct ConfItem *conf = cnode->data;
2614  
2615 <      if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE ||
2616 <          conf->type == OPER_TYPE)
2617 <      {
2618 <        aconf = (struct AccessItem *) map_to_conf(conf);
2619 <        if (aconf->class_ptr != NULL)
2620 <          return aconf->class_ptr->name;
2843 <      }
2844 <    }
2615 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2616 >          (conf->type == OPER_TYPE));
2617 >
2618 >    aconf = map_to_conf(conf);
2619 >    if (aconf->class_ptr != NULL)
2620 >      return aconf->class_ptr->name;
2621    }
2622  
2623    return "default";
# Line 2857 | Line 2633 | get_client_class(struct Client *target_p
2633   int
2634   get_client_ping(struct Client *target_p, int *pingwarn)
2635   {
2636 <  int ping;
2637 <  struct ConfItem *conf;
2862 <  dlink_node *nlink;
2636 >  int ping = 0;
2637 >  dlink_node *cnode = NULL;
2638  
2639 <  if (target_p->localClient->confs.head != NULL)
2640 <    DLINK_FOREACH(nlink, target_p->localClient->confs.head)
2641 <    {
2867 <      conf = nlink->data;
2639 >  if ((cnode = target_p->localClient->confs.head))
2640 >  {
2641 >    struct ConfItem *conf = cnode->data;
2642  
2643 <      if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2644 <          (conf->type == OPER_TYPE))
2645 <      {
2646 <        ping = get_conf_ping(conf, pingwarn);
2647 <        if (ping > 0)
2648 <          return ping;
2649 <      }
2876 <    }
2643 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2644 >          (conf->type == OPER_TYPE));
2645 >
2646 >    ping = get_conf_ping(conf, pingwarn);
2647 >    if (ping > 0)
2648 >      return ping;
2649 >  }
2650  
2651    *pingwarn = 0;
2652    return DEFAULT_PINGFREQUENCY;
# Line 2890 | Line 2663 | find_class(const char *classname)
2663   {
2664    struct ConfItem *conf;
2665  
2666 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2667 <    return(conf);
2666 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2667 >    return conf;
2668  
2669    return class_default;
2670   }
# Line 2905 | Line 2678 | find_class(const char *classname)
2678   void
2679   check_class(void)
2680   {
2681 <  dlink_node *ptr;
2909 <  dlink_node *next_ptr;
2910 <  struct ConfItem *conf;
2911 <  struct ClassItem *aclass;
2681 >  dlink_node *ptr = NULL, *next_ptr = NULL;
2682  
2683    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)
2684    {
2685 <    conf = ptr->data;
2916 <    aclass = (struct ClassItem *)map_to_conf(conf);
2685 >    struct ClassItem *aclass = map_to_conf(ptr->data);
2686  
2687 <    if (MaxTotal(aclass) < 0)
2687 >    if (!aclass->active && !aclass->curr_user_count)
2688      {
2689        destroy_cidr_class(aclass);
2690 <      if (CurrUserCount(aclass) > 0)
2922 <        dlinkDelete(&conf->node, &class_items);
2923 <      else
2924 <        delete_conf_item(conf);
2690 >      delete_conf_item(ptr->data);
2691      }
2692    }
2693   }
# Line 2938 | Line 2704 | init_class(void)
2704    struct ClassItem *aclass;
2705  
2706    class_default = make_conf_item(CLASS_TYPE);
2707 <  aclass = (struct ClassItem *)map_to_conf(class_default);
2707 >
2708 >  aclass = map_to_conf(class_default);
2709 >  aclass->active = 1;
2710    DupString(class_default->name, "default");
2711 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2712 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2713 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2714 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2711 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2712 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2713 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2714 >  aclass->max_sendq = DEFAULT_SENDQ;
2715 >  aclass->max_recvq = DEFAULT_RECVQ;
2716  
2717    client_check_cb = register_callback("check_client", check_client);
2718   }
# Line 2954 | Line 2723 | init_class(void)
2723   * output       - sendq for this client as found from its class
2724   * side effects - NONE
2725   */
2726 < unsigned long
2726 > unsigned int
2727   get_sendq(struct Client *client_p)
2728   {
2729 <  unsigned long sendq = DEFAULT_SENDQ;
2730 <  dlink_node *ptr;
2962 <  struct ConfItem *conf;
2729 >  unsigned int sendq = DEFAULT_SENDQ;
2730 >  dlink_node *cnode;
2731    struct ConfItem *class_conf;
2732    struct ClassItem *aclass;
2733    struct AccessItem *aconf;
2734  
2735 <  if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
2735 >  assert(!IsMe(client_p));
2736 >
2737 >  if ((cnode = client_p->localClient->confs.head))
2738    {
2739 <    DLINK_FOREACH(ptr, client_p->localClient->confs.head)
2740 <    {
2741 <      conf = ptr->data;
2742 <      if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE)
2743 <          || (conf->type == CLIENT_TYPE))
2744 <      {
2745 <        aconf = (struct AccessItem *)map_to_conf(conf);
2746 <        if ((class_conf = aconf->class_ptr) == NULL)
2747 <          continue;
2748 <        aclass = (struct ClassItem *)map_to_conf(class_conf);
2749 <        sendq = MaxSendq(aclass);
2750 <        return sendq;
2751 <      }
2982 <    }
2739 >    struct ConfItem *conf = cnode->data;
2740 >
2741 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2742 >          (conf->type == OPER_TYPE));
2743 >
2744 >    aconf = map_to_conf(conf);
2745 >
2746 >    if ((class_conf = aconf->class_ptr) == NULL)
2747 >      return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */
2748 >
2749 >    aclass = map_to_conf(class_conf);
2750 >    sendq = aclass->max_sendq;
2751 >    return sendq;
2752    }
2753 +
2754    /* XXX return a default?
2755     * if here, then there wasn't an attached conf with a sendq
2756     * that is very bad -Dianora
# Line 2988 | Line 2758 | get_sendq(struct Client *client_p)
2758    return DEFAULT_SENDQ;
2759   }
2760  
2761 + unsigned int
2762 + get_recvq(struct Client *client_p)
2763 + {
2764 +  unsigned int recvq = DEFAULT_RECVQ;
2765 +  dlink_node *cnode;
2766 +  struct ConfItem *class_conf;
2767 +  struct ClassItem *aclass;
2768 +  struct AccessItem *aconf;
2769 +
2770 +  assert(!IsMe(client_p));
2771 +
2772 +  if ((cnode = client_p->localClient->confs.head))
2773 +  {
2774 +    struct ConfItem *conf = cnode->data;
2775 +
2776 +    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2777 +          (conf->type == OPER_TYPE));
2778 +
2779 +    aconf = map_to_conf(conf);
2780 +
2781 +    if ((class_conf = aconf->class_ptr) == NULL)
2782 +      return DEFAULT_RECVQ; /* TBV: shouldn't be possible at all */
2783 +
2784 +    aclass = map_to_conf(class_conf);
2785 +    recvq = aclass->max_recvq;
2786 +    return recvq;
2787 +  }
2788 +
2789 +  /* XXX return a default?
2790 +   * if here, then there wasn't an attached conf with a recvq
2791 +   * that is very bad -Dianora
2792 +   */
2793 +  return DEFAULT_RECVQ;
2794 + }
2795 +
2796   /* conf_add_class_to_conf()
2797   *
2798   * inputs       - pointer to config item
# Line 2997 | Line 2802 | get_sendq(struct Client *client_p)
2802   void
2803   conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)
2804   {
2805 <  struct AccessItem *aconf;
2806 <  struct ClassItem *aclass;
3002 <
3003 <  aconf = (struct AccessItem *)map_to_conf(conf);
2805 >  struct AccessItem *aconf = map_to_conf(conf);
2806 >  struct ClassItem *class = NULL;
2807  
2808    if (class_name == NULL)
2809    {
2810      aconf->class_ptr = class_default;
2811 +
2812      if (conf->type == CLIENT_TYPE)
2813        sendto_realops_flags(UMODE_ALL, L_ALL,
2814                             "Warning *** Defaulting to default class for %s@%s",
# Line 3015 | Line 2819 | conf_add_class_to_conf(struct ConfItem *
2819                             conf->name);
2820    }
2821    else
3018 –  {
2822      aconf->class_ptr = find_class(class_name);
3020 –  }
2823  
2824 <  if (aconf->class_ptr == NULL)
2824 >  if (aconf->class_ptr)
2825 >    class = map_to_conf(aconf->class_ptr);
2826 >
2827 >  if (aconf->class_ptr == NULL || !class->active)
2828    {
2829      if (conf->type == CLIENT_TYPE)
2830        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 3031 | Line 2836 | conf_add_class_to_conf(struct ConfItem *
2836                             conf->name);
2837      aconf->class_ptr = class_default;
2838    }
3034 –  else
3035 –  {
3036 –    aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
3037 –    if (MaxTotal(aclass) < 0)
3038 –    {
3039 –      aconf->class_ptr = class_default;
3040 –    }
3041 –  }
2839   }
2840  
3044 – #define MAXCONFLINKS 150
3045 –
2841   /* conf_add_server()
2842   *
2843   * inputs       - pointer to config item
# Line 3051 | Line 2846 | conf_add_class_to_conf(struct ConfItem *
2846   * side effects - Add a connect block
2847   */
2848   int
2849 < conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name)
2849 > conf_add_server(struct ConfItem *conf, const char *class_name)
2850   {
2851 <  struct AccessItem *aconf;
3057 <  char *orig_host;
3058 <
3059 <  aconf = map_to_conf(conf);
2851 >  struct AccessItem *aconf = map_to_conf(conf);
2852  
2853    conf_add_class_to_conf(conf, class_name);
2854  
2855 <  if (lcount > MAXCONFLINKS || !aconf->host || !conf->name)
2855 >  if (!aconf->host || !conf->name)
2856    {
2857      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2858 <    ilog(L_WARN, "Bad connect block");
2858 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2859      return -1;
2860    }
2861  
2862 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2862 >  if (EmptyString(aconf->passwd))
2863    {
2864      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2865                           conf->name);
2866 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2866 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2867      return -1;
2868    }
2869  
3078 –  orig_host = aconf->host;
3079 –  split_nuh(orig_host, NULL, &aconf->user, &aconf->host);
3080 –  MyFree(orig_host);
2870    lookup_confhost(conf);
2871  
2872    return 0;
2873   }
2874  
3086 – /* conf_add_d_conf()
3087 – *
3088 – * inputs       - pointer to config item
3089 – * output       - NONE
3090 – * side effects - Add a d/D line
3091 – */
3092 – void
3093 – conf_add_d_conf(struct AccessItem *aconf)
3094 – {
3095 –  if (aconf->host == NULL)
3096 –    return;
3097 –
3098 –  aconf->user = NULL;
3099 –
3100 –  /* XXX - Should 'd' ever be in the old conf? For new conf we don't
3101 –   *       need this anyway, so I will disable it for now... -A1kmm
3102 –   */
3103 –  if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST)
3104 –  {
3105 –    ilog(L_WARN, "Invalid Dline %s ignored", aconf->host);
3106 –    free_access_item(aconf);
3107 –  }
3108 –  else
3109 –  {
3110 –    /* XXX ensure user is NULL */
3111 –    MyFree(aconf->user);
3112 –    aconf->user = NULL;
3113 –    add_conf_by_address(CONF_DLINE, aconf);
3114 –  }
3115 – }
3116 –
2875   /* yyerror()
2876   *
2877   * inputs       - message from parser
# Line 3125 | Line 2883 | yyerror(const char *msg)
2883   {
2884    char newlinebuf[IRCD_BUFSIZE];
2885  
2886 <  if (ypass != 1)
2886 >  if (conf_parser_ctx.pass != 1)
2887      return;
2888  
2889    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2890    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2891                         conffilebuf, lineno + 1, msg, newlinebuf);
2892 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2892 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2893         conffilebuf, lineno + 1, msg, newlinebuf);
2894   }
2895  
3138 – int
3139 – conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb)
3140 – {
3141 –  if (fbgets(lbuf, max_size, fb) == NULL)
3142 –    return 0;
3143 –
3144 –  return strlen(lbuf);
3145 – }
3146 –
3147 – int
3148 – conf_yy_fatal_error(const char *msg)
3149 – {
3150 –  return 0;
3151 – }
3152 –
2896   /*
2897   * valid_tkline()
2898   *
# Line 3161 | Line 2904 | conf_yy_fatal_error(const char *msg)
2904   * Originally written by Dianora (Diane, db@db.net)
2905   */
2906   time_t
2907 < valid_tkline(char *p, int minutes)
2907 > valid_tkline(const char *p, int minutes)
2908   {
2909    time_t result = 0;
2910  
2911 <  while (*p)
2911 >  for (; *p; ++p)
2912    {
2913 <    if (IsDigit(*p))
3171 <    {
3172 <      result *= 10;
3173 <      result += ((*p) & 0xF);
3174 <      p++;
3175 <    }
3176 <    else
2913 >    if (!IsDigit(*p))
2914        return 0;
2915 +
2916 +    result *= 10;
2917 +    result += ((*p) & 0xF);
2918    }
2919  
2920 <  /* in the degenerate case where oper does a /quote kline 0 user@host :reason
2920 >  /*
2921 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
2922     * i.e. they specifically use 0, I am going to return 1 instead
2923     * as a return value of non-zero is used to flag it as a temporary kline
2924     */
3184 –
2925    if (result == 0)
2926      result = 1;
2927  
# Line 3282 | Line 3022 | valid_wild_card(struct Client *source_p,
3022   *                if target_server is NULL and an "ON" is found error
3023   *                is reported.
3024   *                if reason pointer is NULL ignore pointer,
3025 < *                this allows usee of parse_a_line in unkline etc.
3025 > *                this allows use of parse_a_line in unkline etc.
3026   *
3027   * - Dianora
3028   */
# Line 3352 | Line 3092 | parse_aline(const char *cmd, struct Clie
3092          return -1;
3093        }
3094  
3095 <      if (!IsOperRemoteBan(source_p))
3095 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3096        {
3097          sendto_one(source_p, form_str(ERR_NOPRIVS),
3098                     me.name, source_p->name, "remoteban");
# Line 3389 | Line 3129 | parse_aline(const char *cmd, struct Clie
3129        return -1;
3130      }
3131  
3132 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3132 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3133        return -1;
3134    }
3135    else
3136 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3136 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3137        return -1;
3138  
3139    if (reason != NULL)
3140    {
3141 <    if (parc != 0)
3141 >    if (parc != 0 && !EmptyString(*parv))
3142      {
3143        *reason = *parv;
3144 <      if (!valid_comment(source_p, *reason, YES))
3144 >      if (!valid_comment(source_p, *reason, 1))
3145          return -1;
3146      }
3147      else
# Line 3437 | Line 3177 | find_user_host(struct Client *source_p,
3177    {
3178      /* Explicit user@host mask given */
3179  
3180 <    if(hostp != NULL)                            /* I'm a little user@host */
3180 >    if (hostp != NULL)                            /* I'm a little user@host */
3181      {
3182        *(hostp++) = '\0';                       /* short and squat */
3183        if (*user_host_or_nick)
# Line 3458 | Line 3198 | find_user_host(struct Client *source_p,
3198      
3199      return 1;
3200    }
3201 <  else if (!(flags & NOUSERLOOKUP))
3201 >  else
3202    {
3203      /* Try to find user@host mask from nick */
3204      /* Okay to use source_p as the first param, because source_p == client_p */
# Line 3532 | Line 3272 | match_conf_password(const char *password
3272   {
3273    const char *encr = NULL;
3274  
3275 <  if (password == NULL || aconf->passwd == NULL)
3275 >  if (EmptyString(password) || EmptyString(aconf->passwd))
3276      return 0;
3277  
3278    if (aconf->flags & CONF_FLAGS_ENCRYPTED)
3279 <  {
3540 <    /* use first two chars of the password they send in as salt */
3541 <    /* If the password in the conf is MD5, and ircd is linked
3542 <     * to scrypt on FreeBSD, or the standard crypt library on
3543 <     * glibc Linux, then this code will work fine on generating
3544 <     * the proper encrypted hash for comparison.
3545 <     */
3546 <    if (*aconf->passwd)
3547 <      encr = crypt(password, aconf->passwd);
3548 <    else
3549 <      encr = "";
3550 <  }
3279 >    encr = crypt(password, aconf->passwd);
3280    else
3281      encr = password;
3282  
# Line 3560 | Line 3289 | match_conf_password(const char *password
3289   * inputs       - client sending the cluster
3290   *              - command name "KLINE" "XLINE" etc.
3291   *              - capab -- CAP_KLN etc. from s_serv.h
3292 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3292 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3293   *              - pattern and args to send along
3294   * output       - none
3295   * side effects - Take source_p send the pattern with args given
# Line 3568 | Line 3297 | match_conf_password(const char *password
3297   */
3298   void
3299   cluster_a_line(struct Client *source_p, const char *command,
3300 <               int capab, int cluster_type, const char *pattern, ...)
3300 >               int capab, int cluster_type, const char *pattern, ...)
3301   {
3302    va_list args;
3303    char buffer[IRCD_BUFSIZE];
3304 <  struct ConfItem *conf;
3576 <  dlink_node *ptr;
3304 >  const dlink_node *ptr = NULL;
3305  
3306    va_start(args, pattern);
3307    vsnprintf(buffer, sizeof(buffer), pattern, args);
# Line 3581 | Line 3309 | cluster_a_line(struct Client *source_p,
3309  
3310    DLINK_FOREACH(ptr, cluster_items.head)
3311    {
3312 <    conf = ptr->data;
3312 >    const struct ConfItem *conf = ptr->data;
3313  
3314      if (conf->flags & cluster_type)
3587 –    {
3315        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
3316                           "%s %s %s", command, conf->name, buffer);
3590 –    }
3317    }
3318   }
3319  
# Line 3619 | Line 3345 | cluster_a_line(struct Client *source_p,
3345   * @                            *       *       *
3346   * !                            *       *       *
3347   */
3622 –
3348   void
3349 < split_nuh(char *mask, char **nick, char **user, char **host)
3349 > split_nuh(struct split_nuh_item *const iptr)
3350   {
3351    char *p = NULL, *q = NULL;
3352  
3353 <  if ((p = strchr(mask, '!')) != NULL)
3353 >  if (iptr->nickptr)
3354 >    strlcpy(iptr->nickptr, "*", iptr->nicksize);
3355 >  if (iptr->userptr)
3356 >    strlcpy(iptr->userptr, "*", iptr->usersize);
3357 >  if (iptr->hostptr)
3358 >    strlcpy(iptr->hostptr, "*", iptr->hostsize);
3359 >
3360 >  if ((p = strchr(iptr->nuhmask, '!')))
3361    {
3362      *p = '\0';
3631 –    if (nick != NULL)
3632 –    {
3633 –      if (*mask != '\0')
3634 –        *nick = xstrldup(mask, NICKLEN);
3635 –      else
3636 –        DupString(*nick, "*");
3637 –    }
3363  
3364 <    if ((q = strchr(++p, '@')) != NULL)
3365 <    {
3366 <      *q = '\0';
3364 >    if (iptr->nickptr && *iptr->nuhmask != '\0')
3365 >      strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3366 >
3367 >    if ((q = strchr(++p, '@'))) {
3368 >      *q++ = '\0';
3369  
3370        if (*p != '\0')
3371 <        *user = xstrldup(p, USERLEN+1);
3645 <      else
3646 <        DupString(*user, "*");
3371 >        strlcpy(iptr->userptr, p, iptr->usersize);
3372  
3373 <      if (*++q != '\0')
3374 <        *host = xstrldup(q, HOSTLEN+1);
3650 <      else
3651 <        DupString(*host, "*");
3373 >      if (*q != '\0')
3374 >        strlcpy(iptr->hostptr, q, iptr->hostsize);
3375      }
3376      else
3377      {
3378        if (*p != '\0')
3379 <        *user = xstrldup(p, USERLEN+1);
3657 <      else
3658 <        DupString(*user, "*");
3659 <
3660 <      DupString(*host, "*");
3379 >        strlcpy(iptr->userptr, p, iptr->usersize);
3380      }
3381    }
3382 <  else  /* No ! found so lets look for a user@host */
3382 >  else
3383    {
3384 <    if ((p = strchr(mask, '@')) != NULL)        /* if found a @ */
3384 >    /* No ! found so lets look for a user@host */
3385 >    if ((p = strchr(iptr->nuhmask, '@')))
3386      {
3387 <      if (nick != NULL)
3388 <        DupString(*nick, "*");
3669 <      *p = '\0';
3387 >      /* if found a @ */
3388 >      *p++ = '\0';
3389  
3390 <      if (*mask != '\0')
3391 <        *user = xstrldup(mask, USERLEN+1);
3673 <      else
3674 <        DupString(*user, "*");
3390 >      if (*iptr->nuhmask != '\0')
3391 >        strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
3392  
3393 <      if (*++p != '\0')
3394 <        *host = xstrldup(p, HOSTLEN+1);
3678 <      else
3679 <        DupString(*host, "*");
3393 >      if (*p != '\0')
3394 >        strlcpy(iptr->hostptr, p, iptr->hostsize);
3395      }
3396 <    else                                        /* no @ found */
3396 >    else
3397      {
3398 <      if (nick != NULL)
3399 <      {
3400 <        if (strpbrk(mask, ".:"))
3686 <        {
3687 <          DupString(*nick, "*");
3688 <          *host = xstrldup(mask, HOSTLEN+1);
3689 <        }
3690 <        else
3691 <        {
3692 <          *nick = xstrldup(mask, NICKLEN);
3693 <          DupString(*host, "*");
3694 <        }
3695 <
3696 <        DupString(*user, "*");
3697 <      }
3398 >      /* no @ found */
3399 >      if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
3400 >        strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
3401        else
3402 <      {
3700 <        DupString(*user, "*");
3701 <        *host = xstrldup(mask, HOSTLEN+1);
3702 <      }
3402 >        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3403      }
3404    }
3405   }
# Line 3726 | Line 3426 | flags_to_ascii(unsigned int flags, const
3426    {
3427      if (flags & mask)
3428        *p++ = bit_table[i];
3429 <    else if(lowerit)
3429 >    else if (lowerit)
3430        *p++ = ToLower(bit_table[i]);
3431    }
3432    *p = '\0';
# Line 3749 | Line 3449 | cidr_limit_reached(int over_rule,
3449    dlink_node *ptr = NULL;
3450    struct CidrItem *cidr;
3451  
3452 <  if (NumberPerCidr(aclass) <= 0)
3452 >  if (aclass->number_per_cidr <= 0)
3453      return 0;
3454  
3455    if (ip->ss.ss_family == AF_INET)
3456    {
3457 <    if (CidrBitlenIPV4(aclass) <= 0)
3457 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3458        return 0;
3459  
3460      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3461      {
3462        cidr = ptr->data;
3463 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3463 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3464        {
3465 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3465 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3466            return -1;
3467          cidr->number_on_this_cidr++;
3468          return 0;
# Line 3771 | Line 3471 | cidr_limit_reached(int over_rule,
3471      cidr = MyMalloc(sizeof(struct CidrItem));
3472      cidr->number_on_this_cidr = 1;
3473      cidr->mask = *ip;
3474 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3474 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3475      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3476    }
3477   #ifdef IPV6
3478 <  else if (CidrBitlenIPV6(aclass) > 0)
3478 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3479    {
3480      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3481      {
3482        cidr = ptr->data;
3483 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3483 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3484        {
3485 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3485 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3486            return -1;
3487          cidr->number_on_this_cidr++;
3488          return 0;
# Line 3791 | Line 3491 | cidr_limit_reached(int over_rule,
3491      cidr = MyMalloc(sizeof(struct CidrItem));
3492      cidr->number_on_this_cidr = 1;
3493      cidr->mask = *ip;
3494 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3494 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3495      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3496    }
3497   #endif
# Line 3813 | Line 3513 | remove_from_cidr_check(struct irc_ssaddr
3513    dlink_node *next_ptr = NULL;
3514    struct CidrItem *cidr;
3515  
3516 <  if (NumberPerCidr(aclass) == 0)
3516 >  if (aclass->number_per_cidr == 0)
3517      return;
3518  
3519    if (ip->ss.ss_family == AF_INET)
3520    {
3521 <    if (CidrBitlenIPV4(aclass) <= 0)
3521 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3522        return;
3523  
3524      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3525      {
3526        cidr = ptr->data;
3527 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3527 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3528        {
3529          cidr->number_on_this_cidr--;
3530          if (cidr->number_on_this_cidr == 0)
# Line 3837 | Line 3537 | remove_from_cidr_check(struct irc_ssaddr
3537      }
3538    }
3539   #ifdef IPV6
3540 <  else if (CidrBitlenIPV6(aclass) > 0)
3540 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3541    {
3542      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3543      {
3544        cidr = ptr->data;
3545 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3545 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3546        {
3547          cidr->number_on_this_cidr--;
3548          if (cidr->number_on_this_cidr == 0)
# Line 3905 | Line 3605 | rebuild_cidr_class(struct ConfItem *conf
3605   {
3606    struct ClassItem *old_class = map_to_conf(conf);
3607  
3608 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3608 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3609    {
3610 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3610 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3611        rebuild_cidr_list(AF_INET, conf, new_class,
3612                          &old_class->list_ipv4, &new_class->list_ipv4,
3613 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3613 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3614  
3615   #ifdef IPV6
3616 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3616 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3617        rebuild_cidr_list(AF_INET6, conf, new_class,
3618                          &old_class->list_ipv6, &new_class->list_ipv6,
3619 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3619 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3620   #endif
3621    }
3622  
# Line 3933 | Line 3633 | rebuild_cidr_class(struct ConfItem *conf
3633   static void
3634   destroy_cidr_list(dlink_list *list)
3635   {
3636 <  dlink_node *ptr = NULL;
3937 <  dlink_node *next_ptr = NULL;
3938 <  struct CidrItem *cidr;
3636 >  dlink_node *ptr = NULL, *next_ptr = NULL;
3637  
3638    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
3639    {
3942 –    cidr = ptr->data;
3640      dlinkDelete(ptr, list);
3641 <    MyFree(cidr);
3641 >    MyFree(ptr->data);
3642    }
3643   }
3644  

Diff Legend

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