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

Comparing:
ircd-hybrid-7.2/src/s_conf.c (file contents), Revision 948 by michael, Tue Jul 21 17:34:06 2009 UTC vs.
ircd-hybrid-8/src/conf.c (file contents), Revision 1495 by michael, Sun Aug 5 09:35:42 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"
32   #include "channel.h"
33   #include "client.h"
33 #include "common.h"
34   #include "event.h"
35 #include "hash.h"
35   #include "hook.h"
36   #include "irc_string.h"
38 #include "sprintf_irc.h"
37   #include "s_bsd.h"
40 #include "irc_getaddrinfo.h"
38   #include "ircd.h"
42 #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"
51 #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 };
64 dlink_list hub_items     = { NULL, NULL, 0 };
65 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 70 | Line 66 | dlink_list rxconf_items  = { NULL, NULL,
66   dlink_list rkconf_items  = { NULL, NULL, 0 };
67   dlink_list nresv_items   = { NULL, NULL, 0 };
68   dlink_list class_items   = { NULL, NULL, 0 };
73 dlink_list gdeny_items   = { NULL, NULL, 0 };
69  
75 dlink_list temporary_klines  = { NULL, NULL, 0 };
76 dlink_list temporary_dlines  = { NULL, NULL, 0 };
70   dlink_list temporary_xlines  = { NULL, NULL, 0 };
78 dlink_list temporary_rklines = { NULL, NULL, 0 };
79 dlink_list temporary_glines  = { NULL, NULL, 0 };
80 dlink_list temporary_rxlines = { NULL, NULL, 0 };
71   dlink_list temporary_resv = { NULL, NULL, 0 };
72  
73   extern unsigned int lineno;
74   extern char linebuf[];
75   extern char conffilebuf[IRCD_BUFSIZE];
86 extern char yytext[];
76   extern int yyparse(); /* defined in y.tab.c */
77 < int ypass = 1; /* used by yyparse()      */
77 >
78 > struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
79  
80   /* internally defined functions */
81 < static void lookup_confhost(struct ConfItem *);
92 < static void set_default_conf(void);
93 < static void validate_conf(void);
94 < static void read_conf(FBFILE *);
81 > static void read_conf(FILE *);
82   static void clear_out_old_conf(void);
83   static void flush_deleted_I_P(void);
84   static void expire_tklines(dlink_list *);
# Line 114 | Line 101 | static void destroy_cidr_class(struct Cl
101  
102   static void flags_to_ascii(unsigned int, const unsigned int[], char *, int);
103  
117 FBFILE *conf_fbfile_in = NULL;
118
104   /* address of default class conf */
105   static struct ConfItem *class_default;
106  
# Line 138 | Line 123 | static BlockHeap *ip_entry_heap = NULL;
123   static int ip_entries_count = 0;
124  
125  
126 < inline void *
126 > void *
127   map_to_conf(struct ConfItem *aconf)
128   {
129    void *conf;
130 <  conf = (void *)((unsigned long)aconf +
131 <                  (unsigned long)sizeof(struct ConfItem));
130 >  conf = (void *)((uintptr_t)aconf +
131 >                  (uintptr_t)sizeof(struct ConfItem));
132    return(conf);
133   }
134  
135 < inline struct ConfItem *
135 > struct ConfItem *
136   unmap_conf_item(void *aconf)
137   {
138    struct ConfItem *conf;
139  
140 <  conf = (struct ConfItem *)((unsigned long)aconf -
141 <                             (unsigned long)sizeof(struct ConfItem));
140 >  conf = (struct ConfItem *)((uintptr_t)aconf -
141 >                             (uintptr_t)sizeof(struct ConfItem));
142    return(conf);
143   }
144  
# Line 168 | Line 153 | unmap_conf_item(void *aconf)
153   * if successful save hp in the conf item it was called with
154   */
155   static void
156 < conf_dns_callback(void *vptr, struct DNSReply *reply)
156 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
157   {
158 <  struct AccessItem *aconf = (struct AccessItem *)vptr;
174 <  struct ConfItem *conf;
158 >  struct AccessItem *aconf = vptr;
159  
160 <  MyFree(aconf->dns_query);
177 <  aconf->dns_query = NULL;
160 >  aconf->dns_pending = 0;
161  
162 <  if (reply != NULL)
163 <    memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr));
164 <  else {
165 <    ilog(L_NOTICE, "Host not found: %s, ignoring connect{} block",
183 <         aconf->host);
184 <    conf = unmap_conf_item(aconf);
185 <    sendto_realops_flags(UMODE_ALL, L_ALL,
186 <                         "Ignoring connect{} block for %s - host not found",
187 <                         conf->name);
188 <    delete_conf_item(conf);
189 <  }
162 >  if (addr != NULL)
163 >    memcpy(&aconf->addr, addr, sizeof(aconf->addr));
164 >  else
165 >    aconf->dns_failed = 1;
166   }
167  
168   /* conf_dns_lookup()
# Line 198 | Line 174 | conf_dns_callback(void *vptr, struct DNS
174   static void
175   conf_dns_lookup(struct AccessItem *aconf)
176   {
177 <  if (aconf->dns_query == NULL)
177 >  if (!aconf->dns_pending)
178    {
179 <    aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
180 <    aconf->dns_query->ptr = aconf;
205 <    aconf->dns_query->callback = conf_dns_callback;
206 <    gethost_byname(aconf->host, aconf->dns_query);
179 >    aconf->dns_pending = 1;
180 >    gethost_byname(conf_dns_callback, aconf, aconf->host);
181    }
182   }
183  
# Line 274 | Line 248 | make_conf_item(ConfType type)
248      aconf->status = status;
249      break;
250  
277  case LEAF_TYPE:
278    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
279                                       sizeof(struct MatchItem));
280    dlinkAdd(conf, &conf->node, &leaf_items);
281    break;
282
283  case HUB_TYPE:
284    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
285                                       sizeof(struct MatchItem));
286    dlinkAdd(conf, &conf->node, &hub_items);
287    break;
288
251    case ULINE_TYPE:
252      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
253                                         sizeof(struct MatchItem));
254      dlinkAdd(conf, &conf->node, &uconf_items);
255      break;
256  
295  case GDENY_TYPE:
296    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
297                                       sizeof(struct AccessItem));
298    dlinkAdd(conf, &conf->node, &gdeny_items);
299    break;
300
257    case XLINE_TYPE:
258      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
259                                         sizeof(struct MatchItem));
260      dlinkAdd(conf, &conf->node, &xconf_items);
261      break;
262 <
262 > #ifdef HAVE_LIBPCRE
263    case RXLINE_TYPE:
264      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
265                                         sizeof(struct MatchItem));
# Line 317 | Line 273 | make_conf_item(ConfType type)
273      aconf->status = CONF_KLINE;
274      dlinkAdd(conf, &conf->node, &rkconf_items);
275      break;
276 <
276 > #endif
277    case CLUSTER_TYPE:
278      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem));
279      dlinkAdd(conf, &conf->node, &cluster_items);
# Line 334 | Line 290 | make_conf_item(ConfType type)
290      dlinkAdd(conf, &conf->node, &nresv_items);
291      break;
292  
293 +  case SERVICE_TYPE:
294 +    status = CONF_SERVICE;
295 +    conf = MyMalloc(sizeof(struct ConfItem));
296 +    dlinkAdd(conf, &conf->node, &service_items);
297 +    break;
298 +
299    case CLASS_TYPE:
300      conf = MyMalloc(sizeof(struct ConfItem) +
301                             sizeof(struct ClassItem));
# Line 341 | Line 303 | make_conf_item(ConfType type)
303  
304      aclass = map_to_conf(conf);
305      aclass->active = 1;
306 <    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
307 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
308 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
309 <    MaxSendq(aclass) = DEFAULT_SENDQ;
306 >    aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
307 >    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
308 >    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
309 >    aclass->max_sendq = DEFAULT_SENDQ;
310  
311      break;
312  
# Line 362 | Line 324 | make_conf_item(ConfType type)
324   void
325   delete_conf_item(struct ConfItem *conf)
326   {
327 <  dlink_node *m = NULL;
327 >  dlink_node *m = NULL, *m_next = NULL;
328    struct MatchItem *match_item;
329    struct AccessItem *aconf;
330    ConfType type = conf->type;
# Line 381 | Line 343 | delete_conf_item(struct ConfItem *conf)
343    case SERVER_TYPE:
344      aconf = map_to_conf(conf);
345  
346 <    if (aconf->dns_query != NULL)
347 <    {
386 <      delete_resolver_queries(aconf->dns_query);
387 <      MyFree(aconf->dns_query);
388 <    }
346 >    if (aconf->dns_pending)
347 >      delete_resolver_queries(aconf);
348      if (aconf->passwd != NULL)
349        memset(aconf->passwd, 0, strlen(aconf->passwd));
350      if (aconf->spasswd != NULL)
# Line 398 | Line 357 | delete_conf_item(struct ConfItem *conf)
357      MyFree(aconf->oper_reason);
358      MyFree(aconf->user);
359      MyFree(aconf->host);
401    MyFree(aconf->fakename);
360   #ifdef HAVE_LIBCRYPTO
361 +    MyFree(aconf->cipher_list);
362 +
363      if (aconf->rsa_public_key)
364        RSA_free(aconf->rsa_public_key);
365      MyFree(aconf->rsa_public_key_file);
# Line 425 | Line 385 | delete_conf_item(struct ConfItem *conf)
385  
386      case SERVER_TYPE:
387        aconf = map_to_conf(conf);
388 +
389 +      DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head)
390 +      {
391 +        MyFree(m->data);
392 +        free_dlink_node(m);
393 +      }
394 +
395 +      DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head)
396 +      {
397 +        MyFree(m->data);
398 +        free_dlink_node(m);  
399 +      }
400 +
401        if (!IsConfIllegal(aconf))
402          dlinkDelete(&conf->node, &server_items);
403        MyFree(conf);
# Line 435 | Line 408 | delete_conf_item(struct ConfItem *conf)
408      }
409      break;
410  
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
411    case ULINE_TYPE:
412      match_item = map_to_conf(conf);
413      MyFree(match_item->user);
# Line 478 | Line 427 | delete_conf_item(struct ConfItem *conf)
427      dlinkDelete(&conf->node, &xconf_items);
428      MyFree(conf);
429      break;
430 <
430 > #ifdef HAVE_LIBPCRE
431    case RKLINE_TYPE:
432      aconf = map_to_conf(conf);
433      MyFree(aconf->regexuser);
# Line 501 | Line 450 | delete_conf_item(struct ConfItem *conf)
450      dlinkDelete(&conf->node, &rxconf_items);
451      MyFree(conf);
452      break;
453 <
453 > #endif
454    case NRESV_TYPE:
455      match_item = map_to_conf(conf);
456      MyFree(match_item->user);
# Line 517 | Line 466 | delete_conf_item(struct ConfItem *conf)
466      MyFree(conf);
467      break;
468  
520  case GDENY_TYPE:
521    aconf = map_to_conf(conf);
522    MyFree(aconf->user);
523    MyFree(aconf->host);
524    dlinkDelete(&conf->node, &gdeny_items);
525    MyFree(conf);
526    break;
527
469    case CLUSTER_TYPE:
470      dlinkDelete(&conf->node, &cluster_items);
471      MyFree(conf);
# Line 543 | Line 484 | delete_conf_item(struct ConfItem *conf)
484      MyFree(conf);
485      break;
486  
487 +  case SERVICE_TYPE:
488 +    dlinkDelete(&conf->node, &service_items);
489 +    MyFree(conf);
490 +    break;
491 +
492    default:
493      break;
494    }
# Line 576 | Line 522 | static const unsigned int shared_bit_tab
522   * side effects -
523   */
524   void
525 < report_confitem_types(struct Client *source_p, ConfType type, int temp)
525 > report_confitem_types(struct Client *source_p, ConfType type)
526   {
527 <  dlink_node *ptr = NULL;
527 >  dlink_node *ptr = NULL, *dptr = NULL;
528    struct ConfItem *conf = NULL;
529    struct AccessItem *aconf = NULL;
530    struct MatchItem *matchitem = NULL;
531    struct ClassItem *classitem = NULL;
532    char buf[12];
533    char *p = NULL;
588  const char *pfx = NULL;
534  
535    switch (type)
536    {
592  case GDENY_TYPE:
593    DLINK_FOREACH(ptr, gdeny_items.head)
594    {
595      conf = ptr->data;
596      aconf = map_to_conf(conf);
597
598      p = buf;
599
600      if (aconf->flags & GDENY_BLOCK)
601        *p++ = 'B';
602      else
603        *p++ = 'b';
604
605      if (aconf->flags & GDENY_REJECT)
606        *p++ = 'R';
607      else
608        *p++ = 'r';
609
610      *p = '\0';
611
612      sendto_one(source_p, ":%s %d %s V %s@%s %s %s",
613                 me.name, RPL_STATSDEBUG, source_p->name,
614                 aconf->user, aconf->host, conf->name, buf);
615    }
616    break;
617
537    case XLINE_TYPE:
538      DLINK_FOREACH(ptr, xconf_items.head)
539      {
# Line 628 | Line 547 | report_confitem_types(struct Client *sou
547      }
548      break;
549  
550 + #ifdef HAVE_LIBPCRE
551    case RXLINE_TYPE:
552      DLINK_FOREACH(ptr, rxconf_items.head)
553      {
# Line 636 | Line 556 | report_confitem_types(struct Client *sou
556  
557        sendto_one(source_p, form_str(RPL_STATSXLINE),
558                   me.name, source_p->name,
559 <                 matchitem->hold ? "xR": "XR", matchitem->count,
559 >                 "XR", matchitem->count,
560                   conf->name, matchitem->reason);
561      }
562      break;
563  
564    case RKLINE_TYPE:
645    pfx = temp ? "kR" : "KR";
646
565      DLINK_FOREACH(ptr, rkconf_items.head)
566      {
567        aconf = map_to_conf((conf = ptr->data));
568  
651      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
652        continue;
653
569        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
570 <                 source_p->name, pfx, aconf->host, aconf->user,
570 >                 source_p->name, "KR", aconf->host, aconf->user,
571                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
572      }
573      break;
574 + #endif
575  
576    case ULINE_TYPE:
577      DLINK_FOREACH(ptr, uconf_items.head)
# Line 700 | Line 616 | report_confitem_types(struct Client *sou
616        aconf = map_to_conf(conf);
617  
618        /* Don't allow non opers to see oper privs */
619 <      if (IsOper(source_p))
619 >      if (HasUMode(source_p, UMODE_OPER))
620          sendto_one(source_p, form_str(RPL_STATSOLINE),
621                     me.name, source_p->name, 'O', aconf->user, aconf->host,
622                     conf->name, oper_privs_as_string(aconf->port),
# Line 720 | Line 636 | report_confitem_types(struct Client *sou
636        classitem = map_to_conf(conf);
637        sendto_one(source_p, form_str(RPL_STATSYLINE),
638                   me.name, source_p->name, 'Y',
639 <                 conf->name, PingFreq(classitem),
640 <                 ConFreq(classitem),
641 <                 MaxTotal(classitem), MaxSendq(classitem),
642 <                 CurrUserCount(classitem),
639 >                 conf->name, classitem->ping_freq,
640 >                 classitem->con_freq,
641 >                 classitem->max_total, classitem->max_sendq,
642 >                 classitem->curr_user_count,
643 >                 classitem->number_per_cidr, classitem->cidr_bitlen_ipv4,
644 >                 classitem->number_per_cidr, classitem->cidr_bitlen_ipv6,
645                   classitem->active ? "active" : "disabled");
646      }
647      break;
# Line 732 | Line 650 | report_confitem_types(struct Client *sou
650    case CLIENT_TYPE:
651      break;
652  
653 +  case SERVICE_TYPE:
654 +    DLINK_FOREACH(ptr, service_items.head)
655 +    {
656 +      conf = ptr->data;
657 +      sendto_one(source_p, form_str(RPL_STATSSERVICE),
658 +                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
659 +    }
660 +    break;
661 +
662    case SERVER_TYPE:
663      DLINK_FOREACH(ptr, server_items.head)
664      {
# Line 744 | Line 671 | report_confitem_types(struct Client *sou
671  
672        if (IsConfAllowAutoConn(aconf))
673          *p++ = 'A';
674 <      if (IsConfCryptLink(aconf))
675 <        *p++ = 'C';
749 <      if (aconf->fakename)
750 <        *p++ = 'M';
674 >      if (IsConfSSL(aconf))
675 >        *p++ = 'S';
676        if (IsConfTopicBurst(aconf))
677          *p++ = 'T';
753      if (IsConfCompressed(aconf))
754        *p++ = 'Z';
678        if (buf[0] == '\0')
679          *p++ = '*';
680  
# Line 760 | Line 683 | report_confitem_types(struct Client *sou
683        /*
684         * Allow admins to see actual ips unless hide_server_ips is enabled
685         */
686 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
686 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
687          sendto_one(source_p, form_str(RPL_STATSCLINE),
688                     me.name, source_p->name, 'C', aconf->host,
689                     buf, conf->name, aconf->port,
# Line 774 | Line 697 | report_confitem_types(struct Client *sou
697      break;
698  
699    case HUB_TYPE:
700 <    DLINK_FOREACH(ptr, hub_items.head)
700 >    DLINK_FOREACH(ptr, server_items.head)
701      {
702        conf = ptr->data;
703 <      matchitem = map_to_conf(conf);
704 <      sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
705 <                 source_p->name, 'H', matchitem->host, conf->name, 0, "*");
703 >      aconf = map_to_conf(conf);
704 >
705 >      DLINK_FOREACH(dptr, aconf->hub_list.head)
706 >        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
707 >                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
708      }
709      break;
710  
711    case LEAF_TYPE:
712 <    DLINK_FOREACH(ptr, leaf_items.head)
712 >    DLINK_FOREACH(ptr, server_items.head)
713      {
714        conf = ptr->data;
715 <      matchitem = map_to_conf(conf);
716 <      sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
717 <                 source_p->name, 'L', matchitem->host, conf->name, 0, "*");
715 >      aconf = map_to_conf(conf);
716 >
717 >      DLINK_FOREACH(dptr, aconf->leaf_list.head)
718 >        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
719 >                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
720      }
721      break;
722  
# Line 800 | Line 727 | report_confitem_types(struct Client *sou
727    case CRESV_TYPE:
728    case NRESV_TYPE:
729    case CLUSTER_TYPE:
730 +  default:
731      break;
732    }
733   }
# Line 826 | Line 754 | check_client(va_list args)
754  
755    /* I'm already in big trouble if source_p->localClient is NULL -db */
756    if ((i = verify_access(source_p, username)))
757 <    ilog(L_INFO, "Access denied: %s[%s]",
757 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
758           source_p->name, source_p->sockhost);
759  
760    switch (i)
# Line 836 | Line 764 | check_client(va_list args)
764                             "Too many on IP for %s (%s).",
765                             get_client_name(source_p, SHOW_IP),
766                             source_p->sockhost);
767 <      ilog(L_INFO,"Too many connections on IP from %s.",
767 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
768             get_client_name(source_p, SHOW_IP));
769        ++ServerStats.is_ref;
770        exit_client(source_p, &me, "No more connections allowed on that IP");
# Line 847 | Line 775 | check_client(va_list args)
775                             "I-line is full for %s (%s).",
776                             get_client_name(source_p, SHOW_IP),
777                             source_p->sockhost);
778 <      ilog(L_INFO,"Too many connections from %s.",
778 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
779             get_client_name(source_p, SHOW_IP));
780        ++ServerStats.is_ref;
781        exit_client(source_p, &me,
# Line 864 | Line 792 | check_client(va_list args)
792                             source_p->sockhost,
793                             source_p->localClient->listener->name,
794                             source_p->localClient->listener->port);
795 <      ilog(L_INFO,
795 >      ilog(LOG_TYPE_IRCD,
796            "Unauthorized client connection from %s on [%s/%u].",
797            get_client_name(source_p, SHOW_IP),
798            source_p->localClient->listener->name,
# Line 1027 | Line 955 | attach_iline(struct Client *client_p, st
955     * setting a_limit_reached if any limit is reached.
956     * - Dianora
957     */
958 <  if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
958 >  if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
959      a_limit_reached = 1;
960 <  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
960 >  else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
961      a_limit_reached = 1;
962 <  else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
962 >  else if (aclass->max_local != 0 && local >= aclass->max_local)
963      a_limit_reached = 1;
964 <  else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))
964 >  else if (aclass->max_global != 0 && global >= aclass->max_global)
965      a_limit_reached = 1;
966 <  else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&
966 >  else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
967             client_p->username[0] != '~')
968      a_limit_reached = 1;
969  
# Line 1191 | Line 1119 | hash_ip(struct irc_ssaddr *addr)
1119    {
1120      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
1121      int hash;
1122 <    u_int32_t ip;
1122 >    uint32_t ip;
1123  
1124      ip   = ntohl(v4->sin_addr.s_addr);
1125      hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
# Line 1202 | Line 1130 | hash_ip(struct irc_ssaddr *addr)
1130    {
1131      int hash;
1132      struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
1133 <    u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr;
1133 >    uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
1134  
1135      hash  = ip[0] ^ ip[3];
1136      hash ^= hash >> 16;  
# Line 1318 | Line 1246 | detach_conf(struct Client *client_p, Con
1246  
1247          assert(aconf->clients > 0);
1248  
1249 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1249 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1250          {
1251            aclass = map_to_conf(aclass_conf);
1252  
# Line 1334 | Line 1262 | detach_conf(struct Client *client_p, Con
1262            delete_conf_item(conf);
1263  
1264          break;
1337
1338      case LEAF_TYPE:
1339      case HUB_TYPE:
1340        match_item = map_to_conf(conf);
1341        if (match_item->ref_count == 0 && match_item->illegal)
1342          delete_conf_item(conf);
1343        break;
1265        default:
1266          break;
1267        }
# Line 1366 | Line 1287 | detach_conf(struct Client *client_p, Con
1287   int
1288   attach_conf(struct Client *client_p, struct ConfItem *conf)
1289   {
1290 +  struct AccessItem *aconf = map_to_conf(conf);
1291 +  struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1292 +
1293    if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
1294      return 1;
1295  
1296 <  if (conf->type == CLIENT_TYPE ||
1297 <      conf->type == SERVER_TYPE ||
1374 <      conf->type == OPER_TYPE)
1375 <  {
1376 <    struct AccessItem *aconf = map_to_conf(conf);
1377 <    struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1296 >  if (IsConfIllegal(aconf)) /* TBV: can't happen */
1297 >    return NOT_AUTHORIZED;
1298  
1299 <    if (IsConfIllegal(aconf))
1300 <      return NOT_AUTHORIZED;
1299 >  if (conf->type == CLIENT_TYPE)
1300 >    if (cidr_limit_reached(IsConfExemptLimits(aconf),
1301 >                           &client_p->localClient->ip, aclass))
1302 >      return TOO_MANY;    /* Already at maximum allowed */
1303  
1304 <    if (conf->type == CLIENT_TYPE)
1305 <      if (cidr_limit_reached(IsConfExemptLimits(aconf),
1384 <                             &client_p->localClient->ip, aclass))
1385 <        return TOO_MANY;    /* Already at maximum allowed */
1386 <
1387 <    CurrUserCount(aclass)++;
1388 <    aconf->clients++;
1389 <  }
1390 <  else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
1391 <  {
1392 <    struct MatchItem *match_item = map_to_conf(conf);
1393 <    match_item->ref_count++;
1394 <  }
1304 >  aclass->curr_user_count++;
1305 >  aconf->clients++;
1306  
1307    dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
1308  
# Line 1480 | Line 1391 | find_conf_exact(ConfType type, const cha
1391      {
1392        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1393  
1394 <      if (aconf->clients >= MaxTotal(aclass))
1394 >      if (aconf->clients >= aclass->max_total)
1395          continue;
1396      }
1397  
# Line 1552 | Line 1463 | map_to_list(ConfType type)
1463    case SERVER_TYPE:
1464      return(&server_items);
1465      break;
1466 +  case SERVICE_TYPE:
1467 +    return(&service_items);
1468 +    break;
1469    case CLUSTER_TYPE:
1470      return(&cluster_items);
1471      break;
# Line 1587 | Line 1501 | find_matching_name_conf(ConfType type, c
1501  
1502    switch (type)
1503    {
1504 <    case RXLINE_TYPE:
1504 > #ifdef HAVE_LIBPCRE
1505 >  case RXLINE_TYPE:
1506        DLINK_FOREACH(ptr, list_p->head)
1507        {
1508          conf = ptr->data;
# Line 1597 | Line 1512 | find_matching_name_conf(ConfType type, c
1512            return conf;
1513        }
1514        break;
1515 + #endif
1516 +  case SERVICE_TYPE:
1517 +    DLINK_FOREACH(ptr, list_p->head)
1518 +    {
1519 +      conf = ptr->data;
1520 +
1521 +      if (EmptyString(conf->name))
1522 +        continue;
1523 +      if ((name != NULL) && !irccmp(name, conf->name))
1524 +        return conf;
1525 +    }
1526 +    break;
1527  
1528    case XLINE_TYPE:
1529    case ULINE_TYPE:
# Line 1651 | Line 1578 | find_matching_name_conf(ConfType type, c
1578   * side effects - looks for an exact match on name field
1579   */
1580   struct ConfItem *
1581 < find_exact_name_conf(ConfType type, const char *name,
1581 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1582                       const char *user, const char *host)
1583   {
1584    dlink_node *ptr = NULL;
# Line 1692 | Line 1619 | find_exact_name_conf(ConfType type, cons
1619      DLINK_FOREACH(ptr, list_p->head)
1620      {
1621        conf = ptr->data;
1622 <      aconf = (struct AccessItem *)map_to_conf(conf);
1622 >      aconf = map_to_conf(conf);
1623 >
1624        if (EmptyString(conf->name))
1625 <        continue;
1626 <    
1627 <      if (irccmp(conf->name, name) == 0)
1625 >        continue;
1626 >
1627 >      if (!irccmp(conf->name, name))
1628        {
1629 <        if ((user == NULL && (host == NULL)))
1630 <          return (conf);
1631 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1632 <          return (conf);
1633 <        if (match(aconf->user, user) && match(aconf->host, host))
1634 <          return (conf);
1629 >        if (!who)
1630 >          return conf;
1631 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1632 >          return conf;
1633 >        if (match(aconf->user, who->username))
1634 >        {
1635 >          switch (aconf->type)
1636 >          {
1637 >            case HM_HOST:
1638 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1639 >                return conf;
1640 >              break;
1641 >            case HM_IPV4:
1642 >              if (who->localClient->aftype == AF_INET)
1643 >                if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits))
1644 >                  return conf;
1645 >              break;
1646 > #ifdef IPV6
1647 >            case HM_IPV6:
1648 >              if (who->localClient->aftype == AF_INET6)
1649 >                if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits))
1650 >                  return conf;
1651 >              break;
1652 > #endif
1653 >            default:
1654 >              assert(0);
1655 >          }
1656 >        }
1657        }
1658      }
1659 +
1660      break;
1661  
1662    case SERVER_TYPE:
# Line 1761 | Line 1712 | rehash(int sig)
1712      sendto_realops_flags(UMODE_ALL, L_ALL,
1713                           "Got signal SIGHUP, reloading ircd.conf file");
1714  
1764 #ifndef _WIN32
1715    restart_resolver();
1716 < #endif
1716 >
1717    /* don't close listeners until we know we can go ahead with the rehash */
1718  
1719    /* Check to see if we magically got(or lost) IPv6 support */
# Line 1774 | Line 1724 | rehash(int sig)
1724    if (ServerInfo.description != NULL)
1725      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1726  
1777 #ifndef STATIC_MODULES
1727    load_conf_modules();
1779 #endif
1728  
1729    flush_deleted_I_P();
1730  
1731    rehashed_klines = 1;
1732 <
1732 > /* XXX */
1733    if (ConfigLoggingEntry.use_logging)
1734 <    reopen_log(logFileName);
1734 >    log_close_all();
1735  
1736    return(0);
1737   }
# Line 1822 | Line 1770 | set_default_conf(void)
1770    ServerInfo.specific_ipv6_vhost = 0;
1771  
1772    ServerInfo.max_clients = MAXCLIENTS_MAX;
1773 <  /* Don't reset hub, as that will break lazylinks */
1774 <  /* ServerInfo.hub = NO; */
1773 >
1774 >  ServerInfo.hub = 0;
1775    ServerInfo.dns_host.sin_addr.s_addr = 0;
1776    ServerInfo.dns_host.sin_port = 0;
1777    AdminInfo.name = NULL;
1778    AdminInfo.email = NULL;
1779    AdminInfo.description = NULL;
1780  
1781 <  set_log_level(L_NOTICE);
1781 >  log_close_all();
1782 >
1783    ConfigLoggingEntry.use_logging = 1;
1784 <  ConfigLoggingEntry.operlog[0] = '\0';
1785 <  ConfigLoggingEntry.userlog[0] = '\0';
1786 <  ConfigLoggingEntry.klinelog[0] = '\0';
1838 <  ConfigLoggingEntry.glinelog[0] = '\0';
1839 <  ConfigLoggingEntry.killlog[0] = '\0';
1840 <  ConfigLoggingEntry.operspylog[0] = '\0';
1841 <  ConfigLoggingEntry.ioerrlog[0] = '\0';
1842 <  ConfigLoggingEntry.failed_operlog[0] = '\0';
1843 <
1844 <  ConfigChannel.disable_fake_channels = NO;
1845 <  ConfigChannel.restrict_channels = NO;
1846 <  ConfigChannel.disable_local_channels = NO;
1847 <  ConfigChannel.use_invex = YES;
1848 <  ConfigChannel.use_except = YES;
1849 <  ConfigChannel.use_knock = YES;
1784 >
1785 >  ConfigChannel.disable_fake_channels = 0;
1786 >  ConfigChannel.restrict_channels = 0;
1787    ConfigChannel.knock_delay = 300;
1788    ConfigChannel.knock_delay_channel = 60;
1789 <  ConfigChannel.max_chans_per_user = 15;
1790 <  ConfigChannel.quiet_on_ban = YES;
1789 >  ConfigChannel.max_chans_per_user = 25;
1790 >  ConfigChannel.max_chans_per_oper = 50;
1791 >  ConfigChannel.quiet_on_ban = 1;
1792    ConfigChannel.max_bans = 25;
1793    ConfigChannel.default_split_user_count = 0;
1794    ConfigChannel.default_split_server_count = 0;
1795 <  ConfigChannel.no_join_on_split = NO;
1796 <  ConfigChannel.no_create_on_split = NO;
1859 <  ConfigChannel.burst_topicwho = YES;
1795 >  ConfigChannel.no_join_on_split = 0;
1796 >  ConfigChannel.no_create_on_split = 0;
1797  
1798 <  ConfigServerHide.flatten_links = NO;
1798 >  ConfigServerHide.flatten_links = 0;
1799    ConfigServerHide.links_delay = 300;
1800 <  ConfigServerHide.hidden = NO;
1801 <  ConfigServerHide.disable_hidden = NO;
1865 <  ConfigServerHide.hide_servers = NO;
1800 >  ConfigServerHide.hidden = 0;
1801 >  ConfigServerHide.hide_servers = 0;
1802    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1803 <  ConfigServerHide.hide_server_ips = NO;
1803 >  ConfigServerHide.hide_server_ips = 0;
1804  
1805    
1806 +  DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1807    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1808 +  ConfigFileEntry.glines = 0;
1809 +  ConfigFileEntry.gline_time = 12 * 3600;
1810 +  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
1811    ConfigFileEntry.gline_min_cidr = 16;
1812    ConfigFileEntry.gline_min_cidr6 = 48;
1813 <  ConfigFileEntry.invisible_on_connect = YES;
1814 <  ConfigFileEntry.burst_away = NO;
1815 <  ConfigFileEntry.use_whois_actually = YES;
1816 <  ConfigFileEntry.tkline_expire_notices = YES;
1817 <  ConfigFileEntry.hide_spoof_ips = YES;
1818 <  ConfigFileEntry.ignore_bogus_ts = NO;
1819 <  ConfigFileEntry.disable_auth = NO;
1820 <  ConfigFileEntry.disable_remote = NO;
1813 >  ConfigFileEntry.invisible_on_connect = 1;
1814 >  ConfigFileEntry.burst_away = 0;
1815 >  ConfigFileEntry.use_whois_actually = 1;
1816 >  ConfigFileEntry.tkline_expire_notices = 1;
1817 >  ConfigFileEntry.hide_spoof_ips = 1;
1818 >  ConfigFileEntry.ignore_bogus_ts = 0;
1819 >  ConfigFileEntry.disable_auth = 0;
1820 >  ConfigFileEntry.disable_remote = 0;
1821    ConfigFileEntry.kill_chase_time_limit = 90;
1822 <  ConfigFileEntry.default_floodcount = 8; /* XXX */
1823 <  ConfigFileEntry.failed_oper_notice = YES;
1824 <  ConfigFileEntry.dots_in_ident = 0;      /* XXX */
1885 <  ConfigFileEntry.dot_in_ip6_addr = YES;
1822 >  ConfigFileEntry.default_floodcount = 8;
1823 >  ConfigFileEntry.failed_oper_notice = 1;
1824 >  ConfigFileEntry.dots_in_ident = 0;
1825    ConfigFileEntry.min_nonwildcard = 4;
1826    ConfigFileEntry.min_nonwildcard_simple = 3;
1827    ConfigFileEntry.max_accept = 20;
1828 <  ConfigFileEntry.anti_nick_flood = NO;   /* XXX */
1828 >  ConfigFileEntry.anti_nick_flood = 0;
1829    ConfigFileEntry.max_nick_time = 20;
1830    ConfigFileEntry.max_nick_changes = 5;
1831 <  ConfigFileEntry.anti_spam_exit_message_time = 0;  /* XXX */
1831 >  ConfigFileEntry.anti_spam_exit_message_time = 0;
1832    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1833 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;  /* XXX */
1834 <  ConfigFileEntry.kline_with_reason = YES;
1833 >  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1834 >  ConfigFileEntry.kline_with_reason = 1;
1835    ConfigFileEntry.kline_reason = NULL;
1836 <  ConfigFileEntry.warn_no_nline = YES;
1837 <  ConfigFileEntry.stats_o_oper_only = NO; /* XXX */
1836 >  ConfigFileEntry.warn_no_nline = 1;
1837 >  ConfigFileEntry.stats_o_oper_only = 0;
1838    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1839    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1840 <  ConfigFileEntry.stats_P_oper_only = NO;
1840 >  ConfigFileEntry.stats_P_oper_only = 0;
1841    ConfigFileEntry.caller_id_wait = 60;
1842 <  ConfigFileEntry.opers_bypass_callerid = NO;
1842 >  ConfigFileEntry.opers_bypass_callerid = 0;
1843    ConfigFileEntry.pace_wait = 10;
1844    ConfigFileEntry.pace_wait_simple = 1;
1845 <  ConfigFileEntry.short_motd = NO;
1846 <  ConfigFileEntry.ping_cookie = NO;
1847 <  ConfigFileEntry.no_oper_flood = NO;     /* XXX */
1848 <  ConfigFileEntry.true_no_oper_flood = NO;  /* XXX */
1849 <  ConfigFileEntry.oper_pass_resv = YES;
1911 <  ConfigFileEntry.glines = NO;            /* XXX */
1912 <  ConfigFileEntry.gline_time = 12 * 3600; /* XXX */
1913 <  ConfigFileEntry.idletime = 0;
1845 >  ConfigFileEntry.short_motd = 0;
1846 >  ConfigFileEntry.ping_cookie = 0;
1847 >  ConfigFileEntry.no_oper_flood = 0;
1848 >  ConfigFileEntry.true_no_oper_flood = 0;
1849 >  ConfigFileEntry.oper_pass_resv = 1;
1850    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1851    ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1852 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;  /* XXX */
1852 >  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1853    ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1854 <    UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1855 <  DupString(ConfigFileEntry.servlink_path, SLPATH);
1920 < #ifdef HAVE_LIBCRYPTO
1921 <  /* jdc -- This is our default value for a cipher.  According to the
1922 <   *        CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
1923 <   *        under all circumstances if cryptlinks are enabled.  So,
1924 <   *        this will be our default.
1925 <   *
1926 <   *        NOTE: I apologise for the hard-coded value of "1" (BF/128).
1927 <   *              This should be moved into a find_cipher() routine.
1928 <   */
1929 <  ConfigFileEntry.default_cipher_preference = &CipherTable[1];
1930 < #endif
1931 <  ConfigFileEntry.use_egd = NO;
1854 >    UMODE_OPERWALL | UMODE_WALLOP;
1855 >  ConfigFileEntry.use_egd = 0;
1856    ConfigFileEntry.egdpool_path = NULL;
1933 #ifdef HAVE_LIBZ
1934  ConfigFileEntry.compression_level = 0;
1935 #endif
1857    ConfigFileEntry.throttle_time = 10;
1858   }
1859  
1939 /* read_conf()
1940 *
1941 * inputs       - file descriptor pointing to config file to use
1942 * output       - None
1943 * side effects - Read configuration file.
1944 */
1945 static void
1946 read_conf(FBFILE *file)
1947 {
1948  lineno = 0;
1949
1950  set_default_conf(); /* Set default values prior to conf parsing */
1951  ypass = 1;
1952  yyparse();          /* pick up the classes first */
1953
1954  fbrewind(file);
1955
1956  ypass = 2;
1957  yyparse();          /* Load the values from the conf */
1958  validate_conf();    /* Check to make sure some values are still okay. */
1959                      /* Some global values are also loaded here. */
1960  check_class();      /* Make sure classes are valid */
1961 }
1962
1860   static void
1861   validate_conf(void)
1862   {
# Line 1969 | Line 1866 | validate_conf(void)
1866    if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1867      ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1868  
1972  if (ConfigFileEntry.servlink_path == NULL)
1973    DupString(ConfigFileEntry.servlink_path, SLPATH);
1974
1869    if (ServerInfo.network_name == NULL)
1870      DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1871  
1872    if (ServerInfo.network_desc == NULL)
1873      DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1874  
1875 +  if (ConfigFileEntry.service_name == NULL)
1876 +    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1877 +
1878    if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
1879        (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
1880      ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
# Line 1985 | Line 1882 | validate_conf(void)
1882    ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1883   }
1884  
1885 + /* read_conf()
1886 + *
1887 + * inputs       - file descriptor pointing to config file to use
1888 + * output       - None
1889 + * side effects - Read configuration file.
1890 + */
1891 + static void
1892 + read_conf(FILE *file)
1893 + {
1894 +  lineno = 0;
1895 +
1896 +  set_default_conf(); /* Set default values prior to conf parsing */
1897 +  conf_parser_ctx.pass = 1;
1898 +  yyparse();          /* pick up the classes first */
1899 +
1900 +  rewind(file);
1901 +
1902 +  conf_parser_ctx.pass = 2;
1903 +  yyparse();          /* Load the values from the conf */
1904 +  validate_conf();    /* Check to make sure some values are still okay. */
1905 +                      /* Some global values are also loaded here. */
1906 +  check_class();      /* Make sure classes are valid */
1907 + }
1908 +
1909   /* lookup_confhost()
1910   *
1911   * start DNS lookups of all hostnames in the conf
# Line 1998 | Line 1919 | lookup_confhost(struct ConfItem *conf)
1919  
1920    aconf = map_to_conf(conf);
1921  
1922 <  if (EmptyString(aconf->host) ||
2002 <      EmptyString(aconf->user))
1922 >  if (has_wildcards(aconf->host))
1923    {
1924 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
1924 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
1925           aconf->host, conf->name);
1926      return;
1927    }
1928  
2009  if (strchr(aconf->host, '*') ||
2010      strchr(aconf->host, '?'))
2011    return;
2012
1929    /* Do name lookup now on hostnames given and store the
1930     * ip numbers in conf structure.
1931     */
# Line 2021 | Line 1937 | lookup_confhost(struct ConfItem *conf)
1937    /* Get us ready for a bind() and don't bother doing dns lookup */
1938    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1939  
1940 <  if (irc_getaddrinfo(aconf->host, NULL, &hints, &res))
1940 >  if (getaddrinfo(aconf->host, NULL, &hints, &res))
1941    {
1942      conf_dns_lookup(aconf);
1943      return;
# Line 2029 | Line 1945 | lookup_confhost(struct ConfItem *conf)
1945  
1946    assert(res != NULL);
1947  
1948 <  memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
1949 <  aconf->ipnum.ss_len = res->ai_addrlen;
1950 <  aconf->ipnum.ss.ss_family = res->ai_family;
1951 <  irc_freeaddrinfo(res);
1948 >  memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen);
1949 >  aconf->addr.ss_len = res->ai_addrlen;
1950 >  aconf->addr.ss.ss_family = res->ai_family;
1951 >  freeaddrinfo(res);
1952   }
1953  
1954   /* conf_connect_allowed()
# Line 2071 | Line 1987 | conf_connect_allowed(struct irc_ssaddr *
1987   static struct AccessItem *
1988   find_regexp_kline(const char *uhi[])
1989   {
1990 + #ifdef HAVE_LIBPCRE
1991    const dlink_node *ptr = NULL;
1992  
1993    DLINK_FOREACH(ptr, rkconf_items.head)
# Line 2085 | Line 2002 | find_regexp_kline(const char *uhi[])
2002           !ircd_pcre_exec(aptr->regexhost, uhi[2])))
2003        return aptr;
2004    }
2005 <
2005 > #endif
2006    return NULL;
2007   }
2008  
# Line 2108 | Line 2025 | find_kill(struct Client *client_p)
2025  
2026    assert(client_p != NULL);
2027  
2028 <  aconf = find_kline_conf(client_p->host, client_p->username,
2029 <                          &client_p->localClient->ip,
2030 <                          client_p->localClient->aftype);
2028 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2029 >                               CONF_KLINE, client_p->localClient->aftype,
2030 >                               client_p->username, NULL, 1);
2031    if (aconf == NULL)
2032      aconf = find_regexp_kline(uhi);
2033  
2034 <  if (aconf && (aconf->status & CONF_KLINE))
2118 <    return aconf;
2119 <
2120 <  return NULL;
2034 >  return aconf;
2035   }
2036  
2037   struct AccessItem *
# Line 2127 | Line 2041 | find_gline(struct Client *client_p)
2041  
2042    assert(client_p != NULL);
2043  
2044 <  aconf = find_gline_conf(client_p->host, client_p->username,
2045 <                          &client_p->localClient->ip,
2046 <                          client_p->localClient->aftype);
2047 <
2134 <  if (aconf && (aconf->status & CONF_GLINE))
2135 <    return aconf;
2136 <
2137 <  return NULL;
2044 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2045 >                               CONF_GLINE, client_p->localClient->aftype,
2046 >                               client_p->username, NULL, 1);
2047 >  return aconf;
2048   }
2049  
2050   /* add_temp_line()
# Line 2147 | Line 2057 | find_gline(struct Client *client_p)
2057   void
2058   add_temp_line(struct ConfItem *conf)
2059   {
2060 <  struct AccessItem *aconf;
2151 <
2152 <  if (conf->type == DLINE_TYPE)
2153 <  {
2154 <    aconf = map_to_conf(conf);
2155 <    SetConfTemporary(aconf);
2156 <    dlinkAdd(conf, &conf->node, &temporary_dlines);
2157 <    MyFree(aconf->user);
2158 <    aconf->user = NULL;
2159 <    add_conf_by_address(CONF_DLINE, aconf);
2160 <  }
2161 <  else if (conf->type == KLINE_TYPE)
2162 <  {
2163 <    aconf = map_to_conf(conf);
2164 <    SetConfTemporary(aconf);
2165 <    dlinkAdd(conf, &conf->node, &temporary_klines);
2166 <    add_conf_by_address(CONF_KILL, aconf);
2167 <  }
2168 <  else if (conf->type == GLINE_TYPE)
2169 <  {
2170 <    aconf = map_to_conf(conf);
2171 <    SetConfTemporary(aconf);
2172 <    dlinkAdd(conf, &conf->node, &temporary_glines);
2173 <    add_conf_by_address(CONF_GLINE, aconf);
2174 <  }
2175 <  else if (conf->type == XLINE_TYPE)
2060 >  if (conf->type == XLINE_TYPE)
2061    {
2062      conf->flags |= CONF_FLAGS_TEMPORARY;
2063      dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2064    }
2180  else if (conf->type == RXLINE_TYPE)
2181  {
2182    conf->flags |= CONF_FLAGS_TEMPORARY;
2183    dlinkAdd(conf, make_dlink_node(), &temporary_rxlines);
2184  }
2185  else if (conf->type == RKLINE_TYPE)
2186  {
2187    conf->flags |= CONF_FLAGS_TEMPORARY;
2188    dlinkAdd(conf, make_dlink_node(), &temporary_rklines);
2189  }
2065    else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2066    {
2067      conf->flags |= CONF_FLAGS_TEMPORARY;
# Line 2204 | Line 2079 | add_temp_line(struct ConfItem *conf)
2079   void
2080   cleanup_tklines(void *notused)
2081   {
2082 <  expire_tklines(&temporary_glines);
2208 <  expire_tklines(&temporary_klines);
2209 <  expire_tklines(&temporary_dlines);
2082 >  hostmask_expire_temporary();
2083    expire_tklines(&temporary_xlines);
2211  expire_tklines(&temporary_rxlines);
2212  expire_tklines(&temporary_rklines);
2084    expire_tklines(&temporary_resv);
2085   }
2086  
# Line 2227 | Line 2098 | expire_tklines(dlink_list *tklist)
2098    struct ConfItem *conf;
2099    struct MatchItem *xconf;
2100    struct MatchItem *nconf;
2230  struct AccessItem *aconf;
2101    struct ResvChannel *cconf;
2102  
2103    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2104    {
2105      conf = ptr->data;
2236    if (conf->type == GLINE_TYPE ||
2237        conf->type == KLINE_TYPE ||
2238        conf->type == DLINE_TYPE)
2239    {
2240      aconf = (struct AccessItem *)map_to_conf(conf);
2241      if (aconf->hold <= CurrentTime)
2242      {
2243        /* XXX - Do we want GLINE expiry notices?? */
2244        /* Alert opers that a TKline expired - Hwy */
2245        if (ConfigFileEntry.tkline_expire_notices)
2246        {
2247          if (aconf->status & CONF_KILL)
2248          {
2249            sendto_realops_flags(UMODE_ALL, L_ALL,
2250                                 "Temporary K-line for [%s@%s] expired",
2251                                 (aconf->user) ? aconf->user : "*",
2252                                 (aconf->host) ? aconf->host : "*");
2253          }
2254          else if (conf->type == DLINE_TYPE)
2255          {
2256            sendto_realops_flags(UMODE_ALL, L_ALL,
2257                                 "Temporary D-line for [%s] expired",
2258                                 (aconf->host) ? aconf->host : "*");
2259          }
2260        }
2106  
2107 <        dlinkDelete(ptr, tklist);
2263 <        delete_one_address_conf(aconf->host, aconf);
2264 <      }
2265 <    }
2266 <    else if (conf->type == XLINE_TYPE ||
2267 <             conf->type == RXLINE_TYPE)
2107 >    if (conf->type == XLINE_TYPE)
2108      {
2109        xconf = (struct MatchItem *)map_to_conf(conf);
2110        if (xconf->hold <= CurrentTime)
2111        {
2112          if (ConfigFileEntry.tkline_expire_notices)
2113            sendto_realops_flags(UMODE_ALL, L_ALL,
2114 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2275 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2114 >                               "Temporary X-line for [%s] sexpired", conf->name);
2115          dlinkDelete(ptr, tklist);
2116          free_dlink_node(ptr);
2117          delete_conf_item(conf);
2118        }
2119      }
2281    else if (conf->type == RKLINE_TYPE)
2282    {
2283      aconf = map_to_conf(conf);
2284      if (aconf->hold <= CurrentTime)
2285      {
2286        if (ConfigFileEntry.tkline_expire_notices)
2287           sendto_realops_flags(UMODE_ALL, L_ALL,
2288                                "Temporary K-line for [%s@%s] (REGEX) expired",
2289                                (aconf->user) ? aconf->user : "*",
2290                                (aconf->host) ? aconf->host : "*");
2291        dlinkDelete(ptr, tklist);
2292        free_dlink_node(ptr);
2293        delete_conf_item(conf);
2294      }
2295    }
2120      else if (conf->type == NRESV_TYPE)
2121      {
2122        nconf = (struct MatchItem *)map_to_conf(conf);
# Line 2329 | Line 2153 | expire_tklines(dlink_list *tklist)
2153   static const struct oper_privs
2154   {
2155    const unsigned int oprivs;
2332  const unsigned int hidden;
2156    const unsigned char c;
2157   } flag_list[] = {
2158 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2159 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2160 <  { OPER_FLAG_DIE,         0,                       'D' },
2161 <  { OPER_FLAG_GLINE,       0,                       'G' },
2162 <  { OPER_FLAG_REHASH,      0,                       'H' },
2163 <  { OPER_FLAG_K,           0,                       'K' },
2164 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2165 <  { OPER_FLAG_N,           0,                       'N' },
2166 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2167 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2168 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2169 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2170 <  { OPER_FLAG_X,           0,                       'X' },
2171 <  { 0, 0, '\0' }
2158 >  { OPER_FLAG_ADMIN,       'A' },
2159 >  { OPER_FLAG_REMOTEBAN,   'B' },
2160 >  { OPER_FLAG_DIE,         'D' },
2161 >  { OPER_FLAG_GLINE,       'G' },
2162 >  { OPER_FLAG_REHASH,      'H' },
2163 >  { OPER_FLAG_K,           'K' },
2164 >  { OPER_FLAG_OPERWALL,    'L' },
2165 >  { OPER_FLAG_N,           'N' },
2166 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2167 >  { OPER_FLAG_REMOTE,      'R' },
2168 >  { OPER_FLAG_OPER_SPY,    'S' },
2169 >  { OPER_FLAG_UNKLINE,     'U' },
2170 >  { OPER_FLAG_X,           'X' },
2171 >  { 0, '\0' }
2172   };
2173  
2174   char *
# Line 2357 | Line 2180 | oper_privs_as_string(const unsigned int
2180  
2181    for (; flag_list[i].oprivs; ++i)
2182    {
2183 <    if ((port & flag_list[i].oprivs) &&
2361 <        (port & flag_list[i].hidden) == 0)
2183 >    if (port & flag_list[i].oprivs)
2184        *privs_ptr++ = flag_list[i].c;
2185      else
2186        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2375 | Line 2197 | oper_privs_as_string(const unsigned int
2197   *         "oper" is server name for remote opers
2198   * Side effects: None.
2199   */
2200 < char *
2200 > const char *
2201   get_oper_name(const struct Client *client_p)
2202   {
2203 <  dlink_node *cnode;
2382 <  struct ConfItem *conf;
2383 <  struct AccessItem *aconf;
2384 <
2203 >  dlink_node *cnode = NULL;
2204    /* +5 for !,@,{,} and null */
2205 <  static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
2205 >  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2206  
2207    if (MyConnect(client_p))
2208    {
2209 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2209 >    if ((cnode = client_p->localClient->confs.head))
2210      {
2211 <      conf = cnode->data;
2212 <      aconf = map_to_conf(conf);
2211 >      struct ConfItem *conf = cnode->data;
2212 >      const struct AccessItem *aconf = map_to_conf(conf);
2213  
2214        if (IsConfOperator(aconf))
2215        {
2216 <        ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2217 <                   client_p->username, client_p->host,
2399 <                   conf->name);
2216 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2217 >                 client_p->username, client_p->host, conf->name);
2218          return buffer;
2219        }
2220      }
# Line 2407 | Line 2225 | get_oper_name(const struct Client *clien
2225      assert(0); /* Oper without oper conf! */
2226    }
2227  
2228 <  ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2229 <             client_p->username, client_p->host, client_p->servptr->name);
2228 >  snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2229 >           client_p->username, client_p->host, client_p->servptr->name);
2230    return buffer;
2231   }
2232  
# Line 2425 | Line 2243 | read_conf_files(int cold)
2243    char chanmodes[32];
2244    char chanlimit[32];
2245  
2246 +  conf_parser_ctx.boot = cold;
2247    filename = get_conf_name(CONF_TYPE);
2248  
2249    /* We need to know the initial filename for the yyerror() to report
# Line 2435 | Line 2254 | read_conf_files(int cold)
2254    */
2255    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2256  
2257 <  if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
2257 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2258    {
2259      if (cold)
2260      {
2261 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2261 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2262             filename, strerror(errno));
2263        exit(-1);
2264      }
# Line 2455 | Line 2274 | read_conf_files(int cold)
2274    if (!cold)
2275      clear_out_old_conf();
2276  
2277 <  read_conf(conf_fbfile_in);
2278 <  fbclose(conf_fbfile_in);
2277 >  read_conf(conf_parser_ctx.conf_file);
2278 >  fclose(conf_parser_ctx.conf_file);
2279  
2280    add_isupport("NETWORK", ServerInfo.network_name, -1);
2281 <  ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "",
2282 <             ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2281 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%d",
2282 >           ConfigChannel.max_bans);
2283    add_isupport("MAXLIST", chanmodes, -1);
2284    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2285 <  if (ConfigChannel.disable_local_channels)
2286 <    add_isupport("CHANTYPES", "#", -1);
2287 <  else
2288 <    add_isupport("CHANTYPES", "#&", -1);
2289 <  ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&",
2471 <             ConfigChannel.max_chans_per_user);
2285 >
2286 >  add_isupport("CHANTYPES", "#", -1);
2287 >
2288 >  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
2289 >           ConfigChannel.max_chans_per_user);
2290    add_isupport("CHANLIMIT", chanlimit, -1);
2291 <  ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2292 <             ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2291 >  snprintf(chanmodes, sizeof(chanmodes), "%s",
2292 >           "beI,k,l,imnprstORS");
2293    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2294 <  if (ConfigChannel.use_except)
2295 <    add_isupport("EXCEPTS", "e", -1);
2296 <  if (ConfigChannel.use_invex)
2479 <    add_isupport("INVEX", "I", -1);
2294 >
2295 >  add_isupport("EXCEPTS", "e", -1);
2296 >  add_isupport("INVEX", "I", -1);
2297    add_isupport("CHANMODES", chanmodes, -1);
2298  
2299    /*
# Line 2485 | Line 2302 | read_conf_files(int cold)
2302     */
2303    rebuild_isupport_message_line();
2304  
2305 <  parse_conf_file(KLINE_TYPE, cold);
2305 > #ifdef HAVE_LIBPCRE
2306    parse_conf_file(RKLINE_TYPE, cold);
2307 +  parse_conf_file(RXLINE_TYPE, cold);
2308 + #endif
2309 +  parse_conf_file(KLINE_TYPE, cold);
2310    parse_conf_file(DLINE_TYPE, cold);
2311    parse_conf_file(XLINE_TYPE, cold);
2492  parse_conf_file(RXLINE_TYPE, cold);
2312    parse_conf_file(NRESV_TYPE, cold);
2313    parse_conf_file(CRESV_TYPE, cold);
2314   }
# Line 2503 | Line 2322 | read_conf_files(int cold)
2322   static void
2323   parse_conf_file(int type, int cold)
2324   {
2325 <  FBFILE *file = NULL;
2325 >  FILE *file = NULL;
2326    const char *filename = get_conf_name(type);
2327  
2328 <  if ((file = fbopen(filename, "r")) == NULL)
2328 >  if ((file = fopen(filename, "r")) == NULL)
2329    {
2330      if (cold)
2331 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2331 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2332             filename, strerror(errno));
2333      else
2334        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2519 | Line 2338 | parse_conf_file(int type, int cold)
2338    else
2339    {
2340      parse_csv_file(file, type);
2341 <    fbclose(file);
2341 >    fclose(file);
2342    }
2343   }
2344  
# Line 2538 | Line 2357 | clear_out_old_conf(void)
2357    struct ClassItem *cltmp;
2358    struct MatchItem *match_item;
2359    dlink_list *free_items [] = {
2360 <    &server_items,   &oconf_items,    &hub_items, &leaf_items,
2360 >    &server_items,   &oconf_items,
2361       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2362 <     &nresv_items, &cluster_items,  &gdeny_items, NULL
2362 >     &nresv_items, &cluster_items,  &service_items, NULL
2363    };
2364  
2365    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2583 | Line 2402 | clear_out_old_conf(void)
2402            delete_conf_item(conf);
2403          }
2404        }
2586      else if (conf->type == CLIENT_TYPE)
2587      {
2588        aconf = map_to_conf(conf);
2589
2590        if (aconf->clients != 0)
2591        {
2592          SetConfIllegal(aconf);
2593        }
2594        else
2595        {
2596          delete_conf_item(conf);
2597        }
2598      }
2405        else if (conf->type == XLINE_TYPE  ||
2406                 conf->type == RXLINE_TYPE ||
2407                 conf->type == RKLINE_TYPE)
# Line 2609 | Line 2415 | clear_out_old_conf(void)
2415        }
2416        else
2417        {
2612        if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2613        {
2614          match_item = map_to_conf(conf);
2615          if (match_item->ref_count <= 0)
2616            delete_conf_item(conf);
2617          else
2618          {
2619            match_item->illegal = 1;
2620            dlinkDelete(&conf->node, *iterator);
2621          }
2622        }
2623        else
2418            delete_conf_item(conf);
2419        }
2420      }
# Line 2641 | Line 2435 | clear_out_old_conf(void)
2435    clear_out_address_conf();
2436  
2437    /* clean out module paths */
2644 #ifndef STATIC_MODULES
2438    mod_clear_paths();
2646 #endif
2439  
2440    /* clean out ServerInfo */
2441    MyFree(ServerInfo.description);
# Line 2663 | Line 2455 | clear_out_old_conf(void)
2455  
2456    MyFree(ServerInfo.rsa_private_key_file);
2457    ServerInfo.rsa_private_key_file = NULL;
2458 +
2459 +  if (ServerInfo.server_ctx)
2460 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2461 +                                               SSL_OP_NO_SSLv3|
2462 +                                               SSL_OP_NO_TLSv1);
2463 +  if (ServerInfo.client_ctx)
2464 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2465 +                                               SSL_OP_NO_SSLv3|
2466 +                                               SSL_OP_NO_TLSv1);
2467   #endif
2468  
2469    /* clean out old resvs from the conf */
# Line 2685 | Line 2486 | clear_out_old_conf(void)
2486     */
2487  
2488    /* clean out general */
2489 <  MyFree(ConfigFileEntry.servlink_path);
2490 <  ConfigFileEntry.servlink_path = NULL;
2491 < #ifdef HAVE_LIBCRYPTO
2691 <  ConfigFileEntry.default_cipher_preference = NULL;
2692 < #endif /* HAVE_LIBCRYPTO */
2489 >  MyFree(ConfigFileEntry.service_name);
2490 >  ConfigFileEntry.service_name = NULL;
2491 >
2492    delete_isupport("INVEX");
2493    delete_isupport("EXCEPTS");
2494   }
# Line 2800 | Line 2599 | get_conf_ping(struct ConfItem *conf, int
2599      if (aconf->class_ptr != NULL)
2600      {
2601        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2602 <      *pingwarn = PingWarning(aclass);
2603 <      return PingFreq(aclass);
2602 >      *pingwarn = aclass->ping_warning;
2603 >      return aclass->ping_freq;
2604      }
2605    }
2606  
# Line 2817 | Line 2616 | get_conf_ping(struct ConfItem *conf, int
2616   const char *
2617   get_client_class(struct Client *target_p)
2618   {
2619 <  dlink_node *ptr;
2620 <  struct ConfItem *conf;
2822 <  struct AccessItem *aconf;
2619 >  dlink_node *cnode = NULL;
2620 >  struct AccessItem *aconf = NULL;
2621  
2622 <  if (target_p != NULL && !IsMe(target_p) &&
2623 <      target_p->localClient->confs.head != NULL)
2622 >  assert(!IsMe(target_p));
2623 >
2624 >  if ((cnode = target_p->localClient->confs.head))
2625    {
2626 <    DLINK_FOREACH(ptr, target_p->localClient->confs.head)
2828 <    {
2829 <      conf = ptr->data;
2626 >    struct ConfItem *conf = cnode->data;
2627  
2628 <      if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE ||
2629 <          conf->type == OPER_TYPE)
2630 <      {
2631 <        aconf = (struct AccessItem *) map_to_conf(conf);
2632 <        if (aconf->class_ptr != NULL)
2633 <          return aconf->class_ptr->name;
2837 <      }
2838 <    }
2628 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2629 >          (conf->type == OPER_TYPE));
2630 >
2631 >    aconf = map_to_conf(conf);
2632 >    if (aconf->class_ptr != NULL)
2633 >      return aconf->class_ptr->name;
2634    }
2635  
2636    return "default";
# Line 2851 | Line 2646 | get_client_class(struct Client *target_p
2646   int
2647   get_client_ping(struct Client *target_p, int *pingwarn)
2648   {
2649 <  int ping;
2650 <  struct ConfItem *conf;
2856 <  dlink_node *nlink;
2649 >  int ping = 0;
2650 >  dlink_node *cnode = NULL;
2651  
2652 <  if (target_p->localClient->confs.head != NULL)
2653 <    DLINK_FOREACH(nlink, target_p->localClient->confs.head)
2654 <    {
2861 <      conf = nlink->data;
2652 >  if ((cnode = target_p->localClient->confs.head))
2653 >  {
2654 >    struct ConfItem *conf = cnode->data;
2655  
2656 <      if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2657 <          (conf->type == OPER_TYPE))
2658 <      {
2659 <        ping = get_conf_ping(conf, pingwarn);
2660 <        if (ping > 0)
2661 <          return ping;
2662 <      }
2870 <    }
2656 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2657 >          (conf->type == OPER_TYPE));
2658 >
2659 >    ping = get_conf_ping(conf, pingwarn);
2660 >    if (ping > 0)
2661 >      return ping;
2662 >  }
2663  
2664    *pingwarn = 0;
2665    return DEFAULT_PINGFREQUENCY;
# Line 2884 | Line 2676 | find_class(const char *classname)
2676   {
2677    struct ConfItem *conf;
2678  
2679 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2679 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2680      return conf;
2681  
2682    return class_default;
# Line 2905 | Line 2697 | check_class(void)
2697    {
2698      struct ClassItem *aclass = map_to_conf(ptr->data);
2699  
2700 <    if (!aclass->active && !CurrUserCount(aclass))
2700 >    if (!aclass->active && !aclass->curr_user_count)
2701      {
2702        destroy_cidr_class(aclass);
2703        delete_conf_item(ptr->data);
# Line 2929 | Line 2721 | init_class(void)
2721    aclass = map_to_conf(class_default);
2722    aclass->active = 1;
2723    DupString(class_default->name, "default");
2724 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2725 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2726 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2727 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2724 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2725 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2726 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2727 >  aclass->max_sendq = DEFAULT_SENDQ;
2728  
2729    client_check_cb = register_callback("check_client", check_client);
2730   }
# Line 2947 | Line 2739 | unsigned int
2739   get_sendq(struct Client *client_p)
2740   {
2741    unsigned int sendq = DEFAULT_SENDQ;
2742 <  dlink_node *ptr;
2951 <  struct ConfItem *conf;
2742 >  dlink_node *cnode;
2743    struct ConfItem *class_conf;
2744    struct ClassItem *aclass;
2745    struct AccessItem *aconf;
2746  
2747 <  if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
2747 >  assert(!IsMe(client_p));
2748 >
2749 >  if ((cnode = client_p->localClient->confs.head))
2750    {
2751 <    DLINK_FOREACH(ptr, client_p->localClient->confs.head)
2752 <    {
2753 <      conf = ptr->data;
2754 <      if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE)
2755 <          || (conf->type == CLIENT_TYPE))
2756 <      {
2757 <        aconf = (struct AccessItem *)map_to_conf(conf);
2758 <        if ((class_conf = aconf->class_ptr) == NULL)
2759 <          continue;
2760 <        aclass = (struct ClassItem *)map_to_conf(class_conf);
2761 <        sendq = MaxSendq(aclass);
2762 <        return sendq;
2763 <      }
2971 <    }
2751 >    struct ConfItem *conf = cnode->data;
2752 >
2753 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2754 >          (conf->type == OPER_TYPE));
2755 >
2756 >    aconf = map_to_conf(conf);
2757 >
2758 >    if ((class_conf = aconf->class_ptr) == NULL)
2759 >      return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */
2760 >
2761 >    aclass = map_to_conf(class_conf);
2762 >    sendq = aclass->max_sendq;
2763 >    return sendq;
2764    }
2765 +
2766    /* XXX return a default?
2767     * if here, then there wasn't an attached conf with a sendq
2768     * that is very bad -Dianora
# Line 3032 | Line 2825 | conf_add_class_to_conf(struct ConfItem *
2825   int
2826   conf_add_server(struct ConfItem *conf, const char *class_name)
2827   {
2828 <  struct AccessItem *aconf;
3036 <  struct split_nuh_item nuh;
3037 <  char conf_user[USERLEN + 1];
3038 <  char conf_host[HOSTLEN + 1];
3039 <
3040 <  aconf = map_to_conf(conf);
2828 >  struct AccessItem *aconf = map_to_conf(conf);
2829  
2830    conf_add_class_to_conf(conf, class_name);
2831  
2832    if (!aconf->host || !conf->name)
2833    {
2834      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2835 <    ilog(L_WARN, "Bad connect block");
2835 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2836      return -1;
2837    }
2838  
2839 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2839 >  if (EmptyString(aconf->passwd))
2840    {
2841      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2842                           conf->name);
2843 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2843 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2844      return -1;
2845    }
2846  
3059  nuh.nuhmask  = aconf->host;
3060  nuh.nickptr  = NULL;
3061  nuh.userptr  = conf_user;
3062  nuh.hostptr  = conf_host;
3063
3064  nuh.nicksize = 0;
3065  nuh.usersize = sizeof(conf_user);
3066  nuh.hostsize = sizeof(conf_host);
3067
3068  split_nuh(&nuh);
3069
3070  MyFree(aconf->host);
3071  aconf->host = NULL;
3072
3073  DupString(aconf->user, conf_user); /* somehow username checking for servers
3074                                 got lost in H6/7, will have to be re-added */
3075  DupString(aconf->host, conf_host);
3076
2847    lookup_confhost(conf);
2848  
2849    return 0;
2850   }
2851  
3082 /* conf_add_d_conf()
3083 *
3084 * inputs       - pointer to config item
3085 * output       - NONE
3086 * side effects - Add a d/D line
3087 */
3088 void
3089 conf_add_d_conf(struct AccessItem *aconf)
3090 {
3091  if (aconf->host == NULL)
3092    return;
3093
3094  aconf->user = NULL;
3095
3096  /* XXX - Should 'd' ever be in the old conf? For new conf we don't
3097   *       need this anyway, so I will disable it for now... -A1kmm
3098   */
3099  if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST)
3100  {
3101    ilog(L_WARN, "Invalid Dline %s ignored", aconf->host);
3102    free_access_item(aconf);
3103  }
3104  else
3105  {
3106    /* XXX ensure user is NULL */
3107    MyFree(aconf->user);
3108    aconf->user = NULL;
3109    add_conf_by_address(CONF_DLINE, aconf);
3110  }
3111 }
3112
2852   /* yyerror()
2853   *
2854   * inputs       - message from parser
# Line 3121 | Line 2860 | yyerror(const char *msg)
2860   {
2861    char newlinebuf[IRCD_BUFSIZE];
2862  
2863 <  if (ypass != 1)
2863 >  if (conf_parser_ctx.pass != 1)
2864      return;
2865  
2866    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2867    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2868                         conffilebuf, lineno + 1, msg, newlinebuf);
2869 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2869 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2870         conffilebuf, lineno + 1, msg, newlinebuf);
2871   }
2872  
3134 int
3135 conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb)
3136 {
3137  if (fbgets(lbuf, max_size, fb) == NULL)
3138    return 0;
3139
3140  return strlen(lbuf);
3141 }
3142
3143 int
3144 conf_yy_fatal_error(const char *msg)
3145 {
3146  return 0;
3147 }
3148
2873   /*
2874   * valid_tkline()
2875   *
# Line 3157 | Line 2881 | conf_yy_fatal_error(const char *msg)
2881   * Originally written by Dianora (Diane, db@db.net)
2882   */
2883   time_t
2884 < valid_tkline(char *p, int minutes)
2884 > valid_tkline(const char *p, int minutes)
2885   {
2886    time_t result = 0;
2887  
2888 <  while (*p)
2888 >  for (; *p; ++p)
2889    {
2890 <    if (IsDigit(*p))
3167 <    {
3168 <      result *= 10;
3169 <      result += ((*p) & 0xF);
3170 <      p++;
3171 <    }
3172 <    else
2890 >    if (!IsDigit(*p))
2891        return 0;
2892 +
2893 +    result *= 10;
2894 +    result += ((*p) & 0xF);
2895    }
2896  
2897 <  /* in the degenerate case where oper does a /quote kline 0 user@host :reason
2897 >  /*
2898 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
2899     * i.e. they specifically use 0, I am going to return 1 instead
2900     * as a return value of non-zero is used to flag it as a temporary kline
2901     */
3180
2902    if (result == 0)
2903      result = 1;
2904  
# Line 3348 | Line 3069 | parse_aline(const char *cmd, struct Clie
3069          return -1;
3070        }
3071  
3072 <      if (!IsOperRemoteBan(source_p))
3072 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3073        {
3074          sendto_one(source_p, form_str(ERR_NOPRIVS),
3075                     me.name, source_p->name, "remoteban");
# Line 3385 | Line 3106 | parse_aline(const char *cmd, struct Clie
3106        return -1;
3107      }
3108  
3109 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3109 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3110        return -1;
3111    }
3112    else
3113 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3113 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3114        return -1;
3115  
3116    if (reason != NULL)
# Line 3397 | Line 3118 | parse_aline(const char *cmd, struct Clie
3118      if (parc != 0 && !EmptyString(*parv))
3119      {
3120        *reason = *parv;
3121 <      if (!valid_comment(source_p, *reason, YES))
3121 >      if (!valid_comment(source_p, *reason, 1))
3122          return -1;
3123      }
3124      else
# Line 3528 | Line 3249 | match_conf_password(const char *password
3249   {
3250    const char *encr = NULL;
3251  
3252 <  if (password == NULL || aconf->passwd == NULL)
3252 >  if (EmptyString(password) || EmptyString(aconf->passwd))
3253      return 0;
3254  
3255    if (aconf->flags & CONF_FLAGS_ENCRYPTED)
3256 <  {
3536 <    /* use first two chars of the password they send in as salt */
3537 <    /* If the password in the conf is MD5, and ircd is linked
3538 <     * to scrypt on FreeBSD, or the standard crypt library on
3539 <     * glibc Linux, then this code will work fine on generating
3540 <     * the proper encrypted hash for comparison.
3541 <     */
3542 <    if (*aconf->passwd)
3543 <      encr = crypt(password, aconf->passwd);
3544 <    else
3545 <      encr = "";
3546 <  }
3256 >    encr = crypt(password, aconf->passwd);
3257    else
3258      encr = password;
3259  
# Line 3556 | Line 3266 | match_conf_password(const char *password
3266   * inputs       - client sending the cluster
3267   *              - command name "KLINE" "XLINE" etc.
3268   *              - capab -- CAP_KLN etc. from s_serv.h
3269 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3269 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3270   *              - pattern and args to send along
3271   * output       - none
3272   * side effects - Take source_p send the pattern with args given
# Line 3716 | Line 3426 | cidr_limit_reached(int over_rule,
3426    dlink_node *ptr = NULL;
3427    struct CidrItem *cidr;
3428  
3429 <  if (NumberPerCidr(aclass) <= 0)
3429 >  if (aclass->number_per_cidr <= 0)
3430      return 0;
3431  
3432    if (ip->ss.ss_family == AF_INET)
3433    {
3434 <    if (CidrBitlenIPV4(aclass) <= 0)
3434 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3435        return 0;
3436  
3437      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3438      {
3439        cidr = ptr->data;
3440 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3440 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3441        {
3442 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3442 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3443            return -1;
3444          cidr->number_on_this_cidr++;
3445          return 0;
# Line 3738 | Line 3448 | cidr_limit_reached(int over_rule,
3448      cidr = MyMalloc(sizeof(struct CidrItem));
3449      cidr->number_on_this_cidr = 1;
3450      cidr->mask = *ip;
3451 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3451 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3452      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3453    }
3454   #ifdef IPV6
3455 <  else if (CidrBitlenIPV6(aclass) > 0)
3455 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3456    {
3457      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3458      {
3459        cidr = ptr->data;
3460 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3460 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3461        {
3462 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3462 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3463            return -1;
3464          cidr->number_on_this_cidr++;
3465          return 0;
# Line 3758 | Line 3468 | cidr_limit_reached(int over_rule,
3468      cidr = MyMalloc(sizeof(struct CidrItem));
3469      cidr->number_on_this_cidr = 1;
3470      cidr->mask = *ip;
3471 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3471 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3472      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3473    }
3474   #endif
# Line 3780 | Line 3490 | remove_from_cidr_check(struct irc_ssaddr
3490    dlink_node *next_ptr = NULL;
3491    struct CidrItem *cidr;
3492  
3493 <  if (NumberPerCidr(aclass) == 0)
3493 >  if (aclass->number_per_cidr == 0)
3494      return;
3495  
3496    if (ip->ss.ss_family == AF_INET)
3497    {
3498 <    if (CidrBitlenIPV4(aclass) <= 0)
3498 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3499        return;
3500  
3501      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3502      {
3503        cidr = ptr->data;
3504 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3504 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3505        {
3506          cidr->number_on_this_cidr--;
3507          if (cidr->number_on_this_cidr == 0)
# Line 3804 | Line 3514 | remove_from_cidr_check(struct irc_ssaddr
3514      }
3515    }
3516   #ifdef IPV6
3517 <  else if (CidrBitlenIPV6(aclass) > 0)
3517 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3518    {
3519      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3520      {
3521        cidr = ptr->data;
3522 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3522 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3523        {
3524          cidr->number_on_this_cidr--;
3525          if (cidr->number_on_this_cidr == 0)
# Line 3872 | Line 3582 | rebuild_cidr_class(struct ConfItem *conf
3582   {
3583    struct ClassItem *old_class = map_to_conf(conf);
3584  
3585 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3585 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3586    {
3587 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3587 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3588        rebuild_cidr_list(AF_INET, conf, new_class,
3589                          &old_class->list_ipv4, &new_class->list_ipv4,
3590 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3590 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3591  
3592   #ifdef IPV6
3593 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3593 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3594        rebuild_cidr_list(AF_INET6, conf, new_class,
3595                          &old_class->list_ipv6, &new_class->list_ipv6,
3596 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3596 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3597   #endif
3598    }
3599  

Diff Legend

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