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

Comparing:
ircd-hybrid-7.2/src/s_conf.c (file contents), Revision 896 by michael, Sat Nov 3 08:54:09 2007 UTC vs.
ircd-hybrid-8/src/conf.c (file contents), Revision 1393 by michael, Wed May 2 19:17:37 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 72 | 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  
75 dlink_list temporary_klines  = { NULL, NULL, 0 };
76 dlink_list temporary_dlines  = { NULL, NULL, 0 };
71   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 };
72   dlink_list temporary_resv = { NULL, NULL, 0 };
73  
74   extern unsigned int lineno;
75   extern char linebuf[];
76   extern char conffilebuf[IRCD_BUFSIZE];
86 extern char yytext[];
77   extern int yyparse(); /* defined in y.tab.c */
78 < 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 *);
92 < static void set_default_conf(void);
93 < static void validate_conf(void);
94 < 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 114 | Line 102 | static void destroy_cidr_class(struct Cl
102  
103   static void flags_to_ascii(unsigned int, const unsigned int[], char *, int);
104  
117 FBFILE *conf_fbfile_in = NULL;
118
105   /* address of default class conf */
106   static struct ConfItem *class_default;
107  
# Line 138 | 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 168 | 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;
174 <  struct ConfItem *conf;
159 >  struct AccessItem *aconf = vptr;
160  
161 <  MyFree(aconf->dns_query);
177 <  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",
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 <  }
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 198 | 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;
205 <    aconf->dns_query->callback = conf_dns_callback;
206 <    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 274 | Line 249 | make_conf_item(ConfType type)
249      aconf->status = status;
250      break;
251  
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
252    case ULINE_TYPE:
253      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
254                                         sizeof(struct MatchItem));
# Line 303 | 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 317 | 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 334 | 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 = MyMalloc(sizeof(struct ConfItem) +
308                             sizeof(struct ClassItem));
# Line 341 | Line 310 | make_conf_item(ConfType type)
310  
311      aclass = map_to_conf(conf);
312      aclass->active = 1;
313 <    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
314 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
315 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
316 <    MaxSendq(aclass) = DEFAULT_SENDQ;
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  
# Line 362 | Line 331 | make_conf_item(ConfType type)
331   void
332   delete_conf_item(struct ConfItem *conf)
333   {
334 <  dlink_node *m = NULL;
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 543 | 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 576 | 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;
545    struct ClassItem *classitem = NULL;
546    char buf[12];
547    char *p = NULL;
588  const char *pfx = NULL;
548  
549    switch (type)
550    {
# Line 628 | 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 636 | 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:
645    pfx = temp ? "kR" : "KR";
646
605      DLINK_FOREACH(ptr, rkconf_items.head)
606      {
607        aconf = map_to_conf((conf = ptr->data));
608  
651      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
652        continue;
653
609        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
610 <                 source_p->name, pfx, 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 700 | 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 720 | 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),
682 <                 CurrUserCount(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;
# Line 732 | 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 744 | Line 709 | report_confitem_types(struct Client *sou
709  
710        if (IsConfAllowAutoConn(aconf))
711          *p++ = 'A';
712 <      if (IsConfCryptLink(aconf))
713 <        *p++ = 'C';
749 <      if (aconf->fakename)
750 <        *p++ = 'M';
712 >      if (IsConfSSL(aconf))
713 >        *p++ = 'S';
714        if (IsConfTopicBurst(aconf))
715          *p++ = 'T';
753      if (IsConfCompressed(aconf))
754        *p++ = 'Z';
716        if (buf[0] == '\0')
717          *p++ = '*';
718  
# Line 760 | Line 721 | report_confitem_types(struct Client *sou
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 774 | 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 800 | 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 826 | 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 <    ilog(L_INFO, "Access denied: %s[%s]",
795 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
796           source_p->name, source_p->sockhost);
797  
798    switch (i)
# Line 836 | Line 802 | check_client(va_list args)
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;
808        exit_client(source_p, &me, "No more connections allowed on that IP");
# Line 847 | 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;
819        exit_client(source_p, &me,
# Line 864 | Line 830 | check_client(va_list args)
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 1027 | 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  
# Line 1191 | 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 1202 | 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 1226 | 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 1318 | Line 1284 | detach_conf(struct Client *client_p, Con
1284  
1285          assert(aconf->clients > 0);
1286  
1287 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1287 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1288          {
1289            aclass = map_to_conf(aclass_conf);
1290  
# Line 1334 | Line 1300 | detach_conf(struct Client *client_p, Con
1300            delete_conf_item(conf);
1301  
1302          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;
1303        default:
1304          break;
1305        }
# Line 1384 | Line 1343 | attach_conf(struct Client *client_p, str
1343                               &client_p->localClient->ip, aclass))
1344          return TOO_MANY;    /* Already at maximum allowed */
1345  
1346 <    CurrUserCount(aclass)++;
1346 >    aclass->curr_user_count++;
1347      aconf->clients++;
1348    }
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  }
1349  
1350    dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
1351  
# Line 1480 | Line 1434 | find_conf_exact(ConfType type, const cha
1434      {
1435        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1436  
1437 <      if (aconf->clients >= MaxTotal(aclass))
1437 >      if (aconf->clients >= aclass->max_total)
1438          continue;
1439      }
1440  
# Line 1552 | 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 1587 | 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 1597 | 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 1651 | 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 1692 | 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 1761 | Line 1755 | rehash(int sig)
1755      sendto_realops_flags(UMODE_ALL, L_ALL,
1756                           "Got signal SIGHUP, reloading ircd.conf file");
1757  
1764 #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 1774 | Line 1767 | rehash(int sig)
1767    if (ServerInfo.description != NULL)
1768      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1769  
1777 #ifndef STATIC_MODULES
1770    load_conf_modules();
1779 #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 1822 | 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';
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;
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;
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 */
1885 <  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 */
1913 <  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 */
1899 >  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1900    ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1901 <    UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1902 <  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;
1901 >    UMODE_OPERWALL | UMODE_WALLOP;
1902 >  ConfigFileEntry.use_egd = 0;
1903    ConfigFileEntry.egdpool_path = NULL;
1933 #ifdef HAVE_LIBZ
1934  ConfigFileEntry.compression_level = 0;
1935 #endif
1904    ConfigFileEntry.throttle_time = 10;
1905   }
1906  
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
1907   static void
1908   validate_conf(void)
1909   {
# Line 1969 | 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  
1972  if (ConfigFileEntry.servlink_path == NULL)
1973    DupString(ConfigFileEntry.servlink_path, SLPATH);
1974
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;
# Line 1985 | Line 1929 | validate_conf(void)
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()
1957   *
1958   * start DNS lookups of all hostnames in the conf
# Line 2001 | 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 2021 | 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 2029 | 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 2071 | 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 2085 | 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 2108 | Line 2077 | find_kill(struct Client *client_p)
2077  
2078    assert(client_p != NULL);
2079  
2080 <  aconf = find_kline_conf(client_p->host, client_p->username,
2081 <                          &client_p->localClient->ip,
2082 <                          client_p->localClient->aftype);
2080 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2081 >                               CONF_KLINE, client_p->localClient->aftype,
2082 >                               client_p->username, NULL, 1);
2083    if (aconf == NULL)
2084      aconf = find_regexp_kline(uhi);
2085  
2086 <  if (aconf && (aconf->status & CONF_KLINE))
2118 <    return aconf;
2119 <
2120 <  return NULL;
2086 >  return aconf;
2087   }
2088  
2089   struct AccessItem *
# Line 2127 | Line 2093 | find_gline(struct Client *client_p)
2093  
2094    assert(client_p != NULL);
2095  
2096 <  aconf = find_gline_conf(client_p->host, client_p->username,
2097 <                          &client_p->localClient->ip,
2098 <                          client_p->localClient->aftype);
2099 <
2134 <  if (aconf && (aconf->status & CONF_GLINE))
2135 <    return aconf;
2136 <
2137 <  return NULL;
2096 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2097 >                               CONF_GLINE, client_p->localClient->aftype,
2098 >                               client_p->username, NULL, 1);
2099 >  return aconf;
2100   }
2101  
2102   /* add_temp_line()
# Line 2147 | Line 2109 | find_gline(struct Client *client_p)
2109   void
2110   add_temp_line(struct ConfItem *conf)
2111   {
2112 <  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)
2112 >  if (conf->type == XLINE_TYPE)
2113    {
2114      conf->flags |= CONF_FLAGS_TEMPORARY;
2115      dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2116    }
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  }
2117    else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2118    {
2119      conf->flags |= CONF_FLAGS_TEMPORARY;
# Line 2204 | Line 2131 | add_temp_line(struct ConfItem *conf)
2131   void
2132   cleanup_tklines(void *notused)
2133   {
2134 <  expire_tklines(&temporary_glines);
2208 <  expire_tklines(&temporary_klines);
2209 <  expire_tklines(&temporary_dlines);
2134 >  hostmask_expire_temporary();
2135    expire_tklines(&temporary_xlines);
2211  expire_tklines(&temporary_rxlines);
2212  expire_tklines(&temporary_rklines);
2136    expire_tklines(&temporary_resv);
2137   }
2138  
# Line 2227 | Line 2150 | expire_tklines(dlink_list *tklist)
2150    struct ConfItem *conf;
2151    struct MatchItem *xconf;
2152    struct MatchItem *nconf;
2230  struct AccessItem *aconf;
2153    struct ResvChannel *cconf;
2154  
2155    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2156    {
2157      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        }
2158  
2159 <        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)
2159 >    if (conf->type == XLINE_TYPE)
2160      {
2161        xconf = (struct MatchItem *)map_to_conf(conf);
2162        if (xconf->hold <= CurrentTime)
2163        {
2164          if (ConfigFileEntry.tkline_expire_notices)
2165            sendto_realops_flags(UMODE_ALL, L_ALL,
2166 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2275 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2166 >                               "Temporary X-line for [%s] sexpired", conf->name);
2167          dlinkDelete(ptr, tklist);
2168          free_dlink_node(ptr);
2169          delete_conf_item(conf);
2170        }
2171      }
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    }
2172      else if (conf->type == NRESV_TYPE)
2173      {
2174        nconf = (struct MatchItem *)map_to_conf(conf);
# Line 2329 | Line 2205 | expire_tklines(dlink_list *tklist)
2205   static const struct oper_privs
2206   {
2207    const unsigned int oprivs;
2332  const unsigned int hidden;
2208    const unsigned char c;
2209   } flag_list[] = {
2210 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2211 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2212 <  { OPER_FLAG_DIE,         0,                       'D' },
2213 <  { OPER_FLAG_GLINE,       0,                       'G' },
2214 <  { OPER_FLAG_REHASH,      0,                       'H' },
2215 <  { OPER_FLAG_K,           0,                       'K' },
2216 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2217 <  { OPER_FLAG_N,           0,                       'N' },
2218 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2219 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2220 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2221 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2222 <  { OPER_FLAG_X,           0,                       'X' },
2223 <  { 0, 0, '\0' }
2210 >  { OPER_FLAG_ADMIN,       'A' },
2211 >  { OPER_FLAG_REMOTEBAN,   'B' },
2212 >  { OPER_FLAG_DIE,         'D' },
2213 >  { OPER_FLAG_GLINE,       'G' },
2214 >  { OPER_FLAG_REHASH,      'H' },
2215 >  { OPER_FLAG_K,           'K' },
2216 >  { OPER_FLAG_OPERWALL,    'L' },
2217 >  { OPER_FLAG_N,           'N' },
2218 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2219 >  { OPER_FLAG_REMOTE,      'R' },
2220 >  { OPER_FLAG_OPER_SPY,    'S' },
2221 >  { OPER_FLAG_UNKLINE,     'U' },
2222 >  { OPER_FLAG_X,           'X' },
2223 >  { 0, '\0' }
2224   };
2225  
2226   char *
# Line 2357 | Line 2232 | oper_privs_as_string(const unsigned int
2232  
2233    for (; flag_list[i].oprivs; ++i)
2234    {
2235 <    if ((port & flag_list[i].oprivs) &&
2361 <        (port & flag_list[i].hidden) == 0)
2235 >    if (port & flag_list[i].oprivs)
2236        *privs_ptr++ = flag_list[i].c;
2237      else
2238        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2375 | Line 2249 | oper_privs_as_string(const unsigned int
2249   *         "oper" is server name for remote opers
2250   * Side effects: None.
2251   */
2252 < char *
2252 > const char *
2253   get_oper_name(const struct Client *client_p)
2254   {
2255 <  dlink_node *cnode;
2382 <  struct ConfItem *conf;
2383 <  struct AccessItem *aconf;
2384 <
2255 >  dlink_node *cnode = NULL;
2256    /* +5 for !,@,{,} and null */
2257 <  static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
2257 >  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2258  
2259    if (MyConnect(client_p))
2260    {
2261 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2261 >    if ((cnode = client_p->localClient->confs.head))
2262      {
2263 <      conf = cnode->data;
2264 <      aconf = map_to_conf(conf);
2263 >      struct ConfItem *conf = cnode->data;
2264 >      const struct AccessItem *aconf = map_to_conf(conf);
2265  
2266        if (IsConfOperator(aconf))
2267        {
2268 <        ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2269 <                   client_p->username, client_p->host,
2399 <                   conf->name);
2268 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2269 >                 client_p->username, client_p->host, conf->name);
2270          return buffer;
2271        }
2272      }
# Line 2407 | Line 2277 | get_oper_name(const struct Client *clien
2277      assert(0); /* Oper without oper conf! */
2278    }
2279  
2280 <  ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2281 <             client_p->username, client_p->host, client_p->servptr->name);
2280 >  snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2281 >           client_p->username, client_p->host, client_p->servptr->name);
2282    return buffer;
2283   }
2284  
# Line 2425 | Line 2295 | read_conf_files(int cold)
2295    char chanmodes[32];
2296    char chanlimit[32];
2297  
2298 +  conf_parser_ctx.boot = cold;
2299    filename = get_conf_name(CONF_TYPE);
2300  
2301    /* We need to know the initial filename for the yyerror() to report
# Line 2435 | Line 2306 | read_conf_files(int cold)
2306    */
2307    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2308  
2309 <  if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
2309 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2310    {
2311      if (cold)
2312      {
2313 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2313 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2314             filename, strerror(errno));
2315        exit(-1);
2316      }
# Line 2455 | Line 2326 | read_conf_files(int cold)
2326    if (!cold)
2327      clear_out_old_conf();
2328  
2329 <  read_conf(conf_fbfile_in);
2330 <  fbclose(conf_fbfile_in);
2329 >  read_conf(conf_parser_ctx.conf_file);
2330 >  fclose(conf_parser_ctx.conf_file);
2331  
2332    add_isupport("NETWORK", ServerInfo.network_name, -1);
2333 <  ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "",
2334 <             ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2333 >  snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d",
2334 >           ConfigChannel.use_except ? "e" : "",
2335 >           ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2336    add_isupport("MAXLIST", chanmodes, -1);
2337    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2338 +
2339    if (ConfigChannel.disable_local_channels)
2340      add_isupport("CHANTYPES", "#", -1);
2341    else
2342      add_isupport("CHANTYPES", "#&", -1);
2343 <  ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&",
2344 <             ConfigChannel.max_chans_per_user);
2343 >
2344 >  snprintf(chanlimit, sizeof(chanlimit), "%s:%d",
2345 >           ConfigChannel.disable_local_channels ? "#" : "#&",
2346 >           ConfigChannel.max_chans_per_user);
2347    add_isupport("CHANLIMIT", chanlimit, -1);
2348 <  ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2349 <             ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2348 >  snprintf(chanmodes, sizeof(chanmodes), "%s%s%s",
2349 >           ConfigChannel.use_except ? "e" : "",
2350 >           ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS");
2351    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2352 +
2353    if (ConfigChannel.use_except)
2354      add_isupport("EXCEPTS", "e", -1);
2355    if (ConfigChannel.use_invex)
# Line 2485 | Line 2362 | read_conf_files(int cold)
2362     */
2363    rebuild_isupport_message_line();
2364  
2365 <  parse_conf_file(KLINE_TYPE, cold);
2365 > #ifdef HAVE_LIBPCRE
2366    parse_conf_file(RKLINE_TYPE, cold);
2367 +  parse_conf_file(RXLINE_TYPE, cold);
2368 + #endif
2369 +  parse_conf_file(KLINE_TYPE, cold);
2370    parse_conf_file(DLINE_TYPE, cold);
2371    parse_conf_file(XLINE_TYPE, cold);
2492  parse_conf_file(RXLINE_TYPE, cold);
2372    parse_conf_file(NRESV_TYPE, cold);
2373    parse_conf_file(CRESV_TYPE, cold);
2374   }
# Line 2503 | Line 2382 | read_conf_files(int cold)
2382   static void
2383   parse_conf_file(int type, int cold)
2384   {
2385 <  FBFILE *file = NULL;
2385 >  FILE *file = NULL;
2386    const char *filename = get_conf_name(type);
2387  
2388 <  if ((file = fbopen(filename, "r")) == NULL)
2388 >  if ((file = fopen(filename, "r")) == NULL)
2389    {
2390      if (cold)
2391 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2391 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2392             filename, strerror(errno));
2393      else
2394        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2519 | Line 2398 | parse_conf_file(int type, int cold)
2398    else
2399    {
2400      parse_csv_file(file, type);
2401 <    fbclose(file);
2401 >    fclose(file);
2402    }
2403   }
2404  
# Line 2538 | Line 2417 | clear_out_old_conf(void)
2417    struct ClassItem *cltmp;
2418    struct MatchItem *match_item;
2419    dlink_list *free_items [] = {
2420 <    &server_items,   &oconf_items,    &hub_items, &leaf_items,
2420 >    &server_items,   &oconf_items,
2421       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2422 <     &nresv_items, &cluster_items,  &gdeny_items, NULL
2422 >     &nresv_items, &cluster_items,  &gdeny_items, &service_items, NULL
2423    };
2424  
2425    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2583 | Line 2462 | clear_out_old_conf(void)
2462            delete_conf_item(conf);
2463          }
2464        }
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      }
2465        else if (conf->type == XLINE_TYPE  ||
2466                 conf->type == RXLINE_TYPE ||
2467                 conf->type == RKLINE_TYPE)
# Line 2609 | Line 2475 | clear_out_old_conf(void)
2475        }
2476        else
2477        {
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
2478            delete_conf_item(conf);
2479        }
2480      }
# Line 2641 | Line 2495 | clear_out_old_conf(void)
2495    clear_out_address_conf();
2496  
2497    /* clean out module paths */
2644 #ifndef STATIC_MODULES
2498    mod_clear_paths();
2646 #endif
2499  
2500    /* clean out ServerInfo */
2501    MyFree(ServerInfo.description);
# Line 2663 | Line 2515 | clear_out_old_conf(void)
2515  
2516    MyFree(ServerInfo.rsa_private_key_file);
2517    ServerInfo.rsa_private_key_file = NULL;
2518 +
2519 +  if (ServerInfo.server_ctx)
2520 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2521 +                                               SSL_OP_NO_SSLv3|
2522 +                                               SSL_OP_NO_TLSv1);
2523 +  if (ServerInfo.client_ctx)
2524 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2525 +                                               SSL_OP_NO_SSLv3|
2526 +                                               SSL_OP_NO_TLSv1);
2527   #endif
2528  
2529    /* clean out old resvs from the conf */
# Line 2685 | Line 2546 | clear_out_old_conf(void)
2546     */
2547  
2548    /* clean out general */
2549 <  MyFree(ConfigFileEntry.servlink_path);
2550 <  ConfigFileEntry.servlink_path = NULL;
2551 < #ifdef HAVE_LIBCRYPTO
2691 <  ConfigFileEntry.default_cipher_preference = NULL;
2692 < #endif /* HAVE_LIBCRYPTO */
2549 >  MyFree(ConfigFileEntry.service_name);
2550 >  ConfigFileEntry.service_name = NULL;
2551 >
2552    delete_isupport("INVEX");
2553    delete_isupport("EXCEPTS");
2554   }
# Line 2800 | Line 2659 | get_conf_ping(struct ConfItem *conf, int
2659      if (aconf->class_ptr != NULL)
2660      {
2661        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2662 <      *pingwarn = PingWarning(aclass);
2663 <      return PingFreq(aclass);
2662 >      *pingwarn = aclass->ping_warning;
2663 >      return aclass->ping_freq;
2664      }
2665    }
2666  
# Line 2817 | Line 2676 | get_conf_ping(struct ConfItem *conf, int
2676   const char *
2677   get_client_class(struct Client *target_p)
2678   {
2679 <  dlink_node *ptr;
2680 <  struct ConfItem *conf;
2681 <  struct AccessItem *aconf;
2679 >  dlink_node *cnode = NULL;
2680 >  struct AccessItem *aconf = NULL;
2681 >
2682 >  assert(!IsMe(target_p));
2683  
2684 <  if (target_p != NULL && !IsMe(target_p) &&
2825 <      target_p->localClient->confs.head != NULL)
2684 >  if ((cnode = target_p->localClient->confs.head))
2685    {
2686 <    DLINK_FOREACH(ptr, target_p->localClient->confs.head)
2828 <    {
2829 <      conf = ptr->data;
2686 >    struct ConfItem *conf = cnode->data;
2687  
2688 <      if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE ||
2689 <          conf->type == OPER_TYPE)
2690 <      {
2691 <        aconf = (struct AccessItem *) map_to_conf(conf);
2692 <        if (aconf->class_ptr != NULL)
2693 <          return aconf->class_ptr->name;
2837 <      }
2838 <    }
2688 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2689 >          (conf->type == OPER_TYPE));
2690 >
2691 >    aconf = map_to_conf(conf);
2692 >    if (aconf->class_ptr != NULL)
2693 >      return aconf->class_ptr->name;
2694    }
2695  
2696    return "default";
# Line 2851 | Line 2706 | get_client_class(struct Client *target_p
2706   int
2707   get_client_ping(struct Client *target_p, int *pingwarn)
2708   {
2709 <  int ping;
2710 <  struct ConfItem *conf;
2856 <  dlink_node *nlink;
2709 >  int ping = 0;
2710 >  dlink_node *cnode = NULL;
2711  
2712 <  if (target_p->localClient->confs.head != NULL)
2713 <    DLINK_FOREACH(nlink, target_p->localClient->confs.head)
2714 <    {
2861 <      conf = nlink->data;
2712 >  if ((cnode = target_p->localClient->confs.head))
2713 >  {
2714 >    struct ConfItem *conf = cnode->data;
2715  
2716 <      if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2717 <          (conf->type == OPER_TYPE))
2718 <      {
2719 <        ping = get_conf_ping(conf, pingwarn);
2720 <        if (ping > 0)
2721 <          return ping;
2722 <      }
2870 <    }
2716 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2717 >          (conf->type == OPER_TYPE));
2718 >
2719 >    ping = get_conf_ping(conf, pingwarn);
2720 >    if (ping > 0)
2721 >      return ping;
2722 >  }
2723  
2724    *pingwarn = 0;
2725    return DEFAULT_PINGFREQUENCY;
# Line 2884 | Line 2736 | find_class(const char *classname)
2736   {
2737    struct ConfItem *conf;
2738  
2739 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2739 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2740      return conf;
2741  
2742    return class_default;
# Line 2905 | Line 2757 | check_class(void)
2757    {
2758      struct ClassItem *aclass = map_to_conf(ptr->data);
2759  
2760 <    if (!aclass->active && !CurrUserCount(aclass))
2760 >    if (!aclass->active && !aclass->curr_user_count)
2761      {
2762        destroy_cidr_class(aclass);
2763        delete_conf_item(ptr->data);
# Line 2929 | Line 2781 | init_class(void)
2781    aclass = map_to_conf(class_default);
2782    aclass->active = 1;
2783    DupString(class_default->name, "default");
2784 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2785 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2786 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2787 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2784 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2785 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2786 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2787 >  aclass->max_sendq = DEFAULT_SENDQ;
2788  
2789    client_check_cb = register_callback("check_client", check_client);
2790   }
# Line 2943 | Line 2795 | init_class(void)
2795   * output       - sendq for this client as found from its class
2796   * side effects - NONE
2797   */
2798 < unsigned long
2798 > unsigned int
2799   get_sendq(struct Client *client_p)
2800   {
2801 <  unsigned long sendq = DEFAULT_SENDQ;
2802 <  dlink_node *ptr;
2951 <  struct ConfItem *conf;
2801 >  unsigned int sendq = DEFAULT_SENDQ;
2802 >  dlink_node *cnode;
2803    struct ConfItem *class_conf;
2804    struct ClassItem *aclass;
2805    struct AccessItem *aconf;
2806  
2807 <  if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
2807 >  assert(!IsMe(client_p));
2808 >
2809 >  if ((cnode = client_p->localClient->confs.head))
2810    {
2811 <    DLINK_FOREACH(ptr, client_p->localClient->confs.head)
2812 <    {
2813 <      conf = ptr->data;
2814 <      if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE)
2815 <          || (conf->type == CLIENT_TYPE))
2816 <      {
2817 <        aconf = (struct AccessItem *)map_to_conf(conf);
2818 <        if ((class_conf = aconf->class_ptr) == NULL)
2819 <          continue;
2820 <        aclass = (struct ClassItem *)map_to_conf(class_conf);
2821 <        sendq = MaxSendq(aclass);
2822 <        return sendq;
2823 <      }
2971 <    }
2811 >    struct ConfItem *conf = cnode->data;
2812 >
2813 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2814 >          (conf->type == OPER_TYPE));
2815 >
2816 >    aconf = map_to_conf(conf);
2817 >
2818 >    if ((class_conf = aconf->class_ptr) == NULL)
2819 >      return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */
2820 >
2821 >    aclass = map_to_conf(class_conf);
2822 >    sendq = aclass->max_sendq;
2823 >    return sendq;
2824    }
2825 +
2826    /* XXX return a default?
2827     * if here, then there wasn't an attached conf with a sendq
2828     * that is very bad -Dianora
# Line 3032 | Line 2885 | conf_add_class_to_conf(struct ConfItem *
2885   int
2886   conf_add_server(struct ConfItem *conf, const char *class_name)
2887   {
2888 <  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);
2888 >  struct AccessItem *aconf = map_to_conf(conf);
2889  
2890    conf_add_class_to_conf(conf, class_name);
2891  
2892    if (!aconf->host || !conf->name)
2893    {
2894      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2895 <    ilog(L_WARN, "Bad connect block");
2895 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2896      return -1;
2897    }
2898  
2899 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2899 >  if (EmptyString(aconf->passwd))
2900    {
2901      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2902                           conf->name);
2903 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2903 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2904      return -1;
2905    }
2906  
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
2907    lookup_confhost(conf);
2908  
2909    return 0;
2910   }
2911  
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
2912   /* yyerror()
2913   *
2914   * inputs       - message from parser
# Line 3121 | Line 2920 | yyerror(const char *msg)
2920   {
2921    char newlinebuf[IRCD_BUFSIZE];
2922  
2923 <  if (ypass != 1)
2923 >  if (conf_parser_ctx.pass != 1)
2924      return;
2925  
2926    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2927    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2928                         conffilebuf, lineno + 1, msg, newlinebuf);
2929 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2929 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2930         conffilebuf, lineno + 1, msg, newlinebuf);
2931   }
2932  
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
2933   /*
2934   * valid_tkline()
2935   *
# Line 3157 | Line 2941 | conf_yy_fatal_error(const char *msg)
2941   * Originally written by Dianora (Diane, db@db.net)
2942   */
2943   time_t
2944 < valid_tkline(char *p, int minutes)
2944 > valid_tkline(const char *p, int minutes)
2945   {
2946    time_t result = 0;
2947  
2948 <  while (*p)
2948 >  for (; *p; ++p)
2949    {
2950 <    if (IsDigit(*p))
3167 <    {
3168 <      result *= 10;
3169 <      result += ((*p) & 0xF);
3170 <      p++;
3171 <    }
3172 <    else
2950 >    if (!IsDigit(*p))
2951        return 0;
2952 +
2953 +    result *= 10;
2954 +    result += ((*p) & 0xF);
2955    }
2956  
2957 <  /* in the degenerate case where oper does a /quote kline 0 user@host :reason
2957 >  /*
2958 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
2959     * i.e. they specifically use 0, I am going to return 1 instead
2960     * as a return value of non-zero is used to flag it as a temporary kline
2961     */
3180
2962    if (result == 0)
2963      result = 1;
2964  
# Line 3278 | Line 3059 | valid_wild_card(struct Client *source_p,
3059   *                if target_server is NULL and an "ON" is found error
3060   *                is reported.
3061   *                if reason pointer is NULL ignore pointer,
3062 < *                this allows usee of parse_a_line in unkline etc.
3062 > *                this allows use of parse_a_line in unkline etc.
3063   *
3064   * - Dianora
3065   */
# Line 3348 | Line 3129 | parse_aline(const char *cmd, struct Clie
3129          return -1;
3130        }
3131  
3132 <      if (!IsOperRemoteBan(source_p))
3132 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3133        {
3134          sendto_one(source_p, form_str(ERR_NOPRIVS),
3135                     me.name, source_p->name, "remoteban");
# Line 3385 | Line 3166 | parse_aline(const char *cmd, struct Clie
3166        return -1;
3167      }
3168  
3169 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3169 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3170        return -1;
3171    }
3172    else
3173 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3173 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3174        return -1;
3175  
3176    if (reason != NULL)
# Line 3397 | Line 3178 | parse_aline(const char *cmd, struct Clie
3178      if (parc != 0 && !EmptyString(*parv))
3179      {
3180        *reason = *parv;
3181 <      if (!valid_comment(source_p, *reason, YES))
3181 >      if (!valid_comment(source_p, *reason, 1))
3182          return -1;
3183      }
3184      else
# Line 3528 | Line 3309 | match_conf_password(const char *password
3309   {
3310    const char *encr = NULL;
3311  
3312 <  if (password == NULL || aconf->passwd == NULL)
3312 >  if (EmptyString(password) || EmptyString(aconf->passwd))
3313      return 0;
3314  
3315    if (aconf->flags & CONF_FLAGS_ENCRYPTED)
3316 <  {
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 <  }
3316 >    encr = crypt(password, aconf->passwd);
3317    else
3318      encr = password;
3319  
# Line 3556 | Line 3326 | match_conf_password(const char *password
3326   * inputs       - client sending the cluster
3327   *              - command name "KLINE" "XLINE" etc.
3328   *              - capab -- CAP_KLN etc. from s_serv.h
3329 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3329 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3330   *              - pattern and args to send along
3331   * output       - none
3332   * side effects - Take source_p send the pattern with args given
# Line 3716 | Line 3486 | cidr_limit_reached(int over_rule,
3486    dlink_node *ptr = NULL;
3487    struct CidrItem *cidr;
3488  
3489 <  if (NumberPerCidr(aclass) <= 0)
3489 >  if (aclass->number_per_cidr <= 0)
3490      return 0;
3491  
3492    if (ip->ss.ss_family == AF_INET)
3493    {
3494 <    if (CidrBitlenIPV4(aclass) <= 0)
3494 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3495        return 0;
3496  
3497      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3498      {
3499        cidr = ptr->data;
3500 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3500 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3501        {
3502 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3502 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3503            return -1;
3504          cidr->number_on_this_cidr++;
3505          return 0;
# Line 3738 | Line 3508 | cidr_limit_reached(int over_rule,
3508      cidr = MyMalloc(sizeof(struct CidrItem));
3509      cidr->number_on_this_cidr = 1;
3510      cidr->mask = *ip;
3511 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3511 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3512      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3513    }
3514   #ifdef IPV6
3515 <  else if (CidrBitlenIPV6(aclass) > 0)
3515 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3516    {
3517      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3518      {
3519        cidr = ptr->data;
3520 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3520 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3521        {
3522 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3522 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3523            return -1;
3524          cidr->number_on_this_cidr++;
3525          return 0;
# Line 3758 | Line 3528 | cidr_limit_reached(int over_rule,
3528      cidr = MyMalloc(sizeof(struct CidrItem));
3529      cidr->number_on_this_cidr = 1;
3530      cidr->mask = *ip;
3531 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3531 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3532      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3533    }
3534   #endif
# Line 3780 | Line 3550 | remove_from_cidr_check(struct irc_ssaddr
3550    dlink_node *next_ptr = NULL;
3551    struct CidrItem *cidr;
3552  
3553 <  if (NumberPerCidr(aclass) == 0)
3553 >  if (aclass->number_per_cidr == 0)
3554      return;
3555  
3556    if (ip->ss.ss_family == AF_INET)
3557    {
3558 <    if (CidrBitlenIPV4(aclass) <= 0)
3558 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3559        return;
3560  
3561      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3562      {
3563        cidr = ptr->data;
3564 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3564 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3565        {
3566          cidr->number_on_this_cidr--;
3567          if (cidr->number_on_this_cidr == 0)
# Line 3804 | Line 3574 | remove_from_cidr_check(struct irc_ssaddr
3574      }
3575    }
3576   #ifdef IPV6
3577 <  else if (CidrBitlenIPV6(aclass) > 0)
3577 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3578    {
3579      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3580      {
3581        cidr = ptr->data;
3582 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3582 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3583        {
3584          cidr->number_on_this_cidr--;
3585          if (cidr->number_on_this_cidr == 0)
# Line 3872 | Line 3642 | rebuild_cidr_class(struct ConfItem *conf
3642   {
3643    struct ClassItem *old_class = map_to_conf(conf);
3644  
3645 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3645 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3646    {
3647 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3647 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3648        rebuild_cidr_list(AF_INET, conf, new_class,
3649                          &old_class->list_ipv4, &new_class->list_ipv4,
3650 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3650 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3651  
3652   #ifdef IPV6
3653 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3653 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3654        rebuild_cidr_list(AF_INET6, conf, new_class,
3655                          &old_class->list_ipv6, &new_class->list_ipv6,
3656 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3656 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3657   #endif
3658    }
3659  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines