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-8/src/s_conf.c (file contents), Revision 1176 by michael, Sun Aug 14 11:24:24 2011 UTC vs.
ircd-hybrid-8/src/conf.c (file contents), Revision 1381 by michael, Tue May 1 08:21:27 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 26 | Line 26
26   #include "list.h"
27   #include "ircd_defs.h"
28   #include "balloc.h"
29 < #include "s_conf.h"
29 > #include "conf.h"
30   #include "s_serv.h"
31   #include "resv.h"
32   #include "channel.h"
33   #include "client.h"
34 #include "common.h"
34   #include "event.h"
36 #include "hash.h"
35   #include "hook.h"
36   #include "irc_string.h"
39 #include "sprintf_irc.h"
37   #include "s_bsd.h"
38   #include "ircd.h"
39   #include "listener.h"
# Line 44 | Line 41
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"
50 #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;
# Line 72 | Line 70 | dlink_list nresv_items   = { NULL, NULL,
70   dlink_list class_items   = { NULL, NULL, 0 };
71   dlink_list gdeny_items   = { NULL, NULL, 0 };
72  
75 dlink_list temporary_klines  = { NULL, NULL, 0 };
76 dlink_list temporary_dlines  = { NULL, NULL, 0 };
73   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 };
74   dlink_list temporary_resv = { NULL, NULL, 0 };
75  
76   extern unsigned int lineno;
77   extern char linebuf[];
78   extern char conffilebuf[IRCD_BUFSIZE];
86 extern char yytext[];
79   extern int yyparse(); /* defined in y.tab.c */
80  
81   struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
82  
83   /* internally defined functions */
84 < static void lookup_confhost(struct ConfItem *);
93 < static void set_default_conf(void);
94 < static void validate_conf(void);
95 < static void read_conf(FBFILE *);
84 > static void read_conf(FILE *);
85   static void clear_out_old_conf(void);
86   static void flush_deleted_I_P(void);
87   static void expire_tklines(dlink_list *);
# Line 335 | Line 324 | make_conf_item(ConfType type)
324  
325      aclass = map_to_conf(conf);
326      aclass->active = 1;
327 <    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
328 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
329 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
330 <    MaxSendq(aclass) = DEFAULT_SENDQ;
327 >    aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
328 >    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
329 >    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
330 >    aclass->max_sendq = DEFAULT_SENDQ;
331  
332      break;
333  
# Line 389 | Line 378 | delete_conf_item(struct ConfItem *conf)
378      MyFree(aconf->oper_reason);
379      MyFree(aconf->user);
380      MyFree(aconf->host);
381 +    MyFree(aconf->cipher_list);
382   #ifdef HAVE_LIBCRYPTO
383      if (aconf->rsa_public_key)
384        RSA_free(aconf->rsa_public_key);
# Line 571 | Line 561 | static const unsigned int shared_bit_tab
561   * side effects -
562   */
563   void
564 < report_confitem_types(struct Client *source_p, ConfType type, int temp)
564 > report_confitem_types(struct Client *source_p, ConfType type)
565   {
566    dlink_node *ptr = NULL;
567    struct ConfItem *conf = NULL;
# Line 580 | Line 570 | report_confitem_types(struct Client *sou
570    struct ClassItem *classitem = NULL;
571    char buf[12];
572    char *p = NULL;
583  const char *pfx = NULL;
573  
574    switch (type)
575    {
# Line 632 | Line 621 | report_confitem_types(struct Client *sou
621  
622        sendto_one(source_p, form_str(RPL_STATSXLINE),
623                   me.name, source_p->name,
624 <                 matchitem->hold ? "xR": "XR", matchitem->count,
624 >                 "XR", matchitem->count,
625                   conf->name, matchitem->reason);
626      }
627      break;
628  
629    case RKLINE_TYPE:
641    pfx = temp ? "kR" : "KR";
642
630      DLINK_FOREACH(ptr, rkconf_items.head)
631      {
632        aconf = map_to_conf((conf = ptr->data));
633  
647      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
648        continue;
649
634        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
635 <                 source_p->name, pfx, aconf->host, aconf->user,
635 >                 source_p->name, "KR", aconf->host, aconf->user,
636                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
637      }
638      break;
# Line 697 | Line 681 | report_confitem_types(struct Client *sou
681        aconf = map_to_conf(conf);
682  
683        /* Don't allow non opers to see oper privs */
684 <      if (IsOper(source_p))
684 >      if (HasUMode(source_p, UMODE_OPER))
685          sendto_one(source_p, form_str(RPL_STATSOLINE),
686                     me.name, source_p->name, 'O', aconf->user, aconf->host,
687                     conf->name, oper_privs_as_string(aconf->port),
# Line 717 | Line 701 | report_confitem_types(struct Client *sou
701        classitem = map_to_conf(conf);
702        sendto_one(source_p, form_str(RPL_STATSYLINE),
703                   me.name, source_p->name, 'Y',
704 <                 conf->name, PingFreq(classitem),
705 <                 ConFreq(classitem),
706 <                 MaxTotal(classitem), MaxSendq(classitem),
707 <                 CurrUserCount(classitem),
704 >                 conf->name, classitem->ping_freq,
705 >                 classitem->con_freq,
706 >                 classitem->max_total, classitem->max_sendq,
707 >                 classitem->curr_user_count,
708                   classitem->active ? "active" : "disabled");
709      }
710      break;
# Line 750 | Line 734 | report_confitem_types(struct Client *sou
734  
735        if (IsConfAllowAutoConn(aconf))
736          *p++ = 'A';
737 <      if (IsConfCryptLink(aconf))
738 <        *p++ = 'C';
737 >      if (IsConfSSL(aconf))
738 >        *p++ = 'S';
739        if (IsConfTopicBurst(aconf))
740          *p++ = 'T';
757      if (IsConfCompressed(aconf))
758        *p++ = 'Z';
741        if (buf[0] == '\0')
742          *p++ = '*';
743  
# Line 764 | Line 746 | report_confitem_types(struct Client *sou
746        /*
747         * Allow admins to see actual ips unless hide_server_ips is enabled
748         */
749 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
749 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
750          sendto_one(source_p, form_str(RPL_STATSCLINE),
751                     me.name, source_p->name, 'C', aconf->host,
752                     buf, conf->name, aconf->port,
# Line 831 | Line 813 | check_client(va_list args)
813  
814    /* I'm already in big trouble if source_p->localClient is NULL -db */
815    if ((i = verify_access(source_p, username)))
816 <    ilog(L_INFO, "Access denied: %s[%s]",
816 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
817           source_p->name, source_p->sockhost);
818  
819    switch (i)
# Line 841 | Line 823 | check_client(va_list args)
823                             "Too many on IP for %s (%s).",
824                             get_client_name(source_p, SHOW_IP),
825                             source_p->sockhost);
826 <      ilog(L_INFO,"Too many connections on IP from %s.",
826 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
827             get_client_name(source_p, SHOW_IP));
828        ++ServerStats.is_ref;
829        exit_client(source_p, &me, "No more connections allowed on that IP");
# Line 852 | Line 834 | check_client(va_list args)
834                             "I-line is full for %s (%s).",
835                             get_client_name(source_p, SHOW_IP),
836                             source_p->sockhost);
837 <      ilog(L_INFO,"Too many connections from %s.",
837 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
838             get_client_name(source_p, SHOW_IP));
839        ++ServerStats.is_ref;
840        exit_client(source_p, &me,
# Line 869 | Line 851 | check_client(va_list args)
851                             source_p->sockhost,
852                             source_p->localClient->listener->name,
853                             source_p->localClient->listener->port);
854 <      ilog(L_INFO,
854 >      ilog(LOG_TYPE_IRCD,
855            "Unauthorized client connection from %s on [%s/%u].",
856            get_client_name(source_p, SHOW_IP),
857            source_p->localClient->listener->name,
# Line 1032 | Line 1014 | attach_iline(struct Client *client_p, st
1014     * setting a_limit_reached if any limit is reached.
1015     * - Dianora
1016     */
1017 <  if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
1017 >  if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
1018      a_limit_reached = 1;
1019 <  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
1019 >  else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
1020      a_limit_reached = 1;
1021 <  else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
1021 >  else if (aclass->max_local != 0 && local >= aclass->max_local)
1022      a_limit_reached = 1;
1023 <  else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))
1023 >  else if (aclass->max_global != 0 && global >= aclass->max_global)
1024      a_limit_reached = 1;
1025 <  else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&
1025 >  else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
1026             client_p->username[0] != '~')
1027      a_limit_reached = 1;
1028  
# Line 1323 | Line 1305 | detach_conf(struct Client *client_p, Con
1305  
1306          assert(aconf->clients > 0);
1307  
1308 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1308 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1309          {
1310            aclass = map_to_conf(aclass_conf);
1311  
# Line 1389 | Line 1371 | attach_conf(struct Client *client_p, str
1371                               &client_p->localClient->ip, aclass))
1372          return TOO_MANY;    /* Already at maximum allowed */
1373  
1374 <    CurrUserCount(aclass)++;
1374 >    aclass->curr_user_count++;
1375      aconf->clients++;
1376    }
1377    else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
# Line 1485 | Line 1467 | find_conf_exact(ConfType type, const cha
1467      {
1468        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1469  
1470 <      if (aconf->clients >= MaxTotal(aclass))
1470 >      if (aconf->clients >= aclass->max_total)
1471          continue;
1472      }
1473  
# Line 1672 | Line 1654 | find_matching_name_conf(ConfType type, c
1654   * side effects - looks for an exact match on name field
1655   */
1656   struct ConfItem *
1657 < find_exact_name_conf(ConfType type, const char *name,
1657 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1658                       const char *user, const char *host)
1659   {
1660    dlink_node *ptr = NULL;
# Line 1713 | Line 1695 | find_exact_name_conf(ConfType type, cons
1695      DLINK_FOREACH(ptr, list_p->head)
1696      {
1697        conf = ptr->data;
1698 <      aconf = (struct AccessItem *)map_to_conf(conf);
1698 >      aconf = map_to_conf(conf);
1699 >
1700        if (EmptyString(conf->name))
1701 <        continue;
1702 <    
1703 <      if (irccmp(conf->name, name) == 0)
1701 >        continue;
1702 >
1703 >      if (!irccmp(conf->name, name))
1704        {
1705 <        if ((user == NULL && (host == NULL)))
1706 <          return (conf);
1707 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1708 <          return (conf);
1709 <        if (match(aconf->user, user) && match(aconf->host, host))
1710 <          return (conf);
1705 >        if (!who)
1706 >          return conf;
1707 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1708 >          return conf;
1709 >        if (match(aconf->user, who->username))
1710 >        {
1711 >          switch (aconf->type)
1712 >          {
1713 >            case HM_HOST:
1714 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1715 >                return conf;
1716 >              break;
1717 >            case HM_IPV4:
1718 >              if (who->localClient->aftype == AF_INET)
1719 >                if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits))
1720 >                  return conf;
1721 >              break;
1722 > #ifdef IPV6
1723 >            case HM_IPV6:
1724 >              if (who->localClient->aftype == AF_INET6)
1725 >                if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits))
1726 >                  return conf;
1727 >              break;
1728 > #endif
1729 >            default:
1730 >              assert(0);
1731 >          }
1732 >        }
1733        }
1734      }
1735 +
1736      break;
1737  
1738    case SERVER_TYPE:
# Line 1799 | Line 1805 | rehash(int sig)
1805    flush_deleted_I_P();
1806  
1807    rehashed_klines = 1;
1808 <
1808 > /* XXX */
1809    if (ConfigLoggingEntry.use_logging)
1810 <    reopen_log(logFileName);
1810 >    log_close_all();
1811  
1812    return(0);
1813   }
# Line 1848 | Line 1854 | set_default_conf(void)
1854    AdminInfo.email = NULL;
1855    AdminInfo.description = NULL;
1856  
1857 <  set_log_level(L_NOTICE);
1857 >  log_close_all();
1858 >
1859    ConfigLoggingEntry.use_logging = 1;
1860 <  ConfigLoggingEntry.operlog[0] = '\0';
1861 <  ConfigLoggingEntry.userlog[0] = '\0';
1862 <  ConfigLoggingEntry.klinelog[0] = '\0';
1863 <  ConfigLoggingEntry.glinelog[0] = '\0';
1864 <  ConfigLoggingEntry.killlog[0] = '\0';
1865 <  ConfigLoggingEntry.operspylog[0] = '\0';
1866 <  ConfigLoggingEntry.ioerrlog[0] = '\0';
1860 <  ConfigLoggingEntry.failed_operlog[0] = '\0';
1861 <
1862 <  ConfigChannel.disable_fake_channels = NO;
1863 <  ConfigChannel.restrict_channels = NO;
1864 <  ConfigChannel.disable_local_channels = NO;
1865 <  ConfigChannel.use_invex = YES;
1866 <  ConfigChannel.use_except = YES;
1867 <  ConfigChannel.use_knock = YES;
1860 >
1861 >  ConfigChannel.disable_fake_channels = 0;
1862 >  ConfigChannel.restrict_channels = 0;
1863 >  ConfigChannel.disable_local_channels = 0;
1864 >  ConfigChannel.use_invex = 1;
1865 >  ConfigChannel.use_except = 1;
1866 >  ConfigChannel.use_knock = 1;
1867    ConfigChannel.knock_delay = 300;
1868    ConfigChannel.knock_delay_channel = 60;
1869    ConfigChannel.max_chans_per_user = 15;
1870 <  ConfigChannel.quiet_on_ban = YES;
1870 >  ConfigChannel.quiet_on_ban = 1;
1871    ConfigChannel.max_bans = 25;
1872    ConfigChannel.default_split_user_count = 0;
1873    ConfigChannel.default_split_server_count = 0;
1874 <  ConfigChannel.no_join_on_split = NO;
1875 <  ConfigChannel.no_create_on_split = NO;
1876 <  ConfigChannel.burst_topicwho = YES;
1874 >  ConfigChannel.no_join_on_split = 0;
1875 >  ConfigChannel.no_create_on_split = 0;
1876 >  ConfigChannel.burst_topicwho = 1;
1877  
1878 <  ConfigServerHide.flatten_links = NO;
1878 >  ConfigServerHide.flatten_links = 0;
1879    ConfigServerHide.links_delay = 300;
1880 <  ConfigServerHide.hidden = NO;
1881 <  ConfigServerHide.disable_hidden = NO;
1882 <  ConfigServerHide.hide_servers = NO;
1880 >  ConfigServerHide.hidden = 0;
1881 >  ConfigServerHide.disable_hidden = 0;
1882 >  ConfigServerHide.hide_servers = 0;
1883    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1884 <  ConfigServerHide.hide_server_ips = NO;
1884 >  ConfigServerHide.hide_server_ips = 0;
1885  
1886    
1887    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1888    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1889    ConfigFileEntry.gline_min_cidr = 16;
1890    ConfigFileEntry.gline_min_cidr6 = 48;
1891 <  ConfigFileEntry.invisible_on_connect = YES;
1892 <  ConfigFileEntry.burst_away = NO;
1893 <  ConfigFileEntry.use_whois_actually = YES;
1894 <  ConfigFileEntry.tkline_expire_notices = YES;
1895 <  ConfigFileEntry.hide_spoof_ips = YES;
1896 <  ConfigFileEntry.ignore_bogus_ts = NO;
1897 <  ConfigFileEntry.disable_auth = NO;
1898 <  ConfigFileEntry.disable_remote = NO;
1891 >  ConfigFileEntry.invisible_on_connect = 1;
1892 >  ConfigFileEntry.burst_away = 0;
1893 >  ConfigFileEntry.use_whois_actually = 1;
1894 >  ConfigFileEntry.tkline_expire_notices = 1;
1895 >  ConfigFileEntry.hide_spoof_ips = 1;
1896 >  ConfigFileEntry.ignore_bogus_ts = 0;
1897 >  ConfigFileEntry.disable_auth = 0;
1898 >  ConfigFileEntry.disable_remote = 0;
1899    ConfigFileEntry.kill_chase_time_limit = 90;
1900    ConfigFileEntry.default_floodcount = 8;
1901 <  ConfigFileEntry.failed_oper_notice = YES;
1901 >  ConfigFileEntry.failed_oper_notice = 1;
1902    ConfigFileEntry.dots_in_ident = 0;
1903    ConfigFileEntry.min_nonwildcard = 4;
1904    ConfigFileEntry.min_nonwildcard_simple = 3;
1905    ConfigFileEntry.max_accept = 20;
1906 <  ConfigFileEntry.anti_nick_flood = NO;
1906 >  ConfigFileEntry.anti_nick_flood = 0;
1907    ConfigFileEntry.max_nick_time = 20;
1908    ConfigFileEntry.max_nick_changes = 5;
1909    ConfigFileEntry.anti_spam_exit_message_time = 0;
1910    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1911    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1912 <  ConfigFileEntry.kline_with_reason = YES;
1912 >  ConfigFileEntry.kline_with_reason = 1;
1913    ConfigFileEntry.kline_reason = NULL;
1914 <  ConfigFileEntry.warn_no_nline = YES;
1915 <  ConfigFileEntry.stats_o_oper_only = NO;
1914 >  ConfigFileEntry.warn_no_nline = 1;
1915 >  ConfigFileEntry.stats_o_oper_only = 0;
1916    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1917    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1918 <  ConfigFileEntry.stats_P_oper_only = NO;
1918 >  ConfigFileEntry.stats_P_oper_only = 0;
1919    ConfigFileEntry.caller_id_wait = 60;
1920 <  ConfigFileEntry.opers_bypass_callerid = NO;
1920 >  ConfigFileEntry.opers_bypass_callerid = 0;
1921    ConfigFileEntry.pace_wait = 10;
1922    ConfigFileEntry.pace_wait_simple = 1;
1923 <  ConfigFileEntry.short_motd = NO;
1924 <  ConfigFileEntry.ping_cookie = NO;
1925 <  ConfigFileEntry.no_oper_flood = NO;
1926 <  ConfigFileEntry.true_no_oper_flood = NO;
1927 <  ConfigFileEntry.oper_pass_resv = YES;
1928 <  ConfigFileEntry.glines = NO;
1923 >  ConfigFileEntry.short_motd = 0;
1924 >  ConfigFileEntry.ping_cookie = 0;
1925 >  ConfigFileEntry.no_oper_flood = 0;
1926 >  ConfigFileEntry.true_no_oper_flood = 0;
1927 >  ConfigFileEntry.oper_pass_resv = 1;
1928 >  ConfigFileEntry.glines = 0;
1929    ConfigFileEntry.gline_time = 12 * 3600;
1930    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1931    ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1932    ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1933    ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1934      UMODE_OPERWALL | UMODE_WALLOP;
1935 <  DupString(ConfigFileEntry.servlink_path, SLPATH);
1937 < #ifdef HAVE_LIBCRYPTO
1938 <  /* jdc -- This is our default value for a cipher.  According to the
1939 <   *        CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
1940 <   *        under all circumstances if cryptlinks are enabled.  So,
1941 <   *        this will be our default.
1942 <   *
1943 <   *        NOTE: I apologise for the hard-coded value of "1" (BF/128).
1944 <   *              This should be moved into a find_cipher() routine.
1945 <   */
1946 <  ConfigFileEntry.default_cipher_preference = &CipherTable[1];
1947 < #endif
1948 <  ConfigFileEntry.use_egd = NO;
1935 >  ConfigFileEntry.use_egd = 0;
1936    ConfigFileEntry.egdpool_path = NULL;
1950 #ifdef HAVE_LIBZ
1951  ConfigFileEntry.compression_level = 0;
1952 #endif
1937    ConfigFileEntry.throttle_time = 10;
1938   }
1939  
1956 /* read_conf()
1957 *
1958 * inputs       - file descriptor pointing to config file to use
1959 * output       - None
1960 * side effects - Read configuration file.
1961 */
1962 static void
1963 read_conf(FBFILE *file)
1964 {
1965  lineno = 0;
1966
1967  set_default_conf(); /* Set default values prior to conf parsing */
1968  conf_parser_ctx.pass = 1;
1969  yyparse();          /* pick up the classes first */
1970
1971  fbrewind(file);
1972
1973  conf_parser_ctx.pass = 2;
1974  yyparse();          /* Load the values from the conf */
1975  validate_conf();    /* Check to make sure some values are still okay. */
1976                      /* Some global values are also loaded here. */
1977  check_class();      /* Make sure classes are valid */
1978 }
1979
1940   static void
1941   validate_conf(void)
1942   {
# Line 1986 | Line 1946 | validate_conf(void)
1946    if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1947      ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1948  
1989  if (ConfigFileEntry.servlink_path == NULL)
1990    DupString(ConfigFileEntry.servlink_path, SLPATH);
1991
1949    if (ServerInfo.network_name == NULL)
1950      DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1951  
# Line 2005 | Line 1962 | validate_conf(void)
1962    ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1963   }
1964  
1965 + /* read_conf()
1966 + *
1967 + * inputs       - file descriptor pointing to config file to use
1968 + * output       - None
1969 + * side effects - Read configuration file.
1970 + */
1971 + static void
1972 + read_conf(FILE *file)
1973 + {
1974 +  lineno = 0;
1975 +
1976 +  set_default_conf(); /* Set default values prior to conf parsing */
1977 +  conf_parser_ctx.pass = 1;
1978 +  yyparse();          /* pick up the classes first */
1979 +
1980 +  rewind(file);
1981 +
1982 +  conf_parser_ctx.pass = 2;
1983 +  yyparse();          /* Load the values from the conf */
1984 +  validate_conf();    /* Check to make sure some values are still okay. */
1985 +                      /* Some global values are also loaded here. */
1986 +  check_class();      /* Make sure classes are valid */
1987 + }
1988 +
1989   /* lookup_confhost()
1990   *
1991   * start DNS lookups of all hostnames in the conf
# Line 2021 | Line 2002 | lookup_confhost(struct ConfItem *conf)
2002    if (EmptyString(aconf->host) ||
2003        EmptyString(aconf->user))
2004    {
2005 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
2005 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
2006           aconf->host, conf->name);
2007      return;
2008    }
# Line 2168 | Line 2149 | find_gline(struct Client *client_p)
2149   void
2150   add_temp_line(struct ConfItem *conf)
2151   {
2152 <  struct AccessItem *aconf;
2172 <
2173 <  if (conf->type == DLINE_TYPE)
2174 <  {
2175 <    aconf = map_to_conf(conf);
2176 <    SetConfTemporary(aconf);
2177 <    dlinkAdd(conf, &conf->node, &temporary_dlines);
2178 <    MyFree(aconf->user);
2179 <    aconf->user = NULL;
2180 <    add_conf_by_address(CONF_DLINE, aconf);
2181 <  }
2182 <  else if (conf->type == KLINE_TYPE)
2183 <  {
2184 <    aconf = map_to_conf(conf);
2185 <    SetConfTemporary(aconf);
2186 <    dlinkAdd(conf, &conf->node, &temporary_klines);
2187 <    add_conf_by_address(CONF_KILL, aconf);
2188 <  }
2189 <  else if (conf->type == GLINE_TYPE)
2190 <  {
2191 <    aconf = map_to_conf(conf);
2192 <    SetConfTemporary(aconf);
2193 <    dlinkAdd(conf, &conf->node, &temporary_glines);
2194 <    add_conf_by_address(CONF_GLINE, aconf);
2195 <  }
2196 <  else if (conf->type == XLINE_TYPE)
2152 >  if (conf->type == XLINE_TYPE)
2153    {
2154      conf->flags |= CONF_FLAGS_TEMPORARY;
2155      dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2156    }
2201  else if (conf->type == RXLINE_TYPE)
2202  {
2203    conf->flags |= CONF_FLAGS_TEMPORARY;
2204    dlinkAdd(conf, make_dlink_node(), &temporary_rxlines);
2205  }
2206  else if (conf->type == RKLINE_TYPE)
2207  {
2208    conf->flags |= CONF_FLAGS_TEMPORARY;
2209    dlinkAdd(conf, make_dlink_node(), &temporary_rklines);
2210  }
2157    else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2158    {
2159      conf->flags |= CONF_FLAGS_TEMPORARY;
# Line 2225 | Line 2171 | add_temp_line(struct ConfItem *conf)
2171   void
2172   cleanup_tklines(void *notused)
2173   {
2174 <  expire_tklines(&temporary_glines);
2229 <  expire_tklines(&temporary_klines);
2230 <  expire_tklines(&temporary_dlines);
2174 >  hostmask_expire_temporary();
2175    expire_tklines(&temporary_xlines);
2232  expire_tklines(&temporary_rxlines);
2233  expire_tklines(&temporary_rklines);
2176    expire_tklines(&temporary_resv);
2177   }
2178  
# Line 2248 | Line 2190 | expire_tklines(dlink_list *tklist)
2190    struct ConfItem *conf;
2191    struct MatchItem *xconf;
2192    struct MatchItem *nconf;
2251  struct AccessItem *aconf;
2193    struct ResvChannel *cconf;
2194  
2195    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2196    {
2197      conf = ptr->data;
2257    if (conf->type == GLINE_TYPE ||
2258        conf->type == KLINE_TYPE ||
2259        conf->type == DLINE_TYPE)
2260    {
2261      aconf = (struct AccessItem *)map_to_conf(conf);
2262      if (aconf->hold <= CurrentTime)
2263      {
2264        /* XXX - Do we want GLINE expiry notices?? */
2265        /* Alert opers that a TKline expired - Hwy */
2266        if (ConfigFileEntry.tkline_expire_notices)
2267        {
2268          if (aconf->status & CONF_KILL)
2269          {
2270            sendto_realops_flags(UMODE_ALL, L_ALL,
2271                                 "Temporary K-line for [%s@%s] expired",
2272                                 (aconf->user) ? aconf->user : "*",
2273                                 (aconf->host) ? aconf->host : "*");
2274          }
2275          else if (conf->type == DLINE_TYPE)
2276          {
2277            sendto_realops_flags(UMODE_ALL, L_ALL,
2278                                 "Temporary D-line for [%s] expired",
2279                                 (aconf->host) ? aconf->host : "*");
2280          }
2281        }
2198  
2199 <        dlinkDelete(ptr, tklist);
2284 <        delete_one_address_conf(aconf->host, aconf);
2285 <      }
2286 <    }
2287 <    else if (conf->type == XLINE_TYPE ||
2288 <             conf->type == RXLINE_TYPE)
2199 >    if (conf->type == XLINE_TYPE)
2200      {
2201        xconf = (struct MatchItem *)map_to_conf(conf);
2202        if (xconf->hold <= CurrentTime)
2203        {
2204          if (ConfigFileEntry.tkline_expire_notices)
2205            sendto_realops_flags(UMODE_ALL, L_ALL,
2206 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2296 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2206 >                               "Temporary X-line for [%s] sexpired", conf->name);
2207          dlinkDelete(ptr, tklist);
2208          free_dlink_node(ptr);
2209          delete_conf_item(conf);
2210        }
2211      }
2302    else if (conf->type == RKLINE_TYPE)
2303    {
2304      aconf = map_to_conf(conf);
2305      if (aconf->hold <= CurrentTime)
2306      {
2307        if (ConfigFileEntry.tkline_expire_notices)
2308           sendto_realops_flags(UMODE_ALL, L_ALL,
2309                                "Temporary K-line for [%s@%s] (REGEX) expired",
2310                                (aconf->user) ? aconf->user : "*",
2311                                (aconf->host) ? aconf->host : "*");
2312        dlinkDelete(ptr, tklist);
2313        free_dlink_node(ptr);
2314        delete_conf_item(conf);
2315      }
2316    }
2212      else if (conf->type == NRESV_TYPE)
2213      {
2214        nconf = (struct MatchItem *)map_to_conf(conf);
# Line 2350 | Line 2245 | expire_tklines(dlink_list *tklist)
2245   static const struct oper_privs
2246   {
2247    const unsigned int oprivs;
2353  const unsigned int hidden;
2248    const unsigned char c;
2249   } flag_list[] = {
2250 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2251 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2252 <  { OPER_FLAG_DIE,         0,                       'D' },
2253 <  { OPER_FLAG_GLINE,       0,                       'G' },
2254 <  { OPER_FLAG_REHASH,      0,                       'H' },
2255 <  { OPER_FLAG_K,           0,                       'K' },
2256 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2257 <  { OPER_FLAG_N,           0,                       'N' },
2258 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2259 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2260 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2261 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2262 <  { OPER_FLAG_X,           0,                       'X' },
2263 <  { 0, 0, '\0' }
2250 >  { OPER_FLAG_ADMIN,       'A' },
2251 >  { OPER_FLAG_REMOTEBAN,   'B' },
2252 >  { OPER_FLAG_DIE,         'D' },
2253 >  { OPER_FLAG_GLINE,       'G' },
2254 >  { OPER_FLAG_REHASH,      'H' },
2255 >  { OPER_FLAG_K,           'K' },
2256 >  { OPER_FLAG_OPERWALL,    'L' },
2257 >  { OPER_FLAG_N,           'N' },
2258 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2259 >  { OPER_FLAG_REMOTE,      'R' },
2260 >  { OPER_FLAG_OPER_SPY,    'S' },
2261 >  { OPER_FLAG_UNKLINE,     'U' },
2262 >  { OPER_FLAG_X,           'X' },
2263 >  { 0, '\0' }
2264   };
2265  
2266   char *
# Line 2378 | Line 2272 | oper_privs_as_string(const unsigned int
2272  
2273    for (; flag_list[i].oprivs; ++i)
2274    {
2275 <    if ((port & flag_list[i].oprivs) &&
2382 <        (port & flag_list[i].hidden) == 0)
2275 >    if (port & flag_list[i].oprivs)
2276        *privs_ptr++ = flag_list[i].c;
2277      else
2278        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2396 | Line 2289 | oper_privs_as_string(const unsigned int
2289   *         "oper" is server name for remote opers
2290   * Side effects: None.
2291   */
2292 < char *
2292 > const char *
2293   get_oper_name(const struct Client *client_p)
2294   {
2295 <  dlink_node *cnode;
2403 <  struct ConfItem *conf;
2404 <  struct AccessItem *aconf;
2405 <
2295 >  dlink_node *cnode = NULL;
2296    /* +5 for !,@,{,} and null */
2297    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2298  
2299    if (MyConnect(client_p))
2300    {
2301 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2301 >    if ((cnode = client_p->localClient->confs.head))
2302      {
2303 <      conf = cnode->data;
2304 <      aconf = map_to_conf(conf);
2303 >      struct ConfItem *conf = cnode->data;
2304 >      const struct AccessItem *aconf = map_to_conf(conf);
2305  
2306        if (IsConfOperator(aconf))
2307        {
# Line 2456 | Line 2346 | read_conf_files(int cold)
2346    */
2347    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2348  
2349 <  if ((conf_parser_ctx.conf_file = fbopen(filename, "r")) == NULL)
2349 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2350    {
2351      if (cold)
2352      {
2353 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2353 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2354             filename, strerror(errno));
2355        exit(-1);
2356      }
# Line 2477 | Line 2367 | read_conf_files(int cold)
2367      clear_out_old_conf();
2368  
2369    read_conf(conf_parser_ctx.conf_file);
2370 <  fbclose(conf_parser_ctx.conf_file);
2370 >  fclose(conf_parser_ctx.conf_file);
2371  
2372    add_isupport("NETWORK", ServerInfo.network_name, -1);
2373    snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d",
# Line 2532 | Line 2422 | read_conf_files(int cold)
2422   static void
2423   parse_conf_file(int type, int cold)
2424   {
2425 <  FBFILE *file = NULL;
2425 >  FILE *file = NULL;
2426    const char *filename = get_conf_name(type);
2427  
2428 <  if ((file = fbopen(filename, "r")) == NULL)
2428 >  if ((file = fopen(filename, "r")) == NULL)
2429    {
2430      if (cold)
2431 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2431 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2432             filename, strerror(errno));
2433      else
2434        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2548 | Line 2438 | parse_conf_file(int type, int cold)
2438    else
2439    {
2440      parse_csv_file(file, type);
2441 <    fbclose(file);
2441 >    fclose(file);
2442    }
2443   }
2444  
# Line 2612 | Line 2502 | clear_out_old_conf(void)
2502            delete_conf_item(conf);
2503          }
2504        }
2615      else if (conf->type == CLIENT_TYPE)
2616      {
2617        aconf = map_to_conf(conf);
2618
2619        if (aconf->clients != 0)
2620        {
2621          SetConfIllegal(aconf);
2622        }
2623        else
2624        {
2625          delete_conf_item(conf);
2626        }
2627      }
2505        else if (conf->type == XLINE_TYPE  ||
2506                 conf->type == RXLINE_TYPE ||
2507                 conf->type == RKLINE_TYPE)
# Line 2690 | Line 2567 | clear_out_old_conf(void)
2567  
2568    MyFree(ServerInfo.rsa_private_key_file);
2569    ServerInfo.rsa_private_key_file = NULL;
2570 +
2571 +  if (ServerInfo.server_ctx)
2572 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2573 +                                               SSL_OP_NO_SSLv3|
2574 +                                               SSL_OP_NO_TLSv1);
2575 +  if (ServerInfo.client_ctx)
2576 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2577 +                                               SSL_OP_NO_SSLv3|
2578 +                                               SSL_OP_NO_TLSv1);
2579   #endif
2580  
2581    /* clean out old resvs from the conf */
# Line 2715 | Line 2601 | clear_out_old_conf(void)
2601    MyFree(ConfigFileEntry.service_name);
2602    ConfigFileEntry.service_name = NULL;
2603  
2718  MyFree(ConfigFileEntry.servlink_path);
2719  ConfigFileEntry.servlink_path = NULL;
2720 #ifdef HAVE_LIBCRYPTO
2721  ConfigFileEntry.default_cipher_preference = NULL;
2722 #endif /* HAVE_LIBCRYPTO */
2604    delete_isupport("INVEX");
2605    delete_isupport("EXCEPTS");
2606   }
# Line 2830 | Line 2711 | get_conf_ping(struct ConfItem *conf, int
2711      if (aconf->class_ptr != NULL)
2712      {
2713        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2714 <      *pingwarn = PingWarning(aclass);
2715 <      return PingFreq(aclass);
2714 >      *pingwarn = aclass->ping_warning;
2715 >      return aclass->ping_freq;
2716      }
2717    }
2718  
# Line 2914 | Line 2795 | find_class(const char *classname)
2795   {
2796    struct ConfItem *conf;
2797  
2798 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2798 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2799      return conf;
2800  
2801    return class_default;
# Line 2935 | Line 2816 | check_class(void)
2816    {
2817      struct ClassItem *aclass = map_to_conf(ptr->data);
2818  
2819 <    if (!aclass->active && !CurrUserCount(aclass))
2819 >    if (!aclass->active && !aclass->curr_user_count)
2820      {
2821        destroy_cidr_class(aclass);
2822        delete_conf_item(ptr->data);
# Line 2959 | Line 2840 | init_class(void)
2840    aclass = map_to_conf(class_default);
2841    aclass->active = 1;
2842    DupString(class_default->name, "default");
2843 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2844 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2845 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2846 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2843 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2844 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2845 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2846 >  aclass->max_sendq = DEFAULT_SENDQ;
2847  
2848    client_check_cb = register_callback("check_client", check_client);
2849   }
# Line 2995 | Line 2876 | get_sendq(struct Client *client_p)
2876          if ((class_conf = aconf->class_ptr) == NULL)
2877            continue;
2878          aclass = (struct ClassItem *)map_to_conf(class_conf);
2879 <        sendq = MaxSendq(aclass);
2879 >        sendq = aclass->max_sendq;
2880          return sendq;
2881        }
2882      }
# Line 3062 | Line 2943 | conf_add_class_to_conf(struct ConfItem *
2943   int
2944   conf_add_server(struct ConfItem *conf, const char *class_name)
2945   {
2946 <  struct AccessItem *aconf;
3066 <  struct split_nuh_item nuh;
3067 <  char conf_user[USERLEN + 1];
3068 <  char conf_host[HOSTLEN + 1];
3069 <
3070 <  aconf = map_to_conf(conf);
2946 >  struct AccessItem *aconf = map_to_conf(conf);
2947  
2948    conf_add_class_to_conf(conf, class_name);
2949  
2950    if (!aconf->host || !conf->name)
2951    {
2952      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2953 <    ilog(L_WARN, "Bad connect block");
2953 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2954      return -1;
2955    }
2956  
2957 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2957 >  if (EmptyString(aconf->passwd))
2958    {
2959      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2960                           conf->name);
2961 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2961 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2962      return -1;
2963    }
2964  
3089  nuh.nuhmask  = aconf->host;
3090  nuh.nickptr  = NULL;
3091  nuh.userptr  = conf_user;
3092  nuh.hostptr  = conf_host;
3093
3094  nuh.nicksize = 0;
3095  nuh.usersize = sizeof(conf_user);
3096  nuh.hostsize = sizeof(conf_host);
3097
3098  split_nuh(&nuh);
3099
3100  MyFree(aconf->host);
3101  aconf->host = NULL;
3102
3103  DupString(aconf->user, conf_user); /* somehow username checking for servers
3104                                 got lost in H6/7, will have to be re-added */
3105  DupString(aconf->host, conf_host);
3106
2965    lookup_confhost(conf);
2966  
2967    return 0;
# Line 3126 | Line 2984 | yyerror(const char *msg)
2984    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2985    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2986                         conffilebuf, lineno + 1, msg, newlinebuf);
2987 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2987 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2988         conffilebuf, lineno + 1, msg, newlinebuf);
2989   }
2990  
3133 int
3134 conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb)
3135 {
3136  if (fbgets(lbuf, max_size, fb) == NULL)
3137    return 0;
3138
3139  return strlen(lbuf);
3140 }
3141
3142 int
3143 conf_yy_fatal_error(const char *msg)
3144 {
3145  return 0;
3146 }
3147
2991   /*
2992   * valid_tkline()
2993   *
# Line 3344 | Line 3187 | parse_aline(const char *cmd, struct Clie
3187          return -1;
3188        }
3189  
3190 <      if (!IsOperRemoteBan(source_p))
3190 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3191        {
3192          sendto_one(source_p, form_str(ERR_NOPRIVS),
3193                     me.name, source_p->name, "remoteban");
# Line 3381 | Line 3224 | parse_aline(const char *cmd, struct Clie
3224        return -1;
3225      }
3226  
3227 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3227 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3228        return -1;
3229    }
3230    else
3231 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3231 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3232        return -1;
3233  
3234    if (reason != NULL)
# Line 3393 | Line 3236 | parse_aline(const char *cmd, struct Clie
3236      if (parc != 0 && !EmptyString(*parv))
3237      {
3238        *reason = *parv;
3239 <      if (!valid_comment(source_p, *reason, YES))
3239 >      if (!valid_comment(source_p, *reason, 1))
3240          return -1;
3241      }
3242      else
# Line 3552 | Line 3395 | match_conf_password(const char *password
3395   * inputs       - client sending the cluster
3396   *              - command name "KLINE" "XLINE" etc.
3397   *              - capab -- CAP_KLN etc. from s_serv.h
3398 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3398 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3399   *              - pattern and args to send along
3400   * output       - none
3401   * side effects - Take source_p send the pattern with args given
# Line 3712 | Line 3555 | cidr_limit_reached(int over_rule,
3555    dlink_node *ptr = NULL;
3556    struct CidrItem *cidr;
3557  
3558 <  if (NumberPerCidr(aclass) <= 0)
3558 >  if (aclass->number_per_cidr <= 0)
3559      return 0;
3560  
3561    if (ip->ss.ss_family == AF_INET)
3562    {
3563 <    if (CidrBitlenIPV4(aclass) <= 0)
3563 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3564        return 0;
3565  
3566      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3567      {
3568        cidr = ptr->data;
3569 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3569 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3570        {
3571 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3571 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3572            return -1;
3573          cidr->number_on_this_cidr++;
3574          return 0;
# Line 3734 | Line 3577 | cidr_limit_reached(int over_rule,
3577      cidr = MyMalloc(sizeof(struct CidrItem));
3578      cidr->number_on_this_cidr = 1;
3579      cidr->mask = *ip;
3580 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3580 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3581      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3582    }
3583   #ifdef IPV6
3584 <  else if (CidrBitlenIPV6(aclass) > 0)
3584 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3585    {
3586      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3587      {
3588        cidr = ptr->data;
3589 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3589 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3590        {
3591 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3591 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3592            return -1;
3593          cidr->number_on_this_cidr++;
3594          return 0;
# Line 3754 | Line 3597 | cidr_limit_reached(int over_rule,
3597      cidr = MyMalloc(sizeof(struct CidrItem));
3598      cidr->number_on_this_cidr = 1;
3599      cidr->mask = *ip;
3600 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3600 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3601      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3602    }
3603   #endif
# Line 3776 | Line 3619 | remove_from_cidr_check(struct irc_ssaddr
3619    dlink_node *next_ptr = NULL;
3620    struct CidrItem *cidr;
3621  
3622 <  if (NumberPerCidr(aclass) == 0)
3622 >  if (aclass->number_per_cidr == 0)
3623      return;
3624  
3625    if (ip->ss.ss_family == AF_INET)
3626    {
3627 <    if (CidrBitlenIPV4(aclass) <= 0)
3627 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3628        return;
3629  
3630      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3631      {
3632        cidr = ptr->data;
3633 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3633 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3634        {
3635          cidr->number_on_this_cidr--;
3636          if (cidr->number_on_this_cidr == 0)
# Line 3800 | Line 3643 | remove_from_cidr_check(struct irc_ssaddr
3643      }
3644    }
3645   #ifdef IPV6
3646 <  else if (CidrBitlenIPV6(aclass) > 0)
3646 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3647    {
3648      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3649      {
3650        cidr = ptr->data;
3651 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3651 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3652        {
3653          cidr->number_on_this_cidr--;
3654          if (cidr->number_on_this_cidr == 0)
# Line 3868 | Line 3711 | rebuild_cidr_class(struct ConfItem *conf
3711   {
3712    struct ClassItem *old_class = map_to_conf(conf);
3713  
3714 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3714 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3715    {
3716 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3716 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3717        rebuild_cidr_list(AF_INET, conf, new_class,
3718                          &old_class->list_ipv4, &new_class->list_ipv4,
3719 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3719 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3720  
3721   #ifdef IPV6
3722 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3722 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3723        rebuild_cidr_list(AF_INET6, conf, new_class,
3724                          &old_class->list_ipv6, &new_class->list_ipv6,
3725 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3725 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3726   #endif
3727    }
3728  

Diff Legend

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