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/src/s_conf.c (file contents), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid-8/src/conf.c (file contents), Revision 1390 by michael, Tue May 1 13:39:18 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 74 | Line 68 | dlink_list nresv_items   = { NULL, NULL,
68   dlink_list class_items   = { NULL, NULL, 0 };
69   dlink_list gdeny_items   = { NULL, NULL, 0 };
70  
77 – dlink_list temporary_klines  = { NULL, NULL, 0 };
78 – dlink_list temporary_dlines  = { NULL, NULL, 0 };
71   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 };
72   dlink_list temporary_resv = { NULL, NULL, 0 };
73  
74   extern unsigned int lineno;
75   extern char linebuf[];
76   extern char conffilebuf[IRCD_BUFSIZE];
88 – extern char yytext[];
77   extern int yyparse(); /* defined in y.tab.c */
78 < unsigned int scount = 0; /* used by yyparse(), etc */
79 < int ypass  = 1; /* used by yyparse()      */
78 >
79 > struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
80  
81   /* internally defined functions */
82 < 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 *);
82 > static void read_conf(FILE *);
83   static void clear_out_old_conf(void);
84   static void flush_deleted_I_P(void);
85   static void expire_tklines(dlink_list *);
# Line 117 | Line 102 | static void destroy_cidr_class(struct Cl
102  
103   static void flags_to_ascii(unsigned int, const unsigned int[], char *, int);
104  
120 – FBFILE *conf_fbfile_in = NULL;
121 –
105   /* address of default class conf */
106   static struct ConfItem *class_default;
107  
# Line 141 | Line 124 | static BlockHeap *ip_entry_heap = NULL;
124   static int ip_entries_count = 0;
125  
126  
127 < inline void *
127 > void *
128   map_to_conf(struct ConfItem *aconf)
129   {
130    void *conf;
131 <  conf = (void *)((unsigned long)aconf +
132 <                  (unsigned long)sizeof(struct ConfItem));
131 >  conf = (void *)((uintptr_t)aconf +
132 >                  (uintptr_t)sizeof(struct ConfItem));
133    return(conf);
134   }
135  
136 < inline struct ConfItem *
136 > struct ConfItem *
137   unmap_conf_item(void *aconf)
138   {
139    struct ConfItem *conf;
140  
141 <  conf = (struct ConfItem *)((unsigned long)aconf -
142 <                             (unsigned long)sizeof(struct ConfItem));
141 >  conf = (struct ConfItem *)((uintptr_t)aconf -
142 >                             (uintptr_t)sizeof(struct ConfItem));
143    return(conf);
144   }
145  
# Line 171 | Line 154 | unmap_conf_item(void *aconf)
154   * if successful save hp in the conf item it was called with
155   */
156   static void
157 < conf_dns_callback(void *vptr, struct DNSReply *reply)
157 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
158   {
159 <  struct AccessItem *aconf = (struct AccessItem *)vptr;
177 <  struct ConfItem *conf;
159 >  struct AccessItem *aconf = vptr;
160  
161 <  MyFree(aconf->dns_query);
180 <  aconf->dns_query = NULL;
161 >  aconf->dns_pending = 0;
162  
163 <  if (reply != NULL)
164 <    memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr));
165 <  else {
166 <    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 <  }
163 >  if (addr != NULL)
164 >    memcpy(&aconf->addr, addr, sizeof(aconf->addr));
165 >  else
166 >    aconf->dns_failed = 1;
167   }
168  
169   /* conf_dns_lookup()
# Line 201 | Line 175 | conf_dns_callback(void *vptr, struct DNS
175   static void
176   conf_dns_lookup(struct AccessItem *aconf)
177   {
178 <  if (aconf->dns_query == NULL)
178 >  if (!aconf->dns_pending)
179    {
180 <    aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
181 <    aconf->dns_query->ptr = aconf;
208 <    aconf->dns_query->callback = conf_dns_callback;
209 <    gethost_byname(aconf->host, aconf->dns_query);
180 >    aconf->dns_pending = 1;
181 >    gethost_byname(conf_dns_callback, aconf, aconf->host);
182    }
183   }
184  
# Line 277 | Line 249 | make_conf_item(ConfType type)
249      aconf->status = status;
250      break;
251  
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 –
252    case ULINE_TYPE:
253      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
254                                         sizeof(struct MatchItem));
# Line 298 | Line 258 | make_conf_item(ConfType type)
258    case GDENY_TYPE:
259      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
260                                         sizeof(struct AccessItem));
261 <    dlinkAddTail(conf, &conf->node, &gdeny_items);
261 >    dlinkAdd(conf, &conf->node, &gdeny_items);
262      break;
263  
264    case XLINE_TYPE:
# Line 306 | Line 266 | make_conf_item(ConfType type)
266                                         sizeof(struct MatchItem));
267      dlinkAdd(conf, &conf->node, &xconf_items);
268      break;
269 <
269 > #ifdef HAVE_LIBPCRE
270    case RXLINE_TYPE:
271      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
272                                         sizeof(struct MatchItem));
# Line 320 | Line 280 | make_conf_item(ConfType type)
280      aconf->status = CONF_KLINE;
281      dlinkAdd(conf, &conf->node, &rkconf_items);
282      break;
283 <
283 > #endif
284    case CLUSTER_TYPE:
285      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem));
286      dlinkAdd(conf, &conf->node, &cluster_items);
# Line 337 | Line 297 | make_conf_item(ConfType type)
297      dlinkAdd(conf, &conf->node, &nresv_items);
298      break;
299  
300 +  case SERVICE_TYPE:
301 +    status = CONF_SERVICE;
302 +    conf = MyMalloc(sizeof(struct ConfItem));
303 +    dlinkAdd(conf, &conf->node, &service_items);
304 +    break;
305 +
306    case CLASS_TYPE:
307 <    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
308 <                                       sizeof(struct ClassItem));
307 >    conf = MyMalloc(sizeof(struct ConfItem) +
308 >                           sizeof(struct ClassItem));
309      dlinkAdd(conf, &conf->node, &class_items);
310 <    aclass = (struct ClassItem *)map_to_conf(conf);
311 <    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
312 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
313 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
314 <    MaxSendq(aclass) = DEFAULT_SENDQ;
315 <    CurrUserCount(aclass) = 0;
310 >
311 >    aclass = map_to_conf(conf);
312 >    aclass->active = 1;
313 >    aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
314 >    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
315 >    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
316 >    aclass->max_sendq = DEFAULT_SENDQ;
317 >
318      break;
319  
320    default:
# Line 357 | Line 325 | make_conf_item(ConfType type)
325    /* XXX Yes, this will core if default is hit. I want it to for now - db */
326    conf->type = type;
327  
328 <  return(conf);
328 >  return conf;
329   }
330  
331   void
332   delete_conf_item(struct ConfItem *conf)
333   {
334 +  dlink_node *m = NULL, *m_next = NULL;
335    struct MatchItem *match_item;
336    struct AccessItem *aconf;
337    ConfType type = conf->type;
# Line 381 | Line 350 | delete_conf_item(struct ConfItem *conf)
350    case SERVER_TYPE:
351      aconf = map_to_conf(conf);
352  
353 <    if (aconf->dns_query != NULL)
354 <    {
386 <      delete_resolver_queries(aconf->dns_query);
387 <      MyFree(aconf->dns_query);
388 <    }
353 >    if (aconf->dns_pending)
354 >      delete_resolver_queries(aconf);
355      if (aconf->passwd != NULL)
356        memset(aconf->passwd, 0, strlen(aconf->passwd));
357      if (aconf->spasswd != NULL)
# Line 398 | Line 364 | delete_conf_item(struct ConfItem *conf)
364      MyFree(aconf->oper_reason);
365      MyFree(aconf->user);
366      MyFree(aconf->host);
367 <    MyFree(aconf->fakename);
367 >    MyFree(aconf->cipher_list);
368   #ifdef HAVE_LIBCRYPTO
369      if (aconf->rsa_public_key)
370        RSA_free(aconf->rsa_public_key);
# Line 425 | Line 391 | delete_conf_item(struct ConfItem *conf)
391  
392      case SERVER_TYPE:
393        aconf = map_to_conf(conf);
394 +
395 +      DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head)
396 +      {
397 +        MyFree(m->data);
398 +        free_dlink_node(m);
399 +      }
400 +
401 +      DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head)
402 +      {
403 +        MyFree(m->data);
404 +        free_dlink_node(m);  
405 +      }
406 +
407        if (!IsConfIllegal(aconf))
408          dlinkDelete(&conf->node, &server_items);
409        MyFree(conf);
# Line 435 | Line 414 | delete_conf_item(struct ConfItem *conf)
414      }
415      break;
416  
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 –
417    case ULINE_TYPE:
418      match_item = map_to_conf(conf);
419      MyFree(match_item->user);
# Line 478 | Line 433 | delete_conf_item(struct ConfItem *conf)
433      dlinkDelete(&conf->node, &xconf_items);
434      MyFree(conf);
435      break;
436 <
436 > #ifdef HAVE_LIBPCRE
437    case RKLINE_TYPE:
438      aconf = map_to_conf(conf);
439      MyFree(aconf->regexuser);
# Line 501 | Line 456 | delete_conf_item(struct ConfItem *conf)
456      dlinkDelete(&conf->node, &rxconf_items);
457      MyFree(conf);
458      break;
459 <
459 > #endif
460    case NRESV_TYPE:
461      match_item = map_to_conf(conf);
462      MyFree(match_item->user);
# Line 509 | Line 464 | delete_conf_item(struct ConfItem *conf)
464      MyFree(match_item->reason);
465      MyFree(match_item->oper_reason);
466      dlinkDelete(&conf->node, &nresv_items);
467 +
468 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
469 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
470 +        free_dlink_node(m);
471 +
472      MyFree(conf);
473      break;
474  
# Line 526 | Line 486 | delete_conf_item(struct ConfItem *conf)
486      break;
487  
488    case CRESV_TYPE:
489 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
490 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
491 +        free_dlink_node(m);
492 +
493      MyFree(conf);
494      break;
495  
# Line 534 | Line 498 | delete_conf_item(struct ConfItem *conf)
498      MyFree(conf);
499      break;
500  
501 +  case SERVICE_TYPE:
502 +    dlinkDelete(&conf->node, &service_items);
503 +    MyFree(conf);
504 +    break;
505 +
506    default:
507      break;
508    }
# Line 567 | Line 536 | static const unsigned int shared_bit_tab
536   * side effects -
537   */
538   void
539 < report_confitem_types(struct Client *source_p, ConfType type, int temp)
539 > report_confitem_types(struct Client *source_p, ConfType type)
540   {
541 <  dlink_node *ptr = NULL;
541 >  dlink_node *ptr = NULL, *dptr = NULL;
542    struct ConfItem *conf = NULL;
543    struct AccessItem *aconf = NULL;
544    struct MatchItem *matchitem = NULL;
# Line 618 | Line 587 | report_confitem_types(struct Client *sou
587      }
588      break;
589  
590 + #ifdef HAVE_LIBPCRE
591    case RXLINE_TYPE:
592      DLINK_FOREACH(ptr, rxconf_items.head)
593      {
# Line 626 | Line 596 | report_confitem_types(struct Client *sou
596  
597        sendto_one(source_p, form_str(RPL_STATSXLINE),
598                   me.name, source_p->name,
599 <                 matchitem->hold ? "xR": "XR", matchitem->count,
599 >                 "XR", matchitem->count,
600                   conf->name, matchitem->reason);
601      }
602      break;
603  
604    case RKLINE_TYPE:
635 –    p = temp ? "Rk" : "RK";
636 –
605      DLINK_FOREACH(ptr, rkconf_items.head)
606      {
607        aconf = map_to_conf((conf = ptr->data));
608  
641 –      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
642 –        continue;
643 –
609        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
610 <                 source_p->name, p, aconf->host, aconf->user,
610 >                 source_p->name, "KR", aconf->host, aconf->user,
611                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
612      }
613      break;
614 + #endif
615  
616    case ULINE_TYPE:
617      DLINK_FOREACH(ptr, uconf_items.head)
# Line 690 | Line 656 | report_confitem_types(struct Client *sou
656        aconf = map_to_conf(conf);
657  
658        /* Don't allow non opers to see oper privs */
659 <      if (IsOper(source_p))
659 >      if (HasUMode(source_p, UMODE_OPER))
660          sendto_one(source_p, form_str(RPL_STATSOLINE),
661                     me.name, source_p->name, 'O', aconf->user, aconf->host,
662                     conf->name, oper_privs_as_string(aconf->port),
# Line 710 | Line 676 | report_confitem_types(struct Client *sou
676        classitem = map_to_conf(conf);
677        sendto_one(source_p, form_str(RPL_STATSYLINE),
678                   me.name, source_p->name, 'Y',
679 <                 conf->name, PingFreq(classitem),
680 <                 ConFreq(classitem),
681 <                 MaxTotal(classitem), MaxSendq(classitem));
679 >                 conf->name, classitem->ping_freq,
680 >                 classitem->con_freq,
681 >                 classitem->max_total, classitem->max_sendq,
682 >                 classitem->curr_user_count,
683 >                 classitem->active ? "active" : "disabled");
684      }
685      break;
686  
# Line 720 | Line 688 | report_confitem_types(struct Client *sou
688    case CLIENT_TYPE:
689      break;
690  
691 +  case SERVICE_TYPE:
692 +    DLINK_FOREACH(ptr, service_items.head)
693 +    {
694 +      conf = ptr->data;
695 +      sendto_one(source_p, form_str(RPL_STATSSERVICE),
696 +                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
697 +    }
698 +    break;
699 +
700    case SERVER_TYPE:
701      DLINK_FOREACH(ptr, server_items.head)
702      {
# Line 732 | Line 709 | report_confitem_types(struct Client *sou
709  
710        if (IsConfAllowAutoConn(aconf))
711          *p++ = 'A';
712 <      if (IsConfCryptLink(aconf))
713 <        *p++ = 'C';
737 <      if (IsConfLazyLink(aconf))
738 <        *p++ = 'L';
739 <      if (aconf->fakename)
740 <        *p++ = 'M';
712 >      if (IsConfSSL(aconf))
713 >        *p++ = 'S';
714        if (IsConfTopicBurst(aconf))
715          *p++ = 'T';
743 –      if (IsConfCompressed(aconf))
744 –        *p++ = 'Z';
716        if (buf[0] == '\0')
717          *p++ = '*';
718  
719        *p = '\0';
720  
721 <      /* Allow admins to see actual ips
722 <       * unless hide_server_ips is enabled
721 >      /*
722 >       * Allow admins to see actual ips unless hide_server_ips is enabled
723         */
724 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
724 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
725          sendto_one(source_p, form_str(RPL_STATSCLINE),
726                     me.name, source_p->name, 'C', aconf->host,
727                     buf, conf->name, aconf->port,
# Line 764 | Line 735 | report_confitem_types(struct Client *sou
735      break;
736  
737    case HUB_TYPE:
738 <    DLINK_FOREACH(ptr, hub_items.head)
738 >    DLINK_FOREACH(ptr, server_items.head)
739      {
740        conf = ptr->data;
741 <      matchitem = map_to_conf(conf);
742 <      sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
743 <                 source_p->name, 'H', matchitem->host, conf->name, 0, "*");
741 >      aconf = map_to_conf(conf);
742 >
743 >      DLINK_FOREACH(dptr, aconf->hub_list.head)
744 >        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
745 >                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
746      }
747      break;
748  
749    case LEAF_TYPE:
750 <    DLINK_FOREACH(ptr, leaf_items.head)
750 >    DLINK_FOREACH(ptr, server_items.head)
751      {
752        conf = ptr->data;
753 <      matchitem = map_to_conf(conf);
754 <      sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
755 <                 source_p->name, 'L', matchitem->host, conf->name, 0, "*");
753 >      aconf = map_to_conf(conf);
754 >
755 >      DLINK_FOREACH(dptr, aconf->leaf_list.head)
756 >        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
757 >                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
758      }
759      break;
760  
# Line 790 | Line 765 | report_confitem_types(struct Client *sou
765    case CRESV_TYPE:
766    case NRESV_TYPE:
767    case CLUSTER_TYPE:
768 +  default:
769      break;
770    }
771   }
# Line 816 | Line 792 | check_client(va_list args)
792  
793    /* I'm already in big trouble if source_p->localClient is NULL -db */
794    if ((i = verify_access(source_p, username)))
795 <  {
820 <    ilog(L_INFO, "Access denied: %s[%s]",
795 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
796           source_p->name, source_p->sockhost);
822 –  }
797  
798    switch (i)
799    {
826 –    case IRCD_SOCKET_ERROR:
827 –      exit_client(source_p, &me, "Socket Error");
828 –      break;
829 –
800      case TOO_MANY:
801        sendto_realops_flags(UMODE_FULL, L_ALL,
802                             "Too many on IP for %s (%s).",
803                             get_client_name(source_p, SHOW_IP),
804                             source_p->sockhost);
805 <      ilog(L_INFO,"Too many connections on IP from %s.",
805 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
806             get_client_name(source_p, SHOW_IP));
807 <      ServerStats->is_ref++;
807 >      ++ServerStats.is_ref;
808        exit_client(source_p, &me, "No more connections allowed on that IP");
809        break;
810  
# Line 843 | Line 813 | check_client(va_list args)
813                             "I-line is full for %s (%s).",
814                             get_client_name(source_p, SHOW_IP),
815                             source_p->sockhost);
816 <      ilog(L_INFO,"Too many connections from %s.",
816 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
817             get_client_name(source_p, SHOW_IP));
818 <       ServerStats->is_ref++;
818 >      ++ServerStats.is_ref;
819        exit_client(source_p, &me,
820                  "No more connections allowed in your connection class");
821        break;
822  
823      case NOT_AUTHORIZED:
824 <    {
855 <      static char ipaddr[HOSTIPLEN];
856 <      ServerStats->is_ref++;
824 >      ++ServerStats.is_ref;
825        /* jdc - lists server name & port connections are on */
826        /*       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);
827        sendto_realops_flags(UMODE_UNAUTH, L_ALL,
828                             "Unauthorized client connection from %s [%s] on [%s/%u].",
829                             get_client_name(source_p, SHOW_IP),
830 <                           ipaddr,
830 >                           source_p->sockhost,
831                             source_p->localClient->listener->name,
832                             source_p->localClient->listener->port);
833 <      ilog(L_INFO,
833 >      ilog(LOG_TYPE_IRCD,
834            "Unauthorized client connection from %s on [%s/%u].",
835            get_client_name(source_p, SHOW_IP),
836            source_p->localClient->listener->name,
# Line 875 | Line 840 | check_client(va_list args)
840         * capture reject code here or rely on the connecting too fast code.
841         * - Dianora
842         */
843 <      if(REJECT_HOLD_TIME > 0)
843 >      if (REJECT_HOLD_TIME > 0)
844        {
845          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
846                     me.name, source_p->name);
# Line 885 | Line 850 | check_client(va_list args)
850        else
851          exit_client(source_p, &me, "You are not authorized to use this server");
852        break;
853 <    }
889 <
853 >
854     case BANNED_CLIENT:
855       /*
856        * Don't exit them immediately, play with them a bit.
# Line 899 | Line 863 | check_client(va_list args)
863       }
864       else
865         exit_client(source_p, &me, "Banned");
866 <     ServerStats->is_ref++;
866 >     ++ServerStats.is_ref;
867       break;
868  
869     case 0:
# Line 1016 | Line 980 | attach_iline(struct Client *client_p, st
980    ip_found->count++;
981    SetIpHash(client_p);
982  
983 <  aconf = (struct AccessItem *)map_to_conf(conf);
983 >  aconf = map_to_conf(conf);
984    if (aconf->class_ptr == NULL)
985      return NOT_AUTHORIZED;  /* If class is missing, this is best */
986  
987 <  aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
987 >  aclass = map_to_conf(aconf->class_ptr);
988  
989    count_user_host(client_p->username, client_p->host,
990                    &global, &local, &ident);
# Line 1029 | Line 993 | attach_iline(struct Client *client_p, st
993     * setting a_limit_reached if any limit is reached.
994     * - Dianora
995     */
996 <  if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
996 >  if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
997      a_limit_reached = 1;
998 <  else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass))
998 >  else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
999      a_limit_reached = 1;
1000 <  else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
1000 >  else if (aclass->max_local != 0 && local >= aclass->max_local)
1001      a_limit_reached = 1;
1002 <  else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))
1002 >  else if (aclass->max_global != 0 && global >= aclass->max_global)
1003      a_limit_reached = 1;
1004 <  else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&
1004 >  else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
1005             client_p->username[0] != '~')
1006      a_limit_reached = 1;
1007  
1008    if (a_limit_reached)
1009    {
1010      if (!IsConfExemptLimits(aconf))
1011 <      return TOO_MANY;  /* Already at maximum allowed */
1011 >      return TOO_MANY;   /* Already at maximum allowed */
1012  
1013      sendto_one(client_p,
1014                 ":%s NOTICE %s :*** Your connection class is full, "
# Line 1193 | Line 1157 | hash_ip(struct irc_ssaddr *addr)
1157    {
1158      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
1159      int hash;
1160 <    u_int32_t ip;
1160 >    uint32_t ip;
1161  
1162      ip   = ntohl(v4->sin_addr.s_addr);
1163      hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
# Line 1204 | Line 1168 | hash_ip(struct irc_ssaddr *addr)
1168    {
1169      int hash;
1170      struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
1171 <    u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr;
1171 >    uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
1172  
1173      hash  = ip[0] ^ ip[3];
1174      hash ^= hash >> 16;  
# Line 1228 | Line 1192 | hash_ip(struct irc_ssaddr *addr)
1192   * used in the hash.
1193   */
1194   void
1195 < count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored)
1195 > count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
1196   {
1197    struct ip_entry *ptr;
1198    int i;
# Line 1316 | Line 1280 | detach_conf(struct Client *client_p, Con
1280        case CLIENT_TYPE:
1281        case OPER_TYPE:
1282        case SERVER_TYPE:
1283 <        aconf = (struct AccessItem *)map_to_conf(conf);
1284 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1283 >        aconf = map_to_conf(conf);
1284 >
1285 >        assert(aconf->clients > 0);
1286 >
1287 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1288          {
1289 <          aclass = (struct ClassItem *)map_to_conf(aclass_conf);
1289 >          aclass = map_to_conf(aclass_conf);
1290 >
1291 >          assert(aclass->curr_user_count > 0);
1292  
1293            if (conf->type == CLIENT_TYPE)
1294              remove_from_cidr_check(&client_p->localClient->ip, aclass);
1295 <
1327 <          if (CurrUserCount(aclass) > 0)
1328 <            aclass->curr_user_count--;
1329 <          if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0)
1295 >          if (--aclass->curr_user_count == 0 && aclass->active == 0)
1296              delete_conf_item(aclass_conf);
1297          }
1298  
1299 <        /* 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)
1299 >        if (--aconf->clients == 0 && IsConfIllegal(aconf))
1300            delete_conf_item(conf);
1301 +
1302          break;
1303        default:
1304          break;
# Line 1367 | Line 1325 | detach_conf(struct Client *client_p, Con
1325   int
1326   attach_conf(struct Client *client_p, struct ConfItem *conf)
1327   {
1370 –  struct AccessItem *aconf;
1371 –  struct MatchItem *match_item;
1372 –
1328    if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
1329      return 1;
1330  
# Line 1377 | Line 1332 | attach_conf(struct Client *client_p, str
1332        conf->type == SERVER_TYPE ||
1333        conf->type == OPER_TYPE)
1334    {
1335 <    aconf = (struct AccessItem *)map_to_conf(conf);
1335 >    struct AccessItem *aconf = map_to_conf(conf);
1336 >    struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1337  
1338      if (IsConfIllegal(aconf))
1339        return NOT_AUTHORIZED;
1340  
1341      if (conf->type == CLIENT_TYPE)
1386 –    {
1387 –      struct ClassItem *aclass;
1388 –      aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1389 –
1342        if (cidr_limit_reached(IsConfExemptLimits(aconf),
1343                               &client_p->localClient->ip, aclass))
1344 <        return TOO_MANY;  /* Already at maximum allowed */
1393 <
1394 <      CurrUserCount(aclass)++;
1395 <    }
1344 >        return TOO_MANY;    /* Already at maximum allowed */
1345  
1346 +    aclass->curr_user_count++;
1347      aconf->clients++;
1348    }
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 –  }
1349  
1350    dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
1351  
# Line 1432 | Line 1377 | attach_connect_block(struct Client *clie
1377    DLINK_FOREACH(ptr, server_items.head)
1378    {
1379      conf = ptr->data;
1380 <    aconf = (struct AccessItem *)map_to_conf(conf);
1380 >    aconf = map_to_conf(conf);
1381  
1382      if (match(conf->name, name) == 0 || match(aconf->host, host) == 0)
1383        continue;
# Line 1472 | Line 1417 | find_conf_exact(ConfType type, const cha
1417  
1418      if (conf->name == NULL)
1419        continue;
1420 <    aconf = (struct AccessItem *)map_to_conf(conf);
1420 >    aconf = map_to_conf(conf);
1421      if (aconf->host == NULL)
1422        continue;
1423      if (irccmp(conf->name, name) != 0)
# Line 1483 | Line 1428 | find_conf_exact(ConfType type, const cha
1428      ** socket host) matches *either* host or name field
1429      ** of the configuration.
1430      */
1431 <    if (!match(aconf->host, host) || !match(aconf->user,user)
1487 <        || irccmp(conf->name, name) )
1431 >    if (!match(aconf->host, host) || !match(aconf->user, user))
1432        continue;
1433      if (type == OPER_TYPE)
1434      {
1435 <      struct ClassItem *aclass;
1435 >      struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1436  
1437 <      aclass = (struct ClassItem *)aconf->class_ptr;
1494 <      if (aconf->clients < MaxTotal(aclass))
1495 <        return conf;
1496 <      else
1437 >      if (aconf->clients >= aclass->max_total)
1438          continue;
1439      }
1440 <    else
1441 <      return conf;
1440 >
1441 >    return conf;
1442    }
1443 +
1444    return NULL;
1445   }
1446  
# Line 1564 | Line 1506 | map_to_list(ConfType type)
1506    case SERVER_TYPE:
1507      return(&server_items);
1508      break;
1509 +  case SERVICE_TYPE:
1510 +    return(&service_items);
1511 +    break;
1512    case CLUSTER_TYPE:
1513      return(&cluster_items);
1514      break;
# Line 1599 | Line 1544 | find_matching_name_conf(ConfType type, c
1544  
1545    switch (type)
1546    {
1547 <    case RXLINE_TYPE:
1547 > #ifdef HAVE_LIBPCRE
1548 >  case RXLINE_TYPE:
1549        DLINK_FOREACH(ptr, list_p->head)
1550        {
1551          conf = ptr->data;
# Line 1609 | Line 1555 | find_matching_name_conf(ConfType type, c
1555            return conf;
1556        }
1557        break;
1558 + #endif
1559 +  case SERVICE_TYPE:
1560 +    DLINK_FOREACH(ptr, list_p->head)
1561 +    {
1562 +      conf = ptr->data;
1563 +
1564 +      if (EmptyString(conf->name))
1565 +        continue;
1566 +      if ((name != NULL) && !irccmp(name, conf->name))
1567 +        return conf;
1568 +    }
1569 +    break;
1570  
1571    case XLINE_TYPE:
1572    case ULINE_TYPE:
# Line 1663 | Line 1621 | find_matching_name_conf(ConfType type, c
1621   * side effects - looks for an exact match on name field
1622   */
1623   struct ConfItem *
1624 < find_exact_name_conf(ConfType type, const char *name,
1624 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1625                       const char *user, const char *host)
1626   {
1627    dlink_node *ptr = NULL;
# Line 1704 | Line 1662 | find_exact_name_conf(ConfType type, cons
1662      DLINK_FOREACH(ptr, list_p->head)
1663      {
1664        conf = ptr->data;
1665 <      aconf = (struct AccessItem *)map_to_conf(conf);
1665 >      aconf = map_to_conf(conf);
1666 >
1667        if (EmptyString(conf->name))
1668 <        continue;
1669 <    
1670 <      if (irccmp(conf->name, name) == 0)
1668 >        continue;
1669 >
1670 >      if (!irccmp(conf->name, name))
1671        {
1672 <        if ((user == NULL && (host == NULL)))
1673 <          return (conf);
1674 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1675 <          return (conf);
1676 <        if (match(aconf->user, user) && match(aconf->host, host))
1677 <          return (conf);
1672 >        if (!who)
1673 >          return conf;
1674 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1675 >          return conf;
1676 >        if (match(aconf->user, who->username))
1677 >        {
1678 >          switch (aconf->type)
1679 >          {
1680 >            case HM_HOST:
1681 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1682 >                return conf;
1683 >              break;
1684 >            case HM_IPV4:
1685 >              if (who->localClient->aftype == AF_INET)
1686 >                if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits))
1687 >                  return conf;
1688 >              break;
1689 > #ifdef IPV6
1690 >            case HM_IPV6:
1691 >              if (who->localClient->aftype == AF_INET6)
1692 >                if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits))
1693 >                  return conf;
1694 >              break;
1695 > #endif
1696 >            default:
1697 >              assert(0);
1698 >          }
1699 >        }
1700        }
1701      }
1702 +
1703      break;
1704  
1705    case SERVER_TYPE:
# Line 1773 | Line 1755 | rehash(int sig)
1755      sendto_realops_flags(UMODE_ALL, L_ALL,
1756                           "Got signal SIGHUP, reloading ircd.conf file");
1757  
1776 – #ifndef _WIN32
1758    restart_resolver();
1759 < #endif
1759 >
1760    /* don't close listeners until we know we can go ahead with the rehash */
1761  
1762    /* Check to see if we magically got(or lost) IPv6 support */
# Line 1786 | Line 1767 | rehash(int sig)
1767    if (ServerInfo.description != NULL)
1768      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1769  
1789 – #ifndef STATIC_MODULES
1770    load_conf_modules();
1791 – #endif
1771  
1772    flush_deleted_I_P();
1773  
1774    rehashed_klines = 1;
1775 <
1775 > /* XXX */
1776    if (ConfigLoggingEntry.use_logging)
1777 <    reopen_log(logFileName);
1777 >    log_close_all();
1778  
1779    return(0);
1780   }
# Line 1834 | Line 1813 | set_default_conf(void)
1813    ServerInfo.specific_ipv6_vhost = 0;
1814  
1815    ServerInfo.max_clients = MAXCLIENTS_MAX;
1816 <  /* Don't reset hub, as that will break lazylinks */
1817 <  /* ServerInfo.hub = NO; */
1816 >
1817 >  ServerInfo.hub = 0;
1818    ServerInfo.dns_host.sin_addr.s_addr = 0;
1819    ServerInfo.dns_host.sin_port = 0;
1820    AdminInfo.name = NULL;
1821    AdminInfo.email = NULL;
1822    AdminInfo.description = NULL;
1823  
1824 <  set_log_level(L_NOTICE);
1824 >  log_close_all();
1825 >
1826    ConfigLoggingEntry.use_logging = 1;
1827 <  ConfigLoggingEntry.operlog[0] = '\0';
1828 <  ConfigLoggingEntry.userlog[0] = '\0';
1829 <  ConfigLoggingEntry.klinelog[0] = '\0';
1830 <  ConfigLoggingEntry.glinelog[0] = '\0';
1831 <  ConfigLoggingEntry.killlog[0] = '\0';
1832 <  ConfigLoggingEntry.operspylog[0] = '\0';
1833 <  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;
1827 >
1828 >  ConfigChannel.disable_fake_channels = 0;
1829 >  ConfigChannel.restrict_channels = 0;
1830 >  ConfigChannel.disable_local_channels = 0;
1831 >  ConfigChannel.use_invex = 1;
1832 >  ConfigChannel.use_except = 1;
1833 >  ConfigChannel.use_knock = 1;
1834    ConfigChannel.knock_delay = 300;
1835    ConfigChannel.knock_delay_channel = 60;
1863 –  ConfigChannel.invite_ops_only = YES;
1836    ConfigChannel.max_chans_per_user = 15;
1837 <  ConfigChannel.quiet_on_ban = YES;
1837 >  ConfigChannel.quiet_on_ban = 1;
1838    ConfigChannel.max_bans = 25;
1839    ConfigChannel.default_split_user_count = 0;
1840    ConfigChannel.default_split_server_count = 0;
1841 <  ConfigChannel.no_join_on_split = NO;
1842 <  ConfigChannel.no_create_on_split = NO;
1843 <  ConfigChannel.burst_topicwho = YES;
1841 >  ConfigChannel.no_join_on_split = 0;
1842 >  ConfigChannel.no_create_on_split = 0;
1843 >  ConfigChannel.burst_topicwho = 1;
1844  
1845 <  ConfigServerHide.flatten_links = NO;
1845 >  ConfigServerHide.flatten_links = 0;
1846    ConfigServerHide.links_delay = 300;
1847 <  ConfigServerHide.hidden = NO;
1848 <  ConfigServerHide.disable_hidden = NO;
1849 <  ConfigServerHide.hide_servers = NO;
1847 >  ConfigServerHide.hidden = 0;
1848 >  ConfigServerHide.disable_hidden = 0;
1849 >  ConfigServerHide.hide_servers = 0;
1850    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1851 <  ConfigServerHide.hide_server_ips = NO;
1851 >  ConfigServerHide.hide_server_ips = 0;
1852  
1853 +  
1854 +  DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1855 +  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1856    ConfigFileEntry.gline_min_cidr = 16;
1857    ConfigFileEntry.gline_min_cidr6 = 48;
1858 <  ConfigFileEntry.invisible_on_connect = YES;
1859 <  ConfigFileEntry.burst_away = NO;
1860 <  ConfigFileEntry.use_whois_actually = YES;
1861 <  ConfigFileEntry.tkline_expire_notices = YES;
1862 <  ConfigFileEntry.hide_spoof_ips = YES;
1863 <  ConfigFileEntry.ignore_bogus_ts = NO;
1864 <  ConfigFileEntry.disable_auth = NO;
1865 <  ConfigFileEntry.disable_remote = NO;
1858 >  ConfigFileEntry.invisible_on_connect = 1;
1859 >  ConfigFileEntry.burst_away = 0;
1860 >  ConfigFileEntry.use_whois_actually = 1;
1861 >  ConfigFileEntry.tkline_expire_notices = 1;
1862 >  ConfigFileEntry.hide_spoof_ips = 1;
1863 >  ConfigFileEntry.ignore_bogus_ts = 0;
1864 >  ConfigFileEntry.disable_auth = 0;
1865 >  ConfigFileEntry.disable_remote = 0;
1866    ConfigFileEntry.kill_chase_time_limit = 90;
1867 <  ConfigFileEntry.default_floodcount = 8; /* XXX */
1868 <  ConfigFileEntry.failed_oper_notice = YES;
1869 <  ConfigFileEntry.dots_in_ident = 0;      /* XXX */
1895 <  ConfigFileEntry.dot_in_ip6_addr = YES;
1867 >  ConfigFileEntry.default_floodcount = 8;
1868 >  ConfigFileEntry.failed_oper_notice = 1;
1869 >  ConfigFileEntry.dots_in_ident = 0;
1870    ConfigFileEntry.min_nonwildcard = 4;
1871    ConfigFileEntry.min_nonwildcard_simple = 3;
1872    ConfigFileEntry.max_accept = 20;
1873 <  ConfigFileEntry.anti_nick_flood = NO;   /* XXX */
1873 >  ConfigFileEntry.anti_nick_flood = 0;
1874    ConfigFileEntry.max_nick_time = 20;
1875    ConfigFileEntry.max_nick_changes = 5;
1876 <  ConfigFileEntry.anti_spam_exit_message_time = 0;  /* XXX */
1876 >  ConfigFileEntry.anti_spam_exit_message_time = 0;
1877    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1878 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;  /* XXX */
1879 <  ConfigFileEntry.kline_with_reason = YES;
1878 >  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1879 >  ConfigFileEntry.kline_with_reason = 1;
1880    ConfigFileEntry.kline_reason = NULL;
1881 <  ConfigFileEntry.warn_no_nline = YES;
1882 <  ConfigFileEntry.stats_o_oper_only = NO; /* XXX */
1881 >  ConfigFileEntry.warn_no_nline = 1;
1882 >  ConfigFileEntry.stats_o_oper_only = 0;
1883    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1884    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1885 <  ConfigFileEntry.stats_P_oper_only = NO;
1885 >  ConfigFileEntry.stats_P_oper_only = 0;
1886    ConfigFileEntry.caller_id_wait = 60;
1887 <  ConfigFileEntry.opers_bypass_callerid = NO;
1887 >  ConfigFileEntry.opers_bypass_callerid = 0;
1888    ConfigFileEntry.pace_wait = 10;
1889    ConfigFileEntry.pace_wait_simple = 1;
1890 <  ConfigFileEntry.short_motd = NO;
1891 <  ConfigFileEntry.ping_cookie = NO;
1892 <  ConfigFileEntry.no_oper_flood = NO;     /* XXX */
1893 <  ConfigFileEntry.true_no_oper_flood = NO;  /* XXX */
1894 <  ConfigFileEntry.oper_pass_resv = YES;
1895 <  ConfigFileEntry.glines = NO;            /* XXX */
1896 <  ConfigFileEntry.gline_time = 12 * 3600; /* XXX */
1923 <  ConfigFileEntry.idletime = 0;
1890 >  ConfigFileEntry.short_motd = 0;
1891 >  ConfigFileEntry.ping_cookie = 0;
1892 >  ConfigFileEntry.no_oper_flood = 0;
1893 >  ConfigFileEntry.true_no_oper_flood = 0;
1894 >  ConfigFileEntry.oper_pass_resv = 1;
1895 >  ConfigFileEntry.glines = 0;
1896 >  ConfigFileEntry.gline_time = 12 * 3600;
1897    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1898    ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1899 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;  /* XXX */
1900 <  ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE |
1901 <    UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1902 <  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;
1899 >  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1900 >  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1901 >    UMODE_OPERWALL | UMODE_WALLOP;
1902 >  ConfigFileEntry.use_egd = 0;
1903    ConfigFileEntry.egdpool_path = NULL;
1943 – #ifdef HAVE_LIBZ
1944 –  ConfigFileEntry.compression_level = 0;
1945 – #endif
1904    ConfigFileEntry.throttle_time = 10;
1905   }
1906  
1949 – /* read_conf()
1950 – *
1951 – * inputs       - file descriptor pointing to config file to use
1952 – * output       - None
1953 – * side effects - Read configuration file.
1954 – */
1955 – static void
1956 – read_conf(FBFILE *file)
1957 – {
1958 –  scount = lineno = 0;
1959 –
1960 –  set_default_conf(); /* Set default values prior to conf parsing */
1961 –  ypass = 1;
1962 –  yyparse();          /* pick up the classes first */
1963 –
1964 –  fbrewind(file);
1965 –
1966 –  ypass = 2;
1967 –  yyparse();          /* Load the values from the conf */
1968 –  validate_conf();    /* Check to make sure some values are still okay. */
1969 –                      /* Some global values are also loaded here. */
1970 –  check_class();      /* Make sure classes are valid */
1971 – }
1972 –
1907   static void
1908   validate_conf(void)
1909   {
# Line 1979 | Line 1913 | validate_conf(void)
1913    if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1914      ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1915  
1982 –  if (ConfigFileEntry.servlink_path == NULL)
1983 –    DupString(ConfigFileEntry.servlink_path, SLPATH);
1984 –
1916    if (ServerInfo.network_name == NULL)
1917      DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1918  
1919    if (ServerInfo.network_desc == NULL)
1920      DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1921  
1922 +  if (ConfigFileEntry.service_name == NULL)
1923 +    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1924 +
1925    if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
1926        (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
1927      ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
1928 +
1929 +  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1930 + }
1931 +
1932 + /* read_conf()
1933 + *
1934 + * inputs       - file descriptor pointing to config file to use
1935 + * output       - None
1936 + * side effects - Read configuration file.
1937 + */
1938 + static void
1939 + read_conf(FILE *file)
1940 + {
1941 +  lineno = 0;
1942 +
1943 +  set_default_conf(); /* Set default values prior to conf parsing */
1944 +  conf_parser_ctx.pass = 1;
1945 +  yyparse();          /* pick up the classes first */
1946 +
1947 +  rewind(file);
1948 +
1949 +  conf_parser_ctx.pass = 2;
1950 +  yyparse();          /* Load the values from the conf */
1951 +  validate_conf();    /* Check to make sure some values are still okay. */
1952 +                      /* Some global values are also loaded here. */
1953 +  check_class();      /* Make sure classes are valid */
1954   }
1955  
1956   /* lookup_confhost()
# Line 2009 | Line 1969 | lookup_confhost(struct ConfItem *conf)
1969    if (EmptyString(aconf->host) ||
1970        EmptyString(aconf->user))
1971    {
1972 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
1972 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
1973           aconf->host, conf->name);
1974      return;
1975    }
# Line 2029 | Line 1989 | lookup_confhost(struct ConfItem *conf)
1989    /* Get us ready for a bind() and don't bother doing dns lookup */
1990    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1991  
1992 <  if (irc_getaddrinfo(aconf->host, NULL, &hints, &res))
1992 >  if (getaddrinfo(aconf->host, NULL, &hints, &res))
1993    {
1994      conf_dns_lookup(aconf);
1995      return;
# Line 2037 | Line 1997 | lookup_confhost(struct ConfItem *conf)
1997  
1998    assert(res != NULL);
1999  
2000 <  memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
2001 <  aconf->ipnum.ss_len = res->ai_addrlen;
2002 <  aconf->ipnum.ss.ss_family = res->ai_family;
2003 <  irc_freeaddrinfo(res);
2000 >  memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen);
2001 >  aconf->addr.ss_len = res->ai_addrlen;
2002 >  aconf->addr.ss.ss_family = res->ai_family;
2003 >  freeaddrinfo(res);
2004   }
2005  
2006   /* conf_connect_allowed()
# Line 2079 | Line 2039 | conf_connect_allowed(struct irc_ssaddr *
2039   static struct AccessItem *
2040   find_regexp_kline(const char *uhi[])
2041   {
2042 + #ifdef HAVE_LIBPCRE
2043    const dlink_node *ptr = NULL;
2044  
2045    DLINK_FOREACH(ptr, rkconf_items.head)
# Line 2093 | Line 2054 | find_regexp_kline(const char *uhi[])
2054           !ircd_pcre_exec(aptr->regexhost, uhi[2])))
2055        return aptr;
2056    }
2057 <
2057 > #endif
2058    return NULL;
2059   }
2060  
# Line 2155 | Line 2116 | find_gline(struct Client *client_p)
2116   void
2117   add_temp_line(struct ConfItem *conf)
2118   {
2119 <  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)
2119 >  if (conf->type == XLINE_TYPE)
2120    {
2121      conf->flags |= CONF_FLAGS_TEMPORARY;
2122      dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2123    }
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 –  }
2124    else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2125    {
2126      conf->flags |= CONF_FLAGS_TEMPORARY;
# Line 2212 | Line 2138 | add_temp_line(struct ConfItem *conf)
2138   void
2139   cleanup_tklines(void *notused)
2140   {
2141 <  expire_tklines(&temporary_glines);
2216 <  expire_tklines(&temporary_klines);
2217 <  expire_tklines(&temporary_dlines);
2141 >  hostmask_expire_temporary();
2142    expire_tklines(&temporary_xlines);
2219 –  expire_tklines(&temporary_rxlines);
2220 –  expire_tklines(&temporary_rklines);
2143    expire_tklines(&temporary_resv);
2144   }
2145  
# Line 2235 | Line 2157 | expire_tklines(dlink_list *tklist)
2157    struct ConfItem *conf;
2158    struct MatchItem *xconf;
2159    struct MatchItem *nconf;
2238 –  struct AccessItem *aconf;
2160    struct ResvChannel *cconf;
2161  
2162    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2163    {
2164      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 –        }
2165  
2166 <        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)
2166 >    if (conf->type == XLINE_TYPE)
2167      {
2168        xconf = (struct MatchItem *)map_to_conf(conf);
2169        if (xconf->hold <= CurrentTime)
2170        {
2171          if (ConfigFileEntry.tkline_expire_notices)
2172            sendto_realops_flags(UMODE_ALL, L_ALL,
2173 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2283 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2173 >                               "Temporary X-line for [%s] sexpired", conf->name);
2174          dlinkDelete(ptr, tklist);
2175          free_dlink_node(ptr);
2176          delete_conf_item(conf);
2177        }
2178      }
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 –    }
2179      else if (conf->type == NRESV_TYPE)
2180      {
2181        nconf = (struct MatchItem *)map_to_conf(conf);
# Line 2322 | Line 2197 | expire_tklines(dlink_list *tklist)
2197          if (ConfigFileEntry.tkline_expire_notices)
2198            sendto_realops_flags(UMODE_ALL, L_ALL,
2199                                 "Temporary RESV for [%s] expired", cconf->name);
2200 <        dlinkDelete(ptr, tklist);
2326 <        free_dlink_node(ptr);
2327 <        delete_conf_item(conf);
2200 >        delete_channel_resv(cconf);
2201        }
2202      }
2203    }
# Line 2332 | Line 2205 | expire_tklines(dlink_list *tklist)
2205  
2206   /* oper_privs_as_string()
2207   *
2208 < * inputs        - pointer to client_p or NULL
2208 > * inputs        - pointer to client_p
2209   * output        - pointer to static string showing oper privs
2210   * side effects  - return as string, the oper privs as derived from port
2211   */
2212 <
2213 < static const unsigned int oper_flags_table[] =
2214 <  { 'O', 'R', 'U', 'G', 'N', 'K', 'X', 'D', 'H', 'A' , 0 };
2212 > static const struct oper_privs
2213 > {
2214 >  const unsigned int oprivs;
2215 >  const unsigned char c;
2216 > } flag_list[] = {
2217 >  { OPER_FLAG_ADMIN,       'A' },
2218 >  { OPER_FLAG_REMOTEBAN,   'B' },
2219 >  { OPER_FLAG_DIE,         'D' },
2220 >  { OPER_FLAG_GLINE,       'G' },
2221 >  { OPER_FLAG_REHASH,      'H' },
2222 >  { OPER_FLAG_K,           'K' },
2223 >  { OPER_FLAG_OPERWALL,    'L' },
2224 >  { OPER_FLAG_N,           'N' },
2225 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2226 >  { OPER_FLAG_REMOTE,      'R' },
2227 >  { OPER_FLAG_OPER_SPY,    'S' },
2228 >  { OPER_FLAG_UNKLINE,     'U' },
2229 >  { OPER_FLAG_X,           'X' },
2230 >  { 0, '\0' }
2231 > };
2232  
2233   char *
2234   oper_privs_as_string(const unsigned int port)
2235   {
2236 <  static char privs_out[12];
2236 >  static char privs_out[16];
2237 >  char *privs_ptr = privs_out;
2238 >  unsigned int i = 0;
2239 >
2240 >  for (; flag_list[i].oprivs; ++i)
2241 >  {
2242 >    if (port & flag_list[i].oprivs)
2243 >      *privs_ptr++ = flag_list[i].c;
2244 >    else
2245 >      *privs_ptr++ = ToLowerTab[flag_list[i].c];
2246 >  }
2247 >
2248 >  *privs_ptr = '\0';
2249  
2348 –  if (port & OPER_FLAG_HIDDEN_ADMIN)
2349 –    flags_to_ascii(port & ~OPER_FLAG_ADMIN, oper_flags_table, privs_out, 1);
2350 –  else
2351 –    flags_to_ascii(port, oper_flags_table, privs_out, 1);
2250    return privs_out;
2251   }
2252  
# Line 2358 | Line 2256 | oper_privs_as_string(const unsigned int
2256   *         "oper" is server name for remote opers
2257   * Side effects: None.
2258   */
2259 < char *
2259 > const char *
2260   get_oper_name(const struct Client *client_p)
2261   {
2262 <  dlink_node *cnode;
2365 <  struct ConfItem *conf;
2366 <  struct AccessItem *aconf;
2367 <
2262 >  dlink_node *cnode = NULL;
2263    /* +5 for !,@,{,} and null */
2264 <  static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
2264 >  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2265  
2266    if (MyConnect(client_p))
2267    {
2268 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2268 >    if ((cnode = client_p->localClient->confs.head))
2269      {
2270 <      conf = cnode->data;
2271 <      aconf = map_to_conf(conf);
2270 >      struct ConfItem *conf = cnode->data;
2271 >      const struct AccessItem *aconf = map_to_conf(conf);
2272  
2273        if (IsConfOperator(aconf))
2274        {
2275 <        ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2276 <                   client_p->username, client_p->host,
2382 <                   conf->name);
2275 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2276 >                 client_p->username, client_p->host, conf->name);
2277          return buffer;
2278        }
2279      }
# Line 2390 | Line 2284 | get_oper_name(const struct Client *clien
2284      assert(0); /* Oper without oper conf! */
2285    }
2286  
2287 <  ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2288 <             client_p->username, client_p->host, client_p->servptr->name);
2287 >  snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2288 >           client_p->username, client_p->host, client_p->servptr->name);
2289    return buffer;
2290   }
2291  
# Line 2408 | Line 2302 | read_conf_files(int cold)
2302    char chanmodes[32];
2303    char chanlimit[32];
2304  
2305 +  conf_parser_ctx.boot = cold;
2306    filename = get_conf_name(CONF_TYPE);
2307  
2308    /* We need to know the initial filename for the yyerror() to report
# Line 2418 | Line 2313 | read_conf_files(int cold)
2313    */
2314    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2315  
2316 <  if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
2316 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2317    {
2318      if (cold)
2319      {
2320 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2320 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2321             filename, strerror(errno));
2322        exit(-1);
2323      }
# Line 2438 | Line 2333 | read_conf_files(int cold)
2333    if (!cold)
2334      clear_out_old_conf();
2335  
2336 <  read_conf(conf_fbfile_in);
2337 <  fbclose(conf_fbfile_in);
2336 >  read_conf(conf_parser_ctx.conf_file);
2337 >  fclose(conf_parser_ctx.conf_file);
2338  
2339    add_isupport("NETWORK", ServerInfo.network_name, -1);
2340 <  ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "",
2341 <             ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2340 >  snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d",
2341 >           ConfigChannel.use_except ? "e" : "",
2342 >           ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2343    add_isupport("MAXLIST", chanmodes, -1);
2344    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2345 +
2346    if (ConfigChannel.disable_local_channels)
2347      add_isupport("CHANTYPES", "#", -1);
2348    else
2349      add_isupport("CHANTYPES", "#&", -1);
2350 <  ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&",
2351 <             ConfigChannel.max_chans_per_user);
2350 >
2351 >  snprintf(chanlimit, sizeof(chanlimit), "%s:%d",
2352 >           ConfigChannel.disable_local_channels ? "#" : "#&",
2353 >           ConfigChannel.max_chans_per_user);
2354    add_isupport("CHANLIMIT", chanlimit, -1);
2355 <  ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2356 <             ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2357 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
2355 >  snprintf(chanmodes, sizeof(chanmodes), "%s%s%s",
2356 >           ConfigChannel.use_except ? "e" : "",
2357 >           ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS");
2358 >  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2359 >
2360    if (ConfigChannel.use_except)
2361      add_isupport("EXCEPTS", "e", -1);
2362    if (ConfigChannel.use_invex)
# Line 2468 | Line 2369 | read_conf_files(int cold)
2369     */
2370    rebuild_isupport_message_line();
2371  
2372 <  parse_conf_file(KLINE_TYPE, cold);
2372 > #ifdef HAVE_LIBPCRE
2373    parse_conf_file(RKLINE_TYPE, cold);
2374 +  parse_conf_file(RXLINE_TYPE, cold);
2375 + #endif
2376 +  parse_conf_file(KLINE_TYPE, cold);
2377    parse_conf_file(DLINE_TYPE, cold);
2378    parse_conf_file(XLINE_TYPE, cold);
2475 –  parse_conf_file(RXLINE_TYPE, cold);
2379    parse_conf_file(NRESV_TYPE, cold);
2380    parse_conf_file(CRESV_TYPE, cold);
2381   }
# Line 2486 | Line 2389 | read_conf_files(int cold)
2389   static void
2390   parse_conf_file(int type, int cold)
2391   {
2392 <  FBFILE *file = NULL;
2392 >  FILE *file = NULL;
2393    const char *filename = get_conf_name(type);
2394  
2395 <  if ((file = fbopen(filename, "r")) == NULL)
2395 >  if ((file = fopen(filename, "r")) == NULL)
2396    {
2397      if (cold)
2398 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2398 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2399             filename, strerror(errno));
2400      else
2401        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2502 | Line 2405 | parse_conf_file(int type, int cold)
2405    else
2406    {
2407      parse_csv_file(file, type);
2408 <    fbclose(file);
2408 >    fclose(file);
2409    }
2410   }
2411  
# Line 2521 | Line 2424 | clear_out_old_conf(void)
2424    struct ClassItem *cltmp;
2425    struct MatchItem *match_item;
2426    dlink_list *free_items [] = {
2427 <    &server_items,   &oconf_items,    &hub_items, &leaf_items,
2427 >    &server_items,   &oconf_items,
2428       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2429 <     &nresv_items, &cluster_items,  &gdeny_items, NULL
2429 >     &nresv_items, &cluster_items,  &gdeny_items, &service_items, NULL
2430    };
2431  
2432    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2540 | Line 2443 | clear_out_old_conf(void)
2443        /* XXX This is less than pretty */
2444        if (conf->type == SERVER_TYPE)
2445        {
2446 <        aconf = (struct AccessItem *)map_to_conf(conf);
2446 >        aconf = map_to_conf(conf);
2447 >
2448          if (aconf->clients != 0)
2449          {
2450            SetConfIllegal(aconf);
# Line 2553 | Line 2457 | clear_out_old_conf(void)
2457        }
2458        else if (conf->type == OPER_TYPE)
2459        {
2460 <        aconf = (struct AccessItem *)map_to_conf(conf);
2460 >        aconf = map_to_conf(conf);
2461 >
2462          if (aconf->clients != 0)
2463          {
2464            SetConfIllegal(aconf);
# Line 2564 | Line 2469 | clear_out_old_conf(void)
2469            delete_conf_item(conf);
2470          }
2471        }
2567 –      else if (conf->type == CLIENT_TYPE)
2568 –      {
2569 –        aconf = (struct AccessItem *)map_to_conf(conf);
2570 –        if (aconf->clients != 0)
2571 –        {
2572 –          SetConfIllegal(aconf);
2573 –        }
2574 –        else
2575 –        {
2576 –          delete_conf_item(conf);
2577 –        }
2578 –      }
2472        else if (conf->type == XLINE_TYPE  ||
2473                 conf->type == RXLINE_TYPE ||
2474                 conf->type == RKLINE_TYPE)
# Line 2589 | Line 2482 | clear_out_old_conf(void)
2482        }
2483        else
2484        {
2592 –        if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2593 –        {
2594 –          match_item = (struct MatchItem *)map_to_conf(conf);
2595 –          if ((match_item->ref_count <= 0))
2596 –            delete_conf_item(conf);
2597 –          else
2598 –          {
2599 –            match_item->illegal = 1;
2600 –            dlinkDelete(&conf->node, *iterator);
2601 –          }
2602 –        }
2603 –        else
2485            delete_conf_item(conf);
2486        }
2487      }
2488    }
2489  
2490 <  /* don't delete the class table, rather mark all entries
2490 >  /*
2491 >   * don't delete the class table, rather mark all entries
2492     * for deletion. The table is cleaned up by check_class. - avalon
2493     */
2494    DLINK_FOREACH(ptr, class_items.head)
2495    {
2496 <    conf = ptr->data;
2497 <    cltmp = (struct ClassItem *)map_to_conf(conf);
2496 >    cltmp = map_to_conf(ptr->data);
2497 >
2498      if (ptr != class_items.tail)  /* never mark the "default" class */
2499 <      MaxTotal(cltmp) = -1;
2499 >      cltmp->active = 0;
2500    }
2501  
2502    clear_out_address_conf();
2503  
2504    /* clean out module paths */
2623 – #ifndef STATIC_MODULES
2505    mod_clear_paths();
2625 – #endif
2506  
2507    /* clean out ServerInfo */
2508    MyFree(ServerInfo.description);
# Line 2642 | Line 2522 | clear_out_old_conf(void)
2522  
2523    MyFree(ServerInfo.rsa_private_key_file);
2524    ServerInfo.rsa_private_key_file = NULL;
2525 +
2526 +  if (ServerInfo.server_ctx)
2527 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2528 +                                               SSL_OP_NO_SSLv3|
2529 +                                               SSL_OP_NO_TLSv1);
2530 +  if (ServerInfo.client_ctx)
2531 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2532 +                                               SSL_OP_NO_SSLv3|
2533 +                                               SSL_OP_NO_TLSv1);
2534   #endif
2535  
2536    /* clean out old resvs from the conf */
# Line 2664 | Line 2553 | clear_out_old_conf(void)
2553     */
2554  
2555    /* clean out general */
2556 <  MyFree(ConfigFileEntry.servlink_path);
2557 <  ConfigFileEntry.servlink_path = NULL;
2558 < #ifdef HAVE_LIBCRYPTO
2670 <  ConfigFileEntry.default_cipher_preference = NULL;
2671 < #endif /* HAVE_LIBCRYPTO */
2556 >  MyFree(ConfigFileEntry.service_name);
2557 >  ConfigFileEntry.service_name = NULL;
2558 >
2559    delete_isupport("INVEX");
2560    delete_isupport("EXCEPTS");
2561   }
# Line 2687 | Line 2574 | flush_deleted_I_P(void)
2574    struct ConfItem *conf;
2575    struct AccessItem *aconf;
2576    dlink_list * free_items [] = {
2577 <    &server_items, &oconf_items, &hub_items, &leaf_items, NULL
2577 >    &server_items, &oconf_items, NULL
2578    };
2579    dlink_list ** iterator = free_items; /* C is dumb */
2580  
# Line 2779 | Line 2666 | get_conf_ping(struct ConfItem *conf, int
2666      if (aconf->class_ptr != NULL)
2667      {
2668        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2669 <      *pingwarn = PingWarning(aclass);
2670 <      return PingFreq(aclass);
2669 >      *pingwarn = aclass->ping_warning;
2670 >      return aclass->ping_freq;
2671      }
2672    }
2673  
# Line 2796 | Line 2683 | get_conf_ping(struct ConfItem *conf, int
2683   const char *
2684   get_client_class(struct Client *target_p)
2685   {
2686 <  dlink_node *ptr;
2687 <  struct ConfItem *conf;
2688 <  struct AccessItem *aconf;
2686 >  dlink_node *cnode = NULL;
2687 >  struct AccessItem *aconf = NULL;
2688 >
2689 >  assert(!IsMe(target_p));
2690  
2691 <  if (target_p != NULL && !IsMe(target_p) &&
2804 <      target_p->localClient->confs.head != NULL)
2691 >  if ((cnode = target_p->localClient->confs.head))
2692    {
2693 <    DLINK_FOREACH(ptr, target_p->localClient->confs.head)
2807 <    {
2808 <      conf = ptr->data;
2693 >    struct ConfItem *conf = cnode->data;
2694  
2695 <      if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE ||
2696 <          conf->type == OPER_TYPE)
2697 <      {
2698 <        aconf = (struct AccessItem *) map_to_conf(conf);
2699 <        if (aconf->class_ptr != NULL)
2700 <          return aconf->class_ptr->name;
2816 <      }
2817 <    }
2695 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2696 >          (conf->type == OPER_TYPE));
2697 >
2698 >    aconf = map_to_conf(conf);
2699 >    if (aconf->class_ptr != NULL)
2700 >      return aconf->class_ptr->name;
2701    }
2702  
2703    return "default";
# Line 2830 | Line 2713 | get_client_class(struct Client *target_p
2713   int
2714   get_client_ping(struct Client *target_p, int *pingwarn)
2715   {
2716 <  int ping;
2717 <  struct ConfItem *conf;
2835 <  dlink_node *nlink;
2716 >  int ping = 0;
2717 >  dlink_node *cnode = NULL;
2718  
2719 <  if (target_p->localClient->confs.head != NULL)
2720 <    DLINK_FOREACH(nlink, target_p->localClient->confs.head)
2721 <    {
2840 <      conf = nlink->data;
2719 >  if ((cnode = target_p->localClient->confs.head))
2720 >  {
2721 >    struct ConfItem *conf = cnode->data;
2722  
2723 <      if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2724 <          (conf->type == OPER_TYPE))
2725 <      {
2726 <        ping = get_conf_ping(conf, pingwarn);
2727 <        if (ping > 0)
2728 <          return ping;
2729 <      }
2849 <    }
2723 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2724 >          (conf->type == OPER_TYPE));
2725 >
2726 >    ping = get_conf_ping(conf, pingwarn);
2727 >    if (ping > 0)
2728 >      return ping;
2729 >  }
2730  
2731    *pingwarn = 0;
2732    return DEFAULT_PINGFREQUENCY;
# Line 2863 | Line 2743 | find_class(const char *classname)
2743   {
2744    struct ConfItem *conf;
2745  
2746 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2747 <    return(conf);
2746 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2747 >    return conf;
2748  
2749    return class_default;
2750   }
# Line 2878 | Line 2758 | find_class(const char *classname)
2758   void
2759   check_class(void)
2760   {
2761 <  dlink_node *ptr;
2882 <  dlink_node *next_ptr;
2883 <  struct ConfItem *conf;
2884 <  struct ClassItem *aclass;
2761 >  dlink_node *ptr = NULL, *next_ptr = NULL;
2762  
2763    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)
2764    {
2765 <    conf = ptr->data;
2889 <    aclass = (struct ClassItem *)map_to_conf(conf);
2765 >    struct ClassItem *aclass = map_to_conf(ptr->data);
2766  
2767 <    if (MaxTotal(aclass) < 0)
2767 >    if (!aclass->active && !aclass->curr_user_count)
2768      {
2769        destroy_cidr_class(aclass);
2770 <      if (CurrUserCount(aclass) > 0)
2895 <        dlinkDelete(&conf->node, &class_items);
2896 <      else
2897 <        delete_conf_item(conf);
2770 >      delete_conf_item(ptr->data);
2771      }
2772    }
2773   }
# Line 2911 | Line 2784 | init_class(void)
2784    struct ClassItem *aclass;
2785  
2786    class_default = make_conf_item(CLASS_TYPE);
2787 <  aclass = (struct ClassItem *)map_to_conf(class_default);
2787 >
2788 >  aclass = map_to_conf(class_default);
2789 >  aclass->active = 1;
2790    DupString(class_default->name, "default");
2791 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2792 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2793 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2794 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2791 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2792 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2793 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2794 >  aclass->max_sendq = DEFAULT_SENDQ;
2795  
2796    client_check_cb = register_callback("check_client", check_client);
2797   }
# Line 2927 | Line 2802 | init_class(void)
2802   * output       - sendq for this client as found from its class
2803   * side effects - NONE
2804   */
2805 < unsigned long
2805 > unsigned int
2806   get_sendq(struct Client *client_p)
2807   {
2808 <  unsigned long sendq = DEFAULT_SENDQ;
2809 <  dlink_node *ptr;
2935 <  struct ConfItem *conf;
2808 >  unsigned int sendq = DEFAULT_SENDQ;
2809 >  dlink_node *cnode;
2810    struct ConfItem *class_conf;
2811    struct ClassItem *aclass;
2812    struct AccessItem *aconf;
2813  
2814 <  if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
2814 >  assert(!IsMe(client_p));
2815 >
2816 >  if ((cnode = client_p->localClient->confs.head))
2817    {
2818 <    DLINK_FOREACH(ptr, client_p->localClient->confs.head)
2819 <    {
2820 <      conf = ptr->data;
2821 <      if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE)
2822 <          || (conf->type == CLIENT_TYPE))
2823 <      {
2824 <        aconf = (struct AccessItem *)map_to_conf(conf);
2825 <        if ((class_conf = aconf->class_ptr) == NULL)
2826 <          continue;
2827 <        aclass = (struct ClassItem *)map_to_conf(class_conf);
2828 <        sendq = MaxSendq(aclass);
2829 <        return sendq;
2830 <      }
2955 <    }
2818 >    struct ConfItem *conf = cnode->data;
2819 >
2820 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2821 >          (conf->type == OPER_TYPE));
2822 >
2823 >    aconf = map_to_conf(conf);
2824 >
2825 >    if ((class_conf = aconf->class_ptr) == NULL)
2826 >      return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */
2827 >
2828 >    aclass = map_to_conf(class_conf);
2829 >    sendq = aclass->max_sendq;
2830 >    return sendq;
2831    }
2832 +
2833    /* XXX return a default?
2834     * if here, then there wasn't an attached conf with a sendq
2835     * that is very bad -Dianora
# Line 2970 | Line 2846 | get_sendq(struct Client *client_p)
2846   void
2847   conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)
2848   {
2849 <  struct AccessItem *aconf;
2850 <  struct ClassItem *aclass;
2975 <
2976 <  aconf = (struct AccessItem *)map_to_conf(conf);
2849 >  struct AccessItem *aconf = map_to_conf(conf);
2850 >  struct ClassItem *class = NULL;
2851  
2852    if (class_name == NULL)
2853    {
2854      aconf->class_ptr = class_default;
2855 +
2856      if (conf->type == CLIENT_TYPE)
2857        sendto_realops_flags(UMODE_ALL, L_ALL,
2858                             "Warning *** Defaulting to default class for %s@%s",
# Line 2988 | Line 2863 | conf_add_class_to_conf(struct ConfItem *
2863                             conf->name);
2864    }
2865    else
2991 –  {
2866      aconf->class_ptr = find_class(class_name);
2993 –  }
2867  
2868 <  if (aconf->class_ptr == NULL)
2868 >  if (aconf->class_ptr)
2869 >    class = map_to_conf(aconf->class_ptr);
2870 >
2871 >  if (aconf->class_ptr == NULL || !class->active)
2872    {
2873      if (conf->type == CLIENT_TYPE)
2874        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 3004 | Line 2880 | conf_add_class_to_conf(struct ConfItem *
2880                             conf->name);
2881      aconf->class_ptr = class_default;
2882    }
3007 –  else
3008 –  {
3009 –    aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
3010 –    if (MaxTotal(aclass) < 0)
3011 –    {
3012 –      aconf->class_ptr = class_default;
3013 –    }
3014 –  }
2883   }
2884  
3017 – #define MAXCONFLINKS 150
3018 –
2885   /* conf_add_server()
2886   *
2887   * inputs       - pointer to config item
# Line 3024 | Line 2890 | conf_add_class_to_conf(struct ConfItem *
2890   * side effects - Add a connect block
2891   */
2892   int
2893 < conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name)
2893 > conf_add_server(struct ConfItem *conf, const char *class_name)
2894   {
2895 <  struct AccessItem *aconf;
3030 <  char *orig_host;
3031 <
3032 <  aconf = map_to_conf(conf);
2895 >  struct AccessItem *aconf = map_to_conf(conf);
2896  
2897    conf_add_class_to_conf(conf, class_name);
2898  
2899 <  if (lcount > MAXCONFLINKS || !aconf->host || !conf->name)
2899 >  if (!aconf->host || !conf->name)
2900    {
2901      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2902 <    ilog(L_WARN, "Bad connect block");
2902 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2903      return -1;
2904    }
2905  
2906 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2906 >  if (EmptyString(aconf->passwd))
2907    {
2908      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2909                           conf->name);
2910 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2910 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2911      return -1;
2912    }
2913  
3051 –  orig_host = aconf->host;
3052 –  split_nuh(orig_host, NULL, &aconf->user, &aconf->host);
3053 –  MyFree(orig_host);
2914    lookup_confhost(conf);
2915  
2916    return 0;
2917   }
2918  
3059 – /* conf_add_d_conf()
3060 – *
3061 – * inputs       - pointer to config item
3062 – * output       - NONE
3063 – * side effects - Add a d/D line
3064 – */
3065 – void
3066 – conf_add_d_conf(struct AccessItem *aconf)
3067 – {
3068 –  if (aconf->host == NULL)
3069 –    return;
3070 –
3071 –  aconf->user = NULL;
3072 –
3073 –  /* XXX - Should 'd' ever be in the old conf? For new conf we don't
3074 –   *       need this anyway, so I will disable it for now... -A1kmm
3075 –   */
3076 –  if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST)
3077 –  {
3078 –    ilog(L_WARN, "Invalid Dline %s ignored", aconf->host);
3079 –    free_access_item(aconf);
3080 –  }
3081 –  else
3082 –  {
3083 –    /* XXX ensure user is NULL */
3084 –    MyFree(aconf->user);
3085 –    aconf->user = NULL;
3086 –    add_conf_by_address(CONF_DLINE, aconf);
3087 –  }
3088 – }
3089 –
2919   /* yyerror()
2920   *
2921   * inputs       - message from parser
# Line 3098 | Line 2927 | yyerror(const char *msg)
2927   {
2928    char newlinebuf[IRCD_BUFSIZE];
2929  
2930 <  if (ypass != 1)
2930 >  if (conf_parser_ctx.pass != 1)
2931      return;
2932  
2933    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2934    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2935                         conffilebuf, lineno + 1, msg, newlinebuf);
2936 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2936 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2937         conffilebuf, lineno + 1, msg, newlinebuf);
2938   }
2939  
3111 – int
3112 – conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb)
3113 – {
3114 –  if (fbgets(lbuf, max_size, fb) == NULL)
3115 –    return 0;
3116 –
3117 –  return strlen(lbuf);
3118 – }
3119 –
3120 – int
3121 – conf_yy_fatal_error(const char *msg)
3122 – {
3123 –  return 0;
3124 – }
3125 –
2940   /*
2941   * valid_tkline()
2942   *
# Line 3134 | Line 2948 | conf_yy_fatal_error(const char *msg)
2948   * Originally written by Dianora (Diane, db@db.net)
2949   */
2950   time_t
2951 < valid_tkline(char *p, int minutes)
2951 > valid_tkline(const char *p, int minutes)
2952   {
2953    time_t result = 0;
2954  
2955 <  while (*p)
2955 >  for (; *p; ++p)
2956    {
2957 <    if (IsDigit(*p))
3144 <    {
3145 <      result *= 10;
3146 <      result += ((*p) & 0xF);
3147 <      p++;
3148 <    }
3149 <    else
2957 >    if (!IsDigit(*p))
2958        return 0;
2959 +
2960 +    result *= 10;
2961 +    result += ((*p) & 0xF);
2962    }
2963  
2964 <  /* in the degenerate case where oper does a /quote kline 0 user@host :reason
2964 >  /*
2965 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
2966     * i.e. they specifically use 0, I am going to return 1 instead
2967     * as a return value of non-zero is used to flag it as a temporary kline
2968     */
3157 –
2969    if (result == 0)
2970      result = 1;
2971  
# Line 3255 | Line 3066 | valid_wild_card(struct Client *source_p,
3066   *                if target_server is NULL and an "ON" is found error
3067   *                is reported.
3068   *                if reason pointer is NULL ignore pointer,
3069 < *                this allows usee of parse_a_line in unkline etc.
3069 > *                this allows use of parse_a_line in unkline etc.
3070   *
3071   * - Dianora
3072   */
# Line 3325 | Line 3136 | parse_aline(const char *cmd, struct Clie
3136          return -1;
3137        }
3138  
3139 <      if (!IsOperRemoteBan(source_p))
3139 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3140        {
3141          sendto_one(source_p, form_str(ERR_NOPRIVS),
3142                     me.name, source_p->name, "remoteban");
# Line 3362 | Line 3173 | parse_aline(const char *cmd, struct Clie
3173        return -1;
3174      }
3175  
3176 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3176 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3177        return -1;
3178    }
3179    else
3180 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3180 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3181        return -1;
3182  
3183    if (reason != NULL)
3184    {
3185 <    if (parc != 0)
3185 >    if (parc != 0 && !EmptyString(*parv))
3186      {
3187        *reason = *parv;
3188 <      if (!valid_comment(source_p, *reason, YES))
3188 >      if (!valid_comment(source_p, *reason, 1))
3189          return -1;
3190      }
3191      else
# Line 3410 | Line 3221 | find_user_host(struct Client *source_p,
3221    {
3222      /* Explicit user@host mask given */
3223  
3224 <    if(hostp != NULL)                            /* I'm a little user@host */
3224 >    if (hostp != NULL)                            /* I'm a little user@host */
3225      {
3226        *(hostp++) = '\0';                       /* short and squat */
3227        if (*user_host_or_nick)
# Line 3505 | Line 3316 | match_conf_password(const char *password
3316   {
3317    const char *encr = NULL;
3318  
3319 <  if (password == NULL || aconf->passwd == NULL)
3319 >  if (EmptyString(password) || EmptyString(aconf->passwd))
3320      return 0;
3321  
3322    if (aconf->flags & CONF_FLAGS_ENCRYPTED)
3323 <  {
3513 <    /* use first two chars of the password they send in as salt */
3514 <    /* If the password in the conf is MD5, and ircd is linked
3515 <     * to scrypt on FreeBSD, or the standard crypt library on
3516 <     * glibc Linux, then this code will work fine on generating
3517 <     * the proper encrypted hash for comparison.
3518 <     */
3519 <    if (*aconf->passwd)
3520 <      encr = crypt(password, aconf->passwd);
3521 <    else
3522 <      encr = "";
3523 <  }
3323 >    encr = crypt(password, aconf->passwd);
3324    else
3325      encr = password;
3326  
# Line 3533 | Line 3333 | match_conf_password(const char *password
3333   * inputs       - client sending the cluster
3334   *              - command name "KLINE" "XLINE" etc.
3335   *              - capab -- CAP_KLN etc. from s_serv.h
3336 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3336 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3337   *              - pattern and args to send along
3338   * output       - none
3339   * side effects - Take source_p send the pattern with args given
# Line 3541 | Line 3341 | match_conf_password(const char *password
3341   */
3342   void
3343   cluster_a_line(struct Client *source_p, const char *command,
3344 <               int capab, int cluster_type, const char *pattern, ...)
3344 >               int capab, int cluster_type, const char *pattern, ...)
3345   {
3346    va_list args;
3347    char buffer[IRCD_BUFSIZE];
3348 <  struct ConfItem *conf;
3549 <  dlink_node *ptr;
3348 >  const dlink_node *ptr = NULL;
3349  
3350    va_start(args, pattern);
3351    vsnprintf(buffer, sizeof(buffer), pattern, args);
# Line 3554 | Line 3353 | cluster_a_line(struct Client *source_p,
3353  
3354    DLINK_FOREACH(ptr, cluster_items.head)
3355    {
3356 <    conf = ptr->data;
3356 >    const struct ConfItem *conf = ptr->data;
3357  
3358      if (conf->flags & cluster_type)
3560 –    {
3359        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
3360                           "%s %s %s", command, conf->name, buffer);
3563 –    }
3361    }
3362   }
3363  
# Line 3592 | Line 3389 | cluster_a_line(struct Client *source_p,
3389   * @                            *       *       *
3390   * !                            *       *       *
3391   */
3595 –
3392   void
3393 < split_nuh(char *mask, char **nick, char **user, char **host)
3393 > split_nuh(struct split_nuh_item *const iptr)
3394   {
3395    char *p = NULL, *q = NULL;
3396  
3397 <  if ((p = strchr(mask, '!')) != NULL)
3397 >  if (iptr->nickptr)
3398 >    strlcpy(iptr->nickptr, "*", iptr->nicksize);
3399 >  if (iptr->userptr)
3400 >    strlcpy(iptr->userptr, "*", iptr->usersize);
3401 >  if (iptr->hostptr)
3402 >    strlcpy(iptr->hostptr, "*", iptr->hostsize);
3403 >
3404 >  if ((p = strchr(iptr->nuhmask, '!')))
3405    {
3406      *p = '\0';
3604 –    if (nick != NULL)
3605 –    {
3606 –      if (*mask != '\0')
3607 –        *nick = xstrldup(mask, NICKLEN);
3608 –      else
3609 –        DupString(*nick, "*");
3610 –    }
3407  
3408 <    if ((q = strchr(++p, '@')) != NULL)
3409 <    {
3410 <      *q = '\0';
3408 >    if (iptr->nickptr && *iptr->nuhmask != '\0')
3409 >      strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3410 >
3411 >    if ((q = strchr(++p, '@'))) {
3412 >      *q++ = '\0';
3413  
3414        if (*p != '\0')
3415 <        *user = xstrldup(p, USERLEN+1);
3618 <      else
3619 <        DupString(*user, "*");
3415 >        strlcpy(iptr->userptr, p, iptr->usersize);
3416  
3417 <      if (*++q != '\0')
3418 <        *host = xstrldup(q, HOSTLEN+1);
3623 <      else
3624 <        DupString(*host, "*");
3417 >      if (*q != '\0')
3418 >        strlcpy(iptr->hostptr, q, iptr->hostsize);
3419      }
3420      else
3421      {
3422        if (*p != '\0')
3423 <        *user = xstrldup(p, USERLEN+1);
3630 <      else
3631 <        DupString(*user, "*");
3632 <
3633 <      DupString(*host, "*");
3423 >        strlcpy(iptr->userptr, p, iptr->usersize);
3424      }
3425    }
3426 <  else  /* No ! found so lets look for a user@host */
3426 >  else
3427    {
3428 <    if ((p = strchr(mask, '@')) != NULL)        /* if found a @ */
3428 >    /* No ! found so lets look for a user@host */
3429 >    if ((p = strchr(iptr->nuhmask, '@')))
3430      {
3431 <      if (nick != NULL)
3432 <        DupString(*nick, "*");
3642 <      *p = '\0';
3431 >      /* if found a @ */
3432 >      *p++ = '\0';
3433  
3434 <      if (*mask != '\0')
3435 <        *user = xstrldup(mask, USERLEN+1);
3646 <      else
3647 <        DupString(*user, "*");
3434 >      if (*iptr->nuhmask != '\0')
3435 >        strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
3436  
3437 <      if (*++p != '\0')
3438 <        *host = xstrldup(p, HOSTLEN+1);
3651 <      else
3652 <        DupString(*host, "*");
3437 >      if (*p != '\0')
3438 >        strlcpy(iptr->hostptr, p, iptr->hostsize);
3439      }
3440 <    else                                        /* no @ found */
3440 >    else
3441      {
3442 <      if (nick != NULL)
3443 <      {
3444 <        if (strpbrk(mask, ".:"))
3659 <        {
3660 <          DupString(*nick, "*");
3661 <          *host = xstrldup(mask, HOSTLEN+1);
3662 <        }
3663 <        else
3664 <        {
3665 <          *nick = xstrldup(mask, NICKLEN);
3666 <          DupString(*host, "*");
3667 <        }
3668 <
3669 <        DupString(*user, "*");
3670 <      }
3442 >      /* no @ found */
3443 >      if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
3444 >        strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
3445        else
3446 <      {
3673 <        DupString(*user, "*");
3674 <        *host = xstrldup(mask, HOSTLEN+1);
3675 <      }
3446 >        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3447      }
3448    }
3449   }
# Line 3699 | Line 3470 | flags_to_ascii(unsigned int flags, const
3470    {
3471      if (flags & mask)
3472        *p++ = bit_table[i];
3473 <    else if(lowerit)
3473 >    else if (lowerit)
3474        *p++ = ToLower(bit_table[i]);
3475    }
3476    *p = '\0';
# Line 3722 | Line 3493 | cidr_limit_reached(int over_rule,
3493    dlink_node *ptr = NULL;
3494    struct CidrItem *cidr;
3495  
3496 <  if (NumberPerCidr(aclass) <= 0)
3496 >  if (aclass->number_per_cidr <= 0)
3497      return 0;
3498  
3499    if (ip->ss.ss_family == AF_INET)
3500    {
3501 <    if (CidrBitlenIPV4(aclass) <= 0)
3501 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3502        return 0;
3503  
3504      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3505      {
3506        cidr = ptr->data;
3507 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3507 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3508        {
3509 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3509 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3510            return -1;
3511          cidr->number_on_this_cidr++;
3512          return 0;
# Line 3744 | Line 3515 | cidr_limit_reached(int over_rule,
3515      cidr = MyMalloc(sizeof(struct CidrItem));
3516      cidr->number_on_this_cidr = 1;
3517      cidr->mask = *ip;
3518 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3518 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3519      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3520    }
3521   #ifdef IPV6
3522 <  else if (CidrBitlenIPV6(aclass) > 0)
3522 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3523    {
3524      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3525      {
3526        cidr = ptr->data;
3527 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3527 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3528        {
3529 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3529 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3530            return -1;
3531          cidr->number_on_this_cidr++;
3532          return 0;
# Line 3764 | Line 3535 | cidr_limit_reached(int over_rule,
3535      cidr = MyMalloc(sizeof(struct CidrItem));
3536      cidr->number_on_this_cidr = 1;
3537      cidr->mask = *ip;
3538 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3538 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3539      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3540    }
3541   #endif
# Line 3786 | Line 3557 | remove_from_cidr_check(struct irc_ssaddr
3557    dlink_node *next_ptr = NULL;
3558    struct CidrItem *cidr;
3559  
3560 <  if (NumberPerCidr(aclass) == 0)
3560 >  if (aclass->number_per_cidr == 0)
3561      return;
3562  
3563    if (ip->ss.ss_family == AF_INET)
3564    {
3565 <    if (CidrBitlenIPV4(aclass) <= 0)
3565 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3566        return;
3567  
3568      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3569      {
3570        cidr = ptr->data;
3571 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3571 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3572        {
3573          cidr->number_on_this_cidr--;
3574          if (cidr->number_on_this_cidr == 0)
# Line 3810 | Line 3581 | remove_from_cidr_check(struct irc_ssaddr
3581      }
3582    }
3583   #ifdef IPV6
3584 <  else if (CidrBitlenIPV6(aclass) > 0)
3584 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3585    {
3586      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3587      {
3588        cidr = ptr->data;
3589 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3589 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3590        {
3591          cidr->number_on_this_cidr--;
3592          if (cidr->number_on_this_cidr == 0)
# Line 3878 | Line 3649 | rebuild_cidr_class(struct ConfItem *conf
3649   {
3650    struct ClassItem *old_class = map_to_conf(conf);
3651  
3652 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3652 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3653    {
3654 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3654 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3655        rebuild_cidr_list(AF_INET, conf, new_class,
3656                          &old_class->list_ipv4, &new_class->list_ipv4,
3657 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3657 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3658  
3659   #ifdef IPV6
3660 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3660 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3661        rebuild_cidr_list(AF_INET6, conf, new_class,
3662                          &old_class->list_ipv6, &new_class->list_ipv6,
3663 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3663 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3664   #endif
3665    }
3666  
# Line 3906 | Line 3677 | rebuild_cidr_class(struct ConfItem *conf
3677   static void
3678   destroy_cidr_list(dlink_list *list)
3679   {
3680 <  dlink_node *ptr = NULL;
3910 <  dlink_node *next_ptr = NULL;
3911 <  struct CidrItem *cidr;
3680 >  dlink_node *ptr = NULL, *next_ptr = NULL;
3681  
3682    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
3683    {
3915 –    cidr = ptr->data;
3684      dlinkDelete(ptr, list);
3685 <    MyFree(cidr);
3685 >    MyFree(ptr->data);
3686    }
3687   }
3688  

Comparing:
ircd-hybrid/src/s_conf.c (property svn:keywords), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid-8/src/conf.c (property svn:keywords), Revision 1390 by michael, Tue May 1 13:39:18 2012 UTC

# Line 1 | Line 1
1 < Revision
1 > Id Revision

Diff Legend

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