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 619 by michael, Tue May 23 07:22:23 2006 UTC vs.
Revision 896 by michael, Sat Nov 3 08:54:09 2007 UTC

# Line 28 | Line 28
28   #include "s_conf.h"
29   #include "s_serv.h"
30   #include "resv.h"
31 #include "s_stats.h"
31   #include "channel.h"
32   #include "client.h"
33   #include "common.h"
# Line 38 | Line 37
37   #include "irc_string.h"
38   #include "sprintf_irc.h"
39   #include "s_bsd.h"
41 #include "irc_getnameinfo.h"
40   #include "irc_getaddrinfo.h"
41   #include "ircd.h"
42   #include "list.h"
# Line 337 | Line 335 | make_conf_item(ConfType type)
335      break;
336  
337    case CLASS_TYPE:
338 <    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
339 <                                       sizeof(struct ClassItem));
338 >    conf = MyMalloc(sizeof(struct ConfItem) +
339 >                           sizeof(struct ClassItem));
340      dlinkAdd(conf, &conf->node, &class_items);
341 <    aclass = (struct ClassItem *)map_to_conf(conf);
342 <    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
341 >
342 >    aclass = map_to_conf(conf);
343 >    aclass->active = 1;
344 >    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
345      PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
346      MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
347      MaxSendq(aclass) = DEFAULT_SENDQ;
348 <    CurrUserCount(aclass) = 0;
348 >
349      break;
350  
351    default:
# Line 356 | Line 356 | make_conf_item(ConfType type)
356    /* XXX Yes, this will core if default is hit. I want it to for now - db */
357    conf->type = type;
358  
359 <  return(conf);
359 >  return conf;
360   }
361  
362   void
# Line 723 | Line 723 | report_confitem_types(struct Client *sou
723                   conf->name, PingFreq(classitem),
724                   ConFreq(classitem),
725                   MaxTotal(classitem), MaxSendq(classitem),
726 <                 CurrUserCount(classitem));
726 >                 CurrUserCount(classitem),
727 >                 classitem->active ? "active" : "disabled");
728      }
729      break;
730  
# Line 745 | Line 746 | report_confitem_types(struct Client *sou
746          *p++ = 'A';
747        if (IsConfCryptLink(aconf))
748          *p++ = 'C';
748      if (IsConfLazyLink(aconf))
749        *p++ = 'L';
749        if (aconf->fakename)
750          *p++ = 'M';
751        if (IsConfTopicBurst(aconf))
# Line 758 | Line 757 | report_confitem_types(struct Client *sou
757  
758        *p = '\0';
759  
760 <      /* Allow admins to see actual ips
761 <       * unless hide_server_ips is enabled
760 >      /*
761 >       * Allow admins to see actual ips unless hide_server_ips is enabled
762         */
763        if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
764          sendto_one(source_p, form_str(RPL_STATSCLINE),
# Line 827 | Line 826 | check_client(va_list args)
826  
827    /* I'm already in big trouble if source_p->localClient is NULL -db */
828    if ((i = verify_access(source_p, username)))
830  {
829      ilog(L_INFO, "Access denied: %s[%s]",
830           source_p->name, source_p->sockhost);
833  }
831  
832    switch (i)
833    {
# Line 841 | Line 838 | check_client(va_list args)
838                             source_p->sockhost);
839        ilog(L_INFO,"Too many connections on IP from %s.",
840             get_client_name(source_p, SHOW_IP));
841 <      ServerStats->is_ref++;
841 >      ++ServerStats.is_ref;
842        exit_client(source_p, &me, "No more connections allowed on that IP");
843        break;
844  
# Line 852 | Line 849 | check_client(va_list args)
849                             source_p->sockhost);
850        ilog(L_INFO,"Too many connections from %s.",
851             get_client_name(source_p, SHOW_IP));
852 <       ServerStats->is_ref++;
852 >      ++ServerStats.is_ref;
853        exit_client(source_p, &me,
854                  "No more connections allowed in your connection class");
855        break;
856  
857      case NOT_AUTHORIZED:
858 <    {
862 <      static char ipaddr[HOSTIPLEN];
863 <      ServerStats->is_ref++;
858 >      ++ServerStats.is_ref;
859        /* jdc - lists server name & port connections are on */
860        /*       a purely cosmetical change */
866      irc_getnameinfo((struct sockaddr*)&source_p->localClient->ip,
867            source_p->localClient->ip.ss_len, ipaddr, HOSTIPLEN, NULL, 0,
868            NI_NUMERICHOST);
861        sendto_realops_flags(UMODE_UNAUTH, L_ALL,
862                             "Unauthorized client connection from %s [%s] on [%s/%u].",
863                             get_client_name(source_p, SHOW_IP),
864 <                           ipaddr,
864 >                           source_p->sockhost,
865                             source_p->localClient->listener->name,
866                             source_p->localClient->listener->port);
867        ilog(L_INFO,
# Line 882 | Line 874 | check_client(va_list args)
874         * capture reject code here or rely on the connecting too fast code.
875         * - Dianora
876         */
877 <      if(REJECT_HOLD_TIME > 0)
877 >      if (REJECT_HOLD_TIME > 0)
878        {
879          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
880                     me.name, source_p->name);
# Line 892 | Line 884 | check_client(va_list args)
884        else
885          exit_client(source_p, &me, "You are not authorized to use this server");
886        break;
887 <    }
896 <
887 >
888     case BANNED_CLIENT:
889       /*
890        * Don't exit them immediately, play with them a bit.
# Line 906 | Line 897 | check_client(va_list args)
897       }
898       else
899         exit_client(source_p, &me, "Banned");
900 <     ServerStats->is_ref++;
900 >     ++ServerStats.is_ref;
901       break;
902  
903     case 0:
# Line 1023 | Line 1014 | attach_iline(struct Client *client_p, st
1014    ip_found->count++;
1015    SetIpHash(client_p);
1016  
1017 <  aconf = (struct AccessItem *)map_to_conf(conf);
1017 >  aconf = map_to_conf(conf);
1018    if (aconf->class_ptr == NULL)
1019      return NOT_AUTHORIZED;  /* If class is missing, this is best */
1020  
1021 <  aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1021 >  aclass = map_to_conf(aconf->class_ptr);
1022  
1023    count_user_host(client_p->username, client_p->host,
1024                    &global, &local, &ident);
# Line 1038 | Line 1029 | attach_iline(struct Client *client_p, st
1029     */
1030    if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
1031      a_limit_reached = 1;
1032 <  else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass))
1032 >  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
1033      a_limit_reached = 1;
1034    else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
1035      a_limit_reached = 1;
# Line 1051 | Line 1042 | attach_iline(struct Client *client_p, st
1042    if (a_limit_reached)
1043    {
1044      if (!IsConfExemptLimits(aconf))
1045 <      return TOO_MANY;  /* Already at maximum allowed */
1045 >      return TOO_MANY;   /* Already at maximum allowed */
1046  
1047      sendto_one(client_p,
1048                 ":%s NOTICE %s :*** Your connection class is full, "
# Line 1324 | Line 1315 | detach_conf(struct Client *client_p, Con
1315        case OPER_TYPE:
1316        case SERVER_TYPE:
1317          aconf = map_to_conf(conf);
1318 +
1319 +        assert(aconf->clients > 0);
1320 +
1321          if ((aclass_conf = ClassPtr(aconf)) != NULL)
1322          {
1323            aclass = map_to_conf(aclass_conf);
1324  
1325 +          assert(aclass->curr_user_count > 0);
1326 +
1327            if (conf->type == CLIENT_TYPE)
1328              remove_from_cidr_check(&client_p->localClient->ip, aclass);
1329 <
1334 <          if (CurrUserCount(aclass) > 0)
1335 <            aclass->curr_user_count--;
1336 <          if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0)
1329 >          if (--aclass->curr_user_count == 0 && aclass->active == 0)
1330              delete_conf_item(aclass_conf);
1331          }
1332  
1333 <        /* Please, no ioccc entries - Dianora */
1341 <        if (aconf->clients > 0)
1342 <          --aconf->clients;
1343 <        if (aconf->clients == 0 && IsConfIllegal(aconf))
1333 >        if (--aconf->clients == 0 && IsConfIllegal(aconf))
1334            delete_conf_item(conf);
1335 +
1336          break;
1337  
1338        case LEAF_TYPE:
# Line 1472 | Line 1463 | find_conf_exact(ConfType type, const cha
1463  
1464      if (conf->name == NULL)
1465        continue;
1466 <    aconf = (struct AccessItem *)map_to_conf(conf);
1466 >    aconf = map_to_conf(conf);
1467      if (aconf->host == NULL)
1468        continue;
1469      if (irccmp(conf->name, name) != 0)
# Line 1483 | Line 1474 | find_conf_exact(ConfType type, const cha
1474      ** socket host) matches *either* host or name field
1475      ** of the configuration.
1476      */
1477 <    if (!match(aconf->host, host) || !match(aconf->user,user)
1487 <        || irccmp(conf->name, name) )
1477 >    if (!match(aconf->host, host) || !match(aconf->user, user))
1478        continue;
1479      if (type == OPER_TYPE)
1480      {
1481 <      struct ClassItem *aclass;
1481 >      struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1482  
1483 <      aclass = (struct ClassItem *)aconf->class_ptr;
1494 <      if (aconf->clients < MaxTotal(aclass))
1495 <        return conf;
1496 <      else
1483 >      if (aconf->clients >= MaxTotal(aclass))
1484          continue;
1485      }
1486 <    else
1487 <      return conf;
1486 >
1487 >    return conf;
1488    }
1489 +
1490    return NULL;
1491   }
1492  
# Line 1853 | Line 1841 | set_default_conf(void)
1841    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;
# Line 1877 | Line 1866 | set_default_conf(void)
1866    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1867    ConfigServerHide.hide_server_ips = NO;
1868  
1869 +  
1870 +  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1871    ConfigFileEntry.gline_min_cidr = 16;
1872    ConfigFileEntry.gline_min_cidr6 = 48;
1873    ConfigFileEntry.invisible_on_connect = YES;
# Line 1990 | Line 1981 | validate_conf(void)
1981    if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
1982        (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
1983      ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
1984 +
1985 +  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1986   }
1987  
1988   /* lookup_confhost()
# Line 2321 | Line 2314 | expire_tklines(dlink_list *tklist)
2314          if (ConfigFileEntry.tkline_expire_notices)
2315            sendto_realops_flags(UMODE_ALL, L_ALL,
2316                                 "Temporary RESV for [%s] expired", cconf->name);
2317 <        dlinkDelete(ptr, tklist);
2325 <        free_dlink_node(ptr);
2326 <        delete_conf_item(conf);
2317 >        delete_channel_resv(cconf);
2318        }
2319      }
2320    }
# Line 2566 | Line 2557 | clear_out_old_conf(void)
2557        /* XXX This is less than pretty */
2558        if (conf->type == SERVER_TYPE)
2559        {
2560 <        aconf = (struct AccessItem *)map_to_conf(conf);
2560 >        aconf = map_to_conf(conf);
2561 >
2562          if (aconf->clients != 0)
2563          {
2564            SetConfIllegal(aconf);
# Line 2579 | Line 2571 | clear_out_old_conf(void)
2571        }
2572        else if (conf->type == OPER_TYPE)
2573        {
2574 <        aconf = (struct AccessItem *)map_to_conf(conf);
2574 >        aconf = map_to_conf(conf);
2575 >
2576          if (aconf->clients != 0)
2577          {
2578            SetConfIllegal(aconf);
# Line 2592 | Line 2585 | clear_out_old_conf(void)
2585        }
2586        else if (conf->type == CLIENT_TYPE)
2587        {
2588 <        aconf = (struct AccessItem *)map_to_conf(conf);
2588 >        aconf = map_to_conf(conf);
2589 >
2590          if (aconf->clients != 0)
2591          {
2592            SetConfIllegal(aconf);
# Line 2617 | Line 2611 | clear_out_old_conf(void)
2611        {
2612          if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2613          {
2614 <          match_item = (struct MatchItem *)map_to_conf(conf);
2615 <          if ((match_item->ref_count <= 0))
2614 >          match_item = map_to_conf(conf);
2615 >          if (match_item->ref_count <= 0)
2616              delete_conf_item(conf);
2617            else
2618            {
# Line 2632 | Line 2626 | clear_out_old_conf(void)
2626      }
2627    }
2628  
2629 <  /* don't delete the class table, rather mark all entries
2629 >  /*
2630 >   * don't delete the class table, rather mark all entries
2631     * for deletion. The table is cleaned up by check_class. - avalon
2632     */
2633    DLINK_FOREACH(ptr, class_items.head)
2634    {
2635 <    conf = ptr->data;
2636 <    cltmp = (struct ClassItem *)map_to_conf(conf);
2635 >    cltmp = map_to_conf(ptr->data);
2636 >
2637      if (ptr != class_items.tail)  /* never mark the "default" class */
2638 <      MaxTotal(cltmp) = -1;
2638 >      cltmp->active = 0;
2639    }
2640  
2641    clear_out_address_conf();
# Line 2890 | Line 2885 | find_class(const char *classname)
2885    struct ConfItem *conf;
2886  
2887    if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2888 <    return(conf);
2888 >    return conf;
2889  
2890    return class_default;
2891   }
# Line 2904 | Line 2899 | find_class(const char *classname)
2899   void
2900   check_class(void)
2901   {
2902 <  dlink_node *ptr;
2908 <  dlink_node *next_ptr;
2909 <  struct ConfItem *conf;
2910 <  struct ClassItem *aclass;
2902 >  dlink_node *ptr = NULL, *next_ptr = NULL;
2903  
2904    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)
2905    {
2906 <    conf = ptr->data;
2915 <    aclass = (struct ClassItem *)map_to_conf(conf);
2906 >    struct ClassItem *aclass = map_to_conf(ptr->data);
2907  
2908 <    if (MaxTotal(aclass) < 0)
2908 >    if (!aclass->active && !CurrUserCount(aclass))
2909      {
2910        destroy_cidr_class(aclass);
2911 <      if (CurrUserCount(aclass) > 0)
2921 <        dlinkDelete(&conf->node, &class_items);
2922 <      else
2923 <        delete_conf_item(conf);
2911 >      delete_conf_item(ptr->data);
2912      }
2913    }
2914   }
# Line 2937 | Line 2925 | init_class(void)
2925    struct ClassItem *aclass;
2926  
2927    class_default = make_conf_item(CLASS_TYPE);
2928 <  aclass = (struct ClassItem *)map_to_conf(class_default);
2928 >
2929 >  aclass = map_to_conf(class_default);
2930 >  aclass->active = 1;
2931    DupString(class_default->name, "default");
2932    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2933    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
# Line 2996 | Line 2986 | get_sendq(struct Client *client_p)
2986   void
2987   conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)
2988   {
2989 <  struct AccessItem *aconf;
2990 <  struct ClassItem *aclass;
3001 <
3002 <  aconf = (struct AccessItem *)map_to_conf(conf);
2989 >  struct AccessItem *aconf = map_to_conf(conf);
2990 >  struct ClassItem *class = NULL;
2991  
2992    if (class_name == NULL)
2993    {
2994      aconf->class_ptr = class_default;
2995 +
2996      if (conf->type == CLIENT_TYPE)
2997        sendto_realops_flags(UMODE_ALL, L_ALL,
2998                             "Warning *** Defaulting to default class for %s@%s",
# Line 3014 | Line 3003 | conf_add_class_to_conf(struct ConfItem *
3003                             conf->name);
3004    }
3005    else
3017  {
3006      aconf->class_ptr = find_class(class_name);
3019  }
3007  
3008 <  if (aconf->class_ptr == NULL)
3008 >  if (aconf->class_ptr)
3009 >    class = map_to_conf(aconf->class_ptr);
3010 >
3011 >  if (aconf->class_ptr == NULL || !class->active)
3012    {
3013      if (conf->type == CLIENT_TYPE)
3014        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 3030 | Line 3020 | conf_add_class_to_conf(struct ConfItem *
3020                             conf->name);
3021      aconf->class_ptr = class_default;
3022    }
3033  else
3034  {
3035    aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
3036    if (MaxTotal(aclass) < 0)
3037    {
3038      aconf->class_ptr = class_default;
3039    }
3040  }
3023   }
3024  
3043 #define MAXCONFLINKS 150
3044
3025   /* conf_add_server()
3026   *
3027   * inputs       - pointer to config item
# Line 3414 | Line 3394 | parse_aline(const char *cmd, struct Clie
3394  
3395    if (reason != NULL)
3396    {
3397 <    if (parc != 0)
3397 >    if (parc != 0 && !EmptyString(*parv))
3398      {
3399        *reason = *parv;
3400        if (!valid_comment(source_p, *reason, YES))
# Line 3920 | Line 3900 | rebuild_cidr_class(struct ConfItem *conf
3900   static void
3901   destroy_cidr_list(dlink_list *list)
3902   {
3903 <  dlink_node *ptr = NULL;
3924 <  dlink_node *next_ptr = NULL;
3925 <  struct CidrItem *cidr;
3903 >  dlink_node *ptr = NULL, *next_ptr = NULL;
3904  
3905    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
3906    {
3929    cidr = ptr->data;
3907      dlinkDelete(ptr, list);
3908 <    MyFree(cidr);
3908 >    MyFree(ptr->data);
3909    }
3910   }
3911  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines