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 3877 by michael, Fri Jun 6 15:49:13 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 1103 | Line 1102 | set_default_conf(void)
1102    ConfigLoggingEntry.use_logging = 1;
1103  
1104    ConfigChannel.disable_fake_channels = 0;
1105 <  ConfigChannel.knock_delay = 300;
1105 >  ConfigChannel.invite_client_count = 10;
1106 >  ConfigChannel.invite_client_time = 300;
1107 >  ConfigChannel.knock_client_count = 1;
1108 >  ConfigChannel.knock_client_time = 300;
1109    ConfigChannel.knock_delay_channel = 60;
1110    ConfigChannel.max_chans_per_user = 25;
1111    ConfigChannel.max_chans_per_oper = 50;
# Line 1148 | Line 1150 | set_default_conf(void)
1150    ConfigFileEntry.anti_spam_exit_message_time = 0;
1151    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1152    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1153 <  ConfigFileEntry.warn_no_nline = 1;
1153 >  ConfigFileEntry.warn_no_connect_block = 1;
1154 >  ConfigFileEntry.stats_e_disabled = 0;
1155    ConfigFileEntry.stats_o_oper_only = 0;
1156 <  ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1157 <  ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1156 >  ConfigFileEntry.stats_k_oper_only = 1;  /* 1 = masked */
1157 >  ConfigFileEntry.stats_i_oper_only = 1;  /* 1 = masked */
1158    ConfigFileEntry.stats_P_oper_only = 0;
1159    ConfigFileEntry.stats_u_oper_only = 0;
1160    ConfigFileEntry.caller_id_wait = 60;
# Line 1165 | Line 1168 | set_default_conf(void)
1168    ConfigFileEntry.oper_pass_resv = 1;
1169    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1170    ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1171 <  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1169 <    UMODE_OPERWALL | UMODE_WALLOP;
1171 >  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
1172    ConfigFileEntry.use_egd = 0;
1173    ConfigFileEntry.egdpool_path = NULL;
1174 +  ConfigFileEntry.throttle_count = 0;
1175    ConfigFileEntry.throttle_time = 10;
1176   }
1177  
# Line 1204 | Line 1207 | read_conf(FILE *file)
1207   {
1208    lineno = 0;
1209  
1210 <  set_default_conf(); /* Set default values prior to conf parsing */
1210 >  set_default_conf();  /* Set default values prior to conf parsing */
1211    conf_parser_ctx.pass = 1;
1212 <  yyparse();          /* pick up the classes first */
1212 >  yyparse();  /* Pick up the classes first */
1213  
1214    rewind(file);
1215  
1216    conf_parser_ctx.pass = 2;
1217 <  yyparse();          /* Load the values from the conf */
1218 <  validate_conf();    /* Check to make sure some values are still okay. */
1219 <                      /* Some global values are also loaded here. */
1220 <  class_delete_marked();      /* Make sure classes are valid */
1217 >  yyparse();  /* Load the values from the conf */
1218 >  validate_conf();  /* Check to make sure some values are still okay. */
1219 >                    /* Some global values are also loaded here. */
1220 >  class_delete_marked();  /* Delete unused classes that are marked for deletion */
1221   }
1222  
1223   /* lookup_confhost()
# Line 1227 | Line 1230 | lookup_confhost(struct MaskItem *conf)
1230   {
1231    struct addrinfo hints, *res;
1232  
1233 <  /* Do name lookup now on hostnames given and store the
1233 >  /*
1234 >   * Do name lookup now on hostnames given and store the
1235     * ip numbers in conf structure.
1236     */
1237    memset(&hints, 0, sizeof(hints));
# Line 1263 | Line 1267 | lookup_confhost(struct MaskItem *conf)
1267   int
1268   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
1269   {
1270 <  struct ip_entry *ip_found;
1270 >  struct ip_entry *ip_found = NULL;
1271    struct MaskItem *conf = find_dline_conf(addr, aftype);
1272  
1273    /* DLINE exempt also gets you out of static limits/pacing... */
# Line 1274 | Line 1278 | conf_connect_allowed(struct irc_ssaddr *
1278      return BANNED_CLIENT;
1279  
1280    ip_found = find_or_add_ip(addr);
1281 +  ++ip_found->connection_count;
1282  
1283 <  if ((CurrentTime - ip_found->last_attempt) <
1279 <      ConfigFileEntry.throttle_time)
1283 >  if ((CurrentTime - ip_found->last_attempt) < ConfigFileEntry.throttle_time)
1284    {
1285 <    ip_found->last_attempt = CurrentTime;
1286 <    return TOO_FAST;
1285 >    if (ip_found->connection_count >= ConfigFileEntry.throttle_count)
1286 >    {
1287 >      ip_found->last_attempt = CurrentTime;
1288 >      return TOO_FAST;
1289 >    }
1290    }
1291 +  else
1292 +    ip_found->connection_count = 1;
1293  
1294    ip_found->last_attempt = CurrentTime;
1295    return 0;
# Line 1355 | Line 1364 | static const struct oper_privs
1364    { OPER_FLAG_GLINE,          'G' },
1365    { OPER_FLAG_REHASH,         'H' },
1366    { OPER_FLAG_K,              'K' },
1358 –  { OPER_FLAG_OPERWALL,       'L' },
1367    { OPER_FLAG_KILL,           'N' },
1368    { OPER_FLAG_KILL_REMOTE,    'O' },
1369    { OPER_FLAG_CONNECT,        'P' },
# Line 1433 | Line 1441 | get_oper_name(const struct Client *clien
1441   void
1442   read_conf_files(int cold)
1443   {
1444 <  const char *filename;
1445 <  char chanmodes[IRCD_BUFSIZE];
1446 <  char chanlimit[IRCD_BUFSIZE];
1444 >  const char *filename = NULL;
1445 >  char chanmodes[IRCD_BUFSIZE] = "";
1446 >  char chanlimit[IRCD_BUFSIZE] = "";
1447  
1448    conf_parser_ctx.boot = cold;
1449    filename = ConfigFileEntry.configfile;
# Line 1485 | Line 1493 | read_conf_files(int cold)
1493             ConfigChannel.max_chans_per_user);
1494    add_isupport("CHANLIMIT", chanlimit, -1);
1495    snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS");
1496 <  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
1496 >  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1497    add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length);
1498    add_isupport("CHANMODES", chanmodes, -1);
1499  
# Line 1735 | Line 1743 | valid_wild_card_simple(const char *data)
1743   {
1744    const unsigned char *p = (const unsigned char *)data;
1745    unsigned char tmpch = '\0';
1746 <  int nonwild = 0;
1746 >  unsigned int nonwild = 0;
1747  
1748    while ((tmpch = *p++))
1749    {
# Line 1766 | Line 1774 | valid_wild_card_simple(const char *data)
1774   int
1775   valid_wild_card(struct Client *source_p, int warn, int count, ...)
1776   {
1777 <  char tmpch;
1778 <  int nonwild = 0;
1777 >  char tmpch = '\0';
1778 >  unsigned int nonwild = 0;
1779    va_list args;
1780  
1781    /*
# Line 1852 | Line 1860 | parse_aline(const char *cmd, struct Clie
1860              char **target_server, char **reason)
1861   {
1862    int found_tkline_time=0;
1863 <  static char def_reason[] = "No Reason";
1863 >  static char def_reason[] = CONF_NOREASON;
1864    static char user[USERLEN*4+1];
1865    static char host[HOSTLEN*4+1];
1866  
# Line 2018 | Line 2026 | find_user_host(struct Client *source_p,
2026      /* Okay to use source_p as the first param, because source_p == client_p */
2027      if ((target_p =
2028          find_chasing(source_p, user_host_or_nick)) == NULL)
2029 <      return 0;
2029 >      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
2030  
2031      if (IsExemptKline(target_p))
2032      {
# Line 2104 | Line 2112 | cluster_a_line(struct Client *source_p,
2112                 int capab, int cluster_type, const char *pattern, ...)
2113   {
2114    va_list args;
2115 <  char buffer[IRCD_BUFSIZE];
2115 >  char buffer[IRCD_BUFSIZE] = "";
2116    const dlink_node *ptr = NULL;
2117  
2118    va_start(args, pattern);
# Line 2165 | Line 2173 | split_nuh(struct split_nuh_item *const i
2173    {
2174      *p = '\0';
2175  
2176 <    if (iptr->nickptr && *iptr->nuhmask != '\0')
2176 >    if (iptr->nickptr && *iptr->nuhmask)
2177        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
2178  
2179      if ((q = strchr(++p, '@')))
2180      {
2181        *q++ = '\0';
2182  
2183 <      if (*p != '\0')
2183 >      if (*p)
2184          strlcpy(iptr->userptr, p, iptr->usersize);
2185  
2186 <      if (*q != '\0')
2186 >      if (*q)
2187          strlcpy(iptr->hostptr, q, iptr->hostsize);
2188      }
2189      else
2190      {
2191 <      if (*p != '\0')
2191 >      if (*p)
2192          strlcpy(iptr->userptr, p, iptr->usersize);
2193      }
2194    }
# Line 2192 | Line 2200 | split_nuh(struct split_nuh_item *const i
2200        /* if found a @ */
2201        *p++ = '\0';
2202  
2203 <      if (*iptr->nuhmask != '\0')
2203 >      if (*iptr->nuhmask)
2204          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
2205  
2206 <      if (*p != '\0')
2206 >      if (*p)
2207          strlcpy(iptr->hostptr, p, iptr->hostsize);
2208      }
2209      else

Diff Legend

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