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 3347 by michael, Sun Apr 20 14:03:06 2014 UTC vs.
Revision 4068 by michael, Wed Jun 25 16:43:33 2014 UTC

# Line 102 | Line 102 | static int find_user_host(struct Client
102   struct ip_entry
103   {
104    struct irc_ssaddr ip;
105 <  unsigned int count;
106 <  time_t last_attempt;
105 >  unsigned int count;  /**< Number of registered users using this IP */
106 >  unsigned int connection_count;  /**< Number of connections from this IP in the last throttle_time duration */
107 >  time_t last_attempt;  /**< The last time someone connected from this IP */
108    struct ip_entry *next;
109   };
110  
# Line 154 | Line 155 | conf_dns_lookup(struct MaskItem *conf)
155   struct MaskItem *
156   conf_make(enum maskitem_type type)
157   {
158 <  struct MaskItem *conf = MyMalloc(sizeof(*conf));
158 >  struct MaskItem *conf = MyCalloc(sizeof(*conf));
159    dlink_list *list = NULL;
160  
161    conf->type   = type;
# Line 403 | Line 404 | attach_iline(struct Client *client_p, st
404     * setting a_limit_reached if any limit is reached.
405     * - Dianora
406     */
407 <  if (class->max_total != 0 && class->ref_count >= class->max_total)
407 >  if (class->max_total && class->ref_count >= class->max_total)
408      a_limit_reached = 1;
409 <  else if (class->max_perip != 0 && ip_found->count > class->max_perip)
409 >  else if (class->max_perip && ip_found->count > class->max_perip)
410      a_limit_reached = 1;
411 <  else if (class->max_local != 0 && local >= class->max_local)
411 >  else if (class->max_local && local >= class->max_local)
412      a_limit_reached = 1;
413 <  else if (class->max_global != 0 && global >= class->max_global)
413 >  else if (class->max_global && global >= class->max_global)
414      a_limit_reached = 1;
415 <  else if (class->max_ident != 0 && ident >= class->max_ident &&
415 >  else if (class->max_ident && ident >= class->max_ident &&
416             client_p->username[0] != '~')
417      a_limit_reached = 1;
418  
# Line 604 | Line 605 | void
605   count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
606   {
607    struct ip_entry *ptr;
607 –  int i;
608  
609    *number_ips_stored = 0;
610    *mem_ips_stored    = 0;
611  
612 <  for (i = 0; i < IP_HASH_SIZE; i++)
612 >  for (unsigned int i = 0; i < IP_HASH_SIZE; ++i)
613    {
614      for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next)
615      {
# Line 631 | Line 631 | garbage_collect_ip_entries(void)
631    struct ip_entry *ptr;
632    struct ip_entry *last_ptr;
633    struct ip_entry *next_ptr;
634 –  int i;
634  
635 <  for (i = 0; i < IP_HASH_SIZE; i++)
635 >  for (unsigned int i = 0; i < IP_HASH_SIZE; ++i)
636    {
637      last_ptr = NULL;
638  
# Line 783 | Line 782 | find_conf_name(dlink_list *list, const c
782  
783      if (conf->type == type)
784      {
785 <      if (conf->name && (irccmp(conf->name, name) == 0 ||
785 >      if (conf->name && (!irccmp(conf->name, name) ||
786                           !match(conf->name, name)))
787        return conf;
788      }
# Line 1048 | Line 1047 | rehash(int sig)
1047      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1048  
1049    load_conf_modules();
1050 <
1052 <  rehashed_klines = 1;
1050 >  check_conf_klines();
1051  
1052    return 0;
1053   }
# Line 1103 | Line 1101 | set_default_conf(void)
1101    ConfigLoggingEntry.use_logging = 1;
1102  
1103    ConfigChannel.disable_fake_channels = 0;
1104 <  ConfigChannel.knock_delay = 300;
1104 >  ConfigChannel.invite_client_count = 10;
1105 >  ConfigChannel.invite_client_time = 300;
1106 >  ConfigChannel.knock_client_count = 1;
1107 >  ConfigChannel.knock_client_time = 300;
1108    ConfigChannel.knock_delay_channel = 60;
1109 <  ConfigChannel.max_chans_per_user = 25;
1109 <  ConfigChannel.max_chans_per_oper = 50;
1109 >  ConfigChannel.max_channels = 25;
1110    ConfigChannel.max_bans = 25;
1111    ConfigChannel.default_split_user_count = 0;
1112    ConfigChannel.default_split_server_count = 0;
# Line 1148 | Line 1148 | set_default_conf(void)
1148    ConfigFileEntry.anti_spam_exit_message_time = 0;
1149    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1150    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1151 <  ConfigFileEntry.warn_no_nline = 1;
1151 >  ConfigFileEntry.warn_no_connect_block = 1;
1152 >  ConfigFileEntry.stats_e_disabled = 0;
1153    ConfigFileEntry.stats_o_oper_only = 0;
1154 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1155 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1154 >  ConfigFileEntry.stats_k_oper_only = 1;  /* 1 = masked */
1155 >  ConfigFileEntry.stats_i_oper_only = 1;  /* 1 = masked */
1156    ConfigFileEntry.stats_P_oper_only = 0;
1157    ConfigFileEntry.stats_u_oper_only = 0;
1158    ConfigFileEntry.caller_id_wait = 60;
# Line 1165 | Line 1166 | set_default_conf(void)
1166    ConfigFileEntry.oper_pass_resv = 1;
1167    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1168    ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1169 <  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1169 <    UMODE_OPERWALL | UMODE_WALLOP;
1169 >  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
1170    ConfigFileEntry.use_egd = 0;
1171    ConfigFileEntry.egdpool_path = NULL;
1172 <  ConfigFileEntry.throttle_time = 10;
1172 >  ConfigFileEntry.throttle_count = 1;
1173 >  ConfigFileEntry.throttle_time = 1;
1174   }
1175  
1176   static void
# Line 1204 | Line 1205 | read_conf(FILE *file)
1205   {
1206    lineno = 0;
1207  
1208 <  set_default_conf(); /* Set default values prior to conf parsing */
1208 >  set_default_conf();  /* Set default values prior to conf parsing */
1209    conf_parser_ctx.pass = 1;
1210 <  yyparse();          /* pick up the classes first */
1210 >  yyparse();  /* Pick up the classes first */
1211  
1212    rewind(file);
1213  
1214    conf_parser_ctx.pass = 2;
1215 <  yyparse();          /* Load the values from the conf */
1216 <  validate_conf();    /* Check to make sure some values are still okay. */
1217 <                      /* Some global values are also loaded here. */
1218 <  class_delete_marked();      /* Make sure classes are valid */
1215 >  yyparse();  /* Load the values from the conf */
1216 >  validate_conf();  /* Check to make sure some values are still okay. */
1217 >                    /* Some global values are also loaded here. */
1218 >  class_delete_marked();  /* Delete unused classes that are marked for deletion */
1219   }
1220  
1221   /* lookup_confhost()
# Line 1227 | Line 1228 | lookup_confhost(struct MaskItem *conf)
1228   {
1229    struct addrinfo hints, *res;
1230  
1231 <  /* Do name lookup now on hostnames given and store the
1231 >  /*
1232 >   * Do name lookup now on hostnames given and store the
1233     * ip numbers in conf structure.
1234     */
1235    memset(&hints, 0, sizeof(hints));
# Line 1263 | Line 1265 | lookup_confhost(struct MaskItem *conf)
1265   int
1266   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
1267   {
1268 <  struct ip_entry *ip_found;
1268 >  struct ip_entry *ip_found = NULL;
1269    struct MaskItem *conf = find_dline_conf(addr, aftype);
1270  
1271    /* DLINE exempt also gets you out of static limits/pacing... */
# Line 1275 | Line 1277 | conf_connect_allowed(struct irc_ssaddr *
1277  
1278    ip_found = find_or_add_ip(addr);
1279  
1280 <  if ((CurrentTime - ip_found->last_attempt) <
1279 <      ConfigFileEntry.throttle_time)
1280 >  if ((CurrentTime - ip_found->last_attempt) < ConfigFileEntry.throttle_time)
1281    {
1282 <    ip_found->last_attempt = CurrentTime;
1283 <    return TOO_FAST;
1282 >    if (ip_found->connection_count >= ConfigFileEntry.throttle_count)
1283 >      return TOO_FAST;
1284 >
1285 >    ++ip_found->connection_count;
1286    }
1287 +  else
1288 +    ip_found->connection_count = 1;
1289  
1290    ip_found->last_attempt = CurrentTime;
1291    return 0;
# Line 1354 | Line 1359 | static const struct oper_privs
1359    { OPER_FLAG_DIE,            'D' },
1360    { OPER_FLAG_GLINE,          'G' },
1361    { OPER_FLAG_REHASH,         'H' },
1362 <  { OPER_FLAG_K,              'K' },
1358 <  { OPER_FLAG_OPERWALL,       'L' },
1362 >  { OPER_FLAG_KLINE,          'K' },
1363    { OPER_FLAG_KILL,           'N' },
1364    { OPER_FLAG_KILL_REMOTE,    'O' },
1365    { OPER_FLAG_CONNECT,        'P' },
# Line 1433 | Line 1437 | get_oper_name(const struct Client *clien
1437   void
1438   read_conf_files(int cold)
1439   {
1440 <  const char *filename;
1441 <  char chanmodes[IRCD_BUFSIZE];
1442 <  char chanlimit[IRCD_BUFSIZE];
1440 >  const char *filename = NULL;
1441 >  char chanmodes[IRCD_BUFSIZE] = "";
1442 >  char chanlimit[IRCD_BUFSIZE] = "";
1443  
1444    conf_parser_ctx.boot = cold;
1445    filename = ConfigFileEntry.configfile;
# Line 1482 | Line 1486 | read_conf_files(int cold)
1486    add_isupport("CHANTYPES", "#", -1);
1487  
1488    snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1489 <           ConfigChannel.max_chans_per_user);
1489 >           ConfigChannel.max_channels);
1490    add_isupport("CHANLIMIT", chanlimit, -1);
1491 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1492 <  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1491 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1492 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1493    add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1494    add_isupport("CHANMODES", chanmodes, -1);
1495  
# Line 1735 | Line 1739 | valid_wild_card_simple(const char *data)
1739   {
1740    const unsigned char *p = (const unsigned char *)data;
1741    unsigned char tmpch = '\0';
1742 <  int nonwild = 0;
1742 >  unsigned int nonwild = 0;
1743  
1744    while ((tmpch = *p++))
1745    {
# Line 1766 | Line 1770 | valid_wild_card_simple(const char *data)
1770   int
1771   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1772   {
1773 <  char tmpch;
1774 <  int nonwild = 0;
1773 >  unsigned char tmpch = '\0';
1774 >  unsigned int nonwild = 0;
1775    va_list args;
1776  
1777    /*
# Line 1786 | Line 1790 | valid_wild_card(struct Client *source_p,
1790  
1791    while (count--)
1792    {
1793 <    const char *p = va_arg(args, const char *);
1793 >    const unsigned char *p = va_arg(args, const unsigned char *);
1794      if (p == NULL)
1795        continue;
1796  
# Line 1809 | Line 1813 | valid_wild_card(struct Client *source_p,
1813  
1814    if (warn)
1815      sendto_one_notice(source_p, &me,
1816 <                      ":Please include at least %d non-wildcard characters with the mask",
1816 >                      ":Please include at least %u non-wildcard characters with the mask",
1817                        ConfigFileEntry.min_nonwildcard);
1818    va_end(args);
1819    return 0;
# Line 1852 | Line 1856 | parse_aline(const char *cmd, struct Clie
1856              char **target_server, char **reason)
1857   {
1858    int found_tkline_time=0;
1859 <  static char def_reason[] = "No Reason";
1859 >  static char def_reason[] = CONF_NOREASON;
1860    static char user[USERLEN*4+1];
1861    static char host[HOSTLEN*4+1];
1862  
# Line 2018 | Line 2022 | find_user_host(struct Client *source_p,
2022      /* Okay to use source_p as the first param, because source_p == client_p */
2023      if ((target_p =
2024          find_chasing(source_p, user_host_or_nick)) == NULL)
2025 <      return 0;
2025 >      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
2026  
2027      if (IsExemptKline(target_p))
2028      {
# Line 2104 | Line 2108 | cluster_a_line(struct Client *source_p,
2108                 int capab, int cluster_type, const char *pattern, ...)
2109   {
2110    va_list args;
2111 <  char buffer[IRCD_BUFSIZE];
2111 >  char buffer[IRCD_BUFSIZE] = "";
2112    const dlink_node *ptr = NULL;
2113  
2114    va_start(args, pattern);
# Line 2165 | Line 2169 | split_nuh(struct split_nuh_item *const i
2169    {
2170      *p = '\0';
2171  
2172 <    if (iptr->nickptr && *iptr->nuhmask != '\0')
2172 >    if (iptr->nickptr && *iptr->nuhmask)
2173        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2174  
2175      if ((q = strchr(++p, '@')))
2176      {
2177        *q++ = '\0';
2178  
2179 <      if (*p != '\0')
2179 >      if (*p)
2180          strlcpy(iptr->userptr, p, iptr->usersize);
2181  
2182 <      if (*q != '\0')
2182 >      if (*q)
2183          strlcpy(iptr->hostptr, q, iptr->hostsize);
2184      }
2185      else
2186      {
2187 <      if (*p != '\0')
2187 >      if (*p)
2188          strlcpy(iptr->userptr, p, iptr->usersize);
2189      }
2190    }
# Line 2192 | Line 2196 | split_nuh(struct split_nuh_item *const i
2196        /* if found a @ */
2197        *p++ = '\0';
2198  
2199 <      if (*iptr->nuhmask != '\0')
2199 >      if (*iptr->nuhmask)
2200          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
2201  
2202 <      if (*p != '\0')
2202 >      if (*p)
2203          strlcpy(iptr->hostptr, p, iptr->hostsize);
2204      }
2205      else

Diff Legend

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