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/trunk/src/conf.c (file contents):
Revision 1649 by michael, Sat Nov 10 19:27:13 2012 UTC vs.
Revision 1904 by michael, Sat Apr 27 21:16:22 2013 UTC

# Line 25 | Line 25
25   #include "stdinc.h"
26   #include "list.h"
27   #include "ircd_defs.h"
28 #include "balloc.h"
28   #include "conf.h"
29   #include "s_serv.h"
30   #include "resv.h"
# Line 45 | Line 44
44   #include "send.h"
45   #include "s_gline.h"
46   #include "memory.h"
47 + #include "mempool.h"
48   #include "irc_res.h"
49   #include "userhost.h"
50   #include "s_user.h"
# Line 104 | Line 104 | struct ip_entry
104   };
105  
106   static struct ip_entry *ip_hash_table[IP_HASH_SIZE];
107 < static BlockHeap *ip_entry_heap = NULL;
107 > static mp_pool_t *ip_entry_pool = NULL;
108   static int ip_entries_count = 0;
109  
110  
# Line 208 | Line 208 | conf_free(struct MaskItem *conf)
208      free_dlink_node(ptr);
209    }
210  
211 +  DLINK_FOREACH_SAFE(ptr, ptr_next, conf->exempt_list.head)
212 +  {
213 +    struct exempt *exptr = ptr->data;
214 +
215 +    MyFree(exptr->name);
216 +    MyFree(exptr->user);
217 +    MyFree(exptr->host);
218 +    MyFree(exptr);
219 +  }
220 +
221    MyFree(conf);
222   }
223  
# Line 654 | Line 664 | attach_iline(struct Client *client_p, st
664   void
665   init_ip_hash_table(void)
666   {
667 <  ip_entry_heap = BlockHeapCreate("ip", sizeof(struct ip_entry),
667 >  ip_entry_pool = mp_pool_new(sizeof(struct ip_entry),
668      2 * hard_fdlimit);
669    memset(ip_hash_table, 0, sizeof(ip_hash_table));
670   }
# Line 704 | Line 714 | find_or_add_ip(struct irc_ssaddr *ip_in)
714    if (ip_entries_count >= 2 * hard_fdlimit)
715      garbage_collect_ip_entries();
716  
717 <  newptr = BlockHeapAlloc(ip_entry_heap);
717 >  newptr = mp_pool_get(ip_entry_pool);
718 >  memset(newptr, 0, sizeof(*newptr));
719    ip_entries_count++;
720    memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr));
721  
# Line 762 | Line 773 | remove_one_ip(struct irc_ssaddr *ip_in)
773        else
774          ip_hash_table[hash_index] = ptr->next;
775  
776 <      BlockHeapFree(ip_entry_heap, ptr);
776 >      mp_pool_release(ptr);
777        ip_entries_count--;
778        return;
779      }
# Line 865 | Line 876 | garbage_collect_ip_entries(void)
876            last_ptr->next = ptr->next;
877          else
878            ip_hash_table[i] = ptr->next;
879 <        BlockHeapFree(ip_entry_heap, ptr);
879 >        mp_pool_release(ptr);
880          ip_entries_count--;
881        }
882        else
# Line 969 | Line 980 | attach_connect_block(struct Client *clie
980    {
981      conf = ptr->data;
982  
983 <    if (match(conf->name, name) == 0 || match(conf->host, host) == 0)
983 >    if (match(conf->name, name) || match(conf->host, host))
984        continue;
985  
986      attach_conf(client_p, conf);
# Line 1001 | Line 1012 | find_conf_name(dlink_list *list, const c
1012      if (conf->type == type)
1013      {
1014        if (conf->name && (irccmp(conf->name, name) == 0 ||
1015 <                         match(conf->name, name)))
1015 >                         !match(conf->name, name)))
1016        return conf;
1017      }
1018    }
# Line 1035 | Line 1046 | map_to_list(enum maskitem_type type)
1046    case CONF_NRESV:
1047      return(&nresv_items);
1048      break;
1049 +  case CONF_CRESV:
1050 +    return(&resv_channel_list);
1051    case CONF_OPER:
1052      return(&oconf_items);
1053      break;
# Line 1077 | Line 1090 | find_matching_name_conf(enum maskitem_ty
1090        DLINK_FOREACH(ptr, list_p->head)
1091        {
1092          conf = ptr->data;
1093 <        assert(conf->regexpname);
1093 >        assert(conf->regexuser);
1094  
1095          if (!ircd_pcre_exec(conf->regexuser, name))
1096            return conf;
# Line 1099 | Line 1112 | find_matching_name_conf(enum maskitem_ty
1112    case CONF_XLINE:
1113    case CONF_ULINE:
1114    case CONF_NRESV:
1115 +  case CONF_CRESV:
1116      DLINK_FOREACH(ptr, list_p->head)
1117      {
1118        conf = ptr->data;
1119  
1120        if (EmptyString(conf->name))
1121          continue;
1122 <      if ((name != NULL) && match_esc(conf->name, name))
1122 >      if ((name != NULL) && !match(conf->name, name))
1123        {
1124          if ((user == NULL && (host == NULL)))
1125            return conf;
# Line 1113 | Line 1127 | find_matching_name_conf(enum maskitem_ty
1127            continue;
1128          if (EmptyString(conf->user) || EmptyString(conf->host))
1129            return conf;
1130 <        if (match(conf->user, user) && match(conf->host, host))
1130 >        if (!match(conf->user, user) && !match(conf->host, host))
1131            return conf;
1132        }
1133      }
# Line 1124 | Line 1138 | find_matching_name_conf(enum maskitem_ty
1138      {
1139        conf = ptr->data;
1140  
1141 <      if ((name != NULL) && match(name, conf->name))
1141 >      if ((name != NULL) && !match(name, conf->name))
1142          return conf;
1143 <      else if ((host != NULL) && match(host, conf->host))
1143 >      else if ((host != NULL) && !match(host, conf->host))
1144          return conf;
1145      }
1146      break;
# Line 1160 | Line 1174 | find_exact_name_conf(enum maskitem_type
1174    case CONF_XLINE:
1175    case CONF_ULINE:
1176    case CONF_NRESV:
1177 +  case CONF_CRESV:
1178  
1179      DLINK_FOREACH(ptr, list_p->head)
1180      {
# Line 1174 | Line 1189 | find_exact_name_conf(enum maskitem_type
1189            return (conf);
1190          if (EmptyString(conf->user) || EmptyString(conf->host))
1191            return (conf);
1192 <        if (match(conf->user, user) && match(conf->host, host))
1192 >        if (!match(conf->user, user) && !match(conf->host, host))
1193            return (conf);
1194        }
1195      }
# Line 1194 | Line 1209 | find_exact_name_conf(enum maskitem_type
1209            return conf;
1210          if (EmptyString(conf->user) || EmptyString(conf->host))
1211            return NULL;
1212 <        if (match(conf->user, who->username))
1212 >        if (!match(conf->user, who->username))
1213          {
1214            switch (conf->htype)
1215            {
1216              case HM_HOST:
1217 <              if (match(conf->host, who->host) || match(conf->host, who->sockhost))
1217 >              if (!match(conf->host, who->host) || !match(conf->host, who->sockhost))
1218                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
1219                    return conf;
1220                break;
# Line 1282 | Line 1297 | rehash(int sig)
1297    load_conf_modules();
1298  
1299    rehashed_klines = 1;
1285 /* XXX */
1286  if (ConfigLoggingEntry.use_logging)
1287    log_close_all();
1300  
1301 <  return(0);
1301 >  return 0;
1302   }
1303  
1304   /* set_default_conf()
# Line 1323 | Line 1335 | set_default_conf(void)
1335    ServerInfo.specific_ipv6_vhost = 0;
1336  
1337    ServerInfo.max_clients = MAXCLIENTS_MAX;
1338 +  ServerInfo.max_nick_length = 9;
1339 +  ServerInfo.max_topic_length = 80;
1340  
1341    ServerInfo.hub = 0;
1342    ServerInfo.dns_host.sin_addr.s_addr = 0;
# Line 1331 | Line 1345 | set_default_conf(void)
1345    AdminInfo.email = NULL;
1346    AdminInfo.description = NULL;
1347  
1348 <  log_close_all();
1348 >  log_del_all();
1349  
1350    ConfigLoggingEntry.use_logging = 1;
1351  
1352    ConfigChannel.disable_fake_channels = 0;
1339  ConfigChannel.restrict_channels = 0;
1353    ConfigChannel.knock_delay = 300;
1354    ConfigChannel.knock_delay_channel = 60;
1355    ConfigChannel.max_chans_per_user = 25;
# Line 1352 | Line 1365 | set_default_conf(void)
1365    ConfigServerHide.links_delay = 300;
1366    ConfigServerHide.hidden = 0;
1367    ConfigServerHide.hide_servers = 0;
1368 +  ConfigServerHide.hide_services = 0;
1369    ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT);
1370    ConfigServerHide.hide_server_ips = 0;
1371  
# Line 1625 | Line 1639 | expire_tklines(dlink_list *tklist)
1639                                 "Temporary X-line for [%s] expired", conf->name);
1640        conf_free(conf);
1641      }
1642 <    else if (conf->type == CONF_NRESV)
1642 >    else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1643      {
1644        if (ConfigFileEntry.tkline_expire_notices)
1645          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1646                                 "Temporary RESV for [%s] expired", conf->name);
1647        conf_free(conf);
1648      }
1635    else if (conf->type == CONF_CRESV)
1636    {
1637      if (ConfigFileEntry.tkline_expire_notices)
1638        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1639                               "Temporary RESV for [%s] expired", conf->name);
1640      delete_channel_resv(conf);
1641    }
1649    }
1650   }
1651  
# Line 1660 | Line 1667 | static const struct oper_privs
1667    { OPER_FLAG_REHASH,      'H' },
1668    { OPER_FLAG_K,           'K' },
1669    { OPER_FLAG_OPERWALL,    'L' },
1663  { OPER_FLAG_N,           'N' },
1670    { OPER_FLAG_GLOBAL_KILL, 'O' },
1671    { OPER_FLAG_REMOTE,      'R' },
1672    { OPER_FLAG_OPER_SPY,    'S' },
# Line 1774 | Line 1780 | read_conf_files(int cold)
1780    read_conf(conf_parser_ctx.conf_file);
1781    fclose(conf_parser_ctx.conf_file);
1782  
1783 +  log_reopen_all();
1784 +
1785 +  add_isupport("NICKLEN", NULL, ServerInfo.max_nick_length);
1786    add_isupport("NETWORK", ServerInfo.network_name, -1);
1787 <  snprintf(chanmodes, sizeof(chanmodes), "beI:%d",
1788 <           ConfigChannel.max_bans);
1787 >
1788 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1789    add_isupport("MAXLIST", chanmodes, -1);
1790    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
1782
1791    add_isupport("CHANTYPES", "#", -1);
1792  
1793    snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1794 <           ConfigChannel.max_chans_per_user);
1794 >           ConfigChannel.max_chans_per_user);
1795    add_isupport("CHANLIMIT", chanlimit, -1);
1796 <  snprintf(chanmodes, sizeof(chanmodes), "%s",
1789 <           "beI,k,l,imnprstORS");
1796 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1797    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1798 <
1798 >  add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1799    add_isupport("EXCEPTS", "e", -1);
1800    add_isupport("INVEX", "I", -1);
1801    add_isupport("CHANMODES", chanmodes, -1);
# Line 1814 | Line 1821 | clear_out_old_conf(void)
1821    dlink_list *free_items [] = {
1822      &server_items,   &oconf_items,
1823       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
1824 <     &nresv_items, &cluster_items,  &service_items, NULL
1824 >     &nresv_items, &cluster_items,  &service_items, &resv_channel_list, NULL
1825    };
1826  
1827    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1889 | Line 1896 | clear_out_old_conf(void)
1896                                                 SSL_OP_NO_TLSv1);
1897   #endif
1898  
1892  /* clean out old resvs from the conf */
1893  clear_conf_resv();
1894
1899    /* clean out AdminInfo */
1900    MyFree(AdminInfo.name);
1901    AdminInfo.name = NULL;
# Line 1920 | Line 1924 | clear_out_old_conf(void)
1924   void
1925   conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1926   {
1923  struct ClassItem *class = NULL;
1924
1927    if (class_name == NULL)
1928    {
1929      conf->class = class_default;
# Line 1967 | Line 1969 | yyerror(const char *msg)
1969      return;
1970  
1971    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1972 <  sendto_realops_flags(UMODE_ALL, L_ALL,  SEND_NOTICE,
1972 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1973 >                       "\"%s\", line %u: %s: %s",
1974 >                       conffilebuf, lineno + 1, msg, newlinebuf);
1975 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1976 >       conffilebuf, lineno + 1, msg, newlinebuf);
1977 > }
1978 >
1979 > void
1980 > conf_error_report(const char *msg)
1981 > {
1982 >  char newlinebuf[IRCD_BUFSIZE];
1983 >
1984 >  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1985 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1986                         "\"%s\", line %u: %s: %s",
1987                         conffilebuf, lineno + 1, msg, newlinebuf);
1988    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",

Diff Legend

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