/[svn]/ircd-hybrid-7.2/src/s_conf.c
ViewVC logotype

Diff of /ircd-hybrid-7.2/src/s_conf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 632 by michael, Thu Jun 1 10:53:00 2006 UTC revision 671 by michael, Tue Jun 13 07:15:38 2006 UTC
# Line 337  make_conf_item(ConfType type) Line 337  make_conf_item(ConfType type)
337      break;      break;
338    
339    case CLASS_TYPE:    case CLASS_TYPE:
340      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +      conf = MyMalloc(sizeof(struct ConfItem) +
341                                         sizeof(struct ClassItem));                             sizeof(struct ClassItem));
342      dlinkAdd(conf, &conf->node, &class_items);      dlinkAdd(conf, &conf->node, &class_items);
343      aclass = (struct ClassItem *)map_to_conf(conf);  
344      ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;      aclass = map_to_conf(conf);
345        aclass->active = 1;
346        ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
347      PingFreq(aclass) = DEFAULT_PINGFREQUENCY;      PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
348      MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;      MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
349      MaxSendq(aclass) = DEFAULT_SENDQ;      MaxSendq(aclass) = DEFAULT_SENDQ;
350      CurrUserCount(aclass) = 0;  
351      break;      break;
352    
353    default:    default:
# Line 356  make_conf_item(ConfType type) Line 358  make_conf_item(ConfType type)
358    /* XXX Yes, this will core if default is hit. I want it to for now - db */    /* XXX Yes, this will core if default is hit. I want it to for now - db */
359    conf->type = type;    conf->type = type;
360    
361    return(conf);    return conf;
362  }  }
363    
364  void  void
# Line 723  report_confitem_types(struct Client *sou Line 725  report_confitem_types(struct Client *sou
725                   conf->name, PingFreq(classitem),                   conf->name, PingFreq(classitem),
726                   ConFreq(classitem),                   ConFreq(classitem),
727                   MaxTotal(classitem), MaxSendq(classitem),                   MaxTotal(classitem), MaxSendq(classitem),
728                   CurrUserCount(classitem));                   CurrUserCount(classitem),
729                     classitem->active ? "active" : "disabled");
730      }      }
731      break;      break;
732    
# Line 758  report_confitem_types(struct Client *sou Line 761  report_confitem_types(struct Client *sou
761    
762        *p = '\0';        *p = '\0';
763    
764        /* Allow admins to see actual ips        /*
765         * unless hide_server_ips is enabled         * Allow admins to see actual ips unless hide_server_ips is enabled
766         */         */
767        if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))        if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
768          sendto_one(source_p, form_str(RPL_STATSCLINE),          sendto_one(source_p, form_str(RPL_STATSCLINE),
# Line 827  check_client(va_list args) Line 830  check_client(va_list args)
830    
831    /* I'm already in big trouble if source_p->localClient is NULL -db */    /* I'm already in big trouble if source_p->localClient is NULL -db */
832    if ((i = verify_access(source_p, username)))    if ((i = verify_access(source_p, username)))
   {  
833      ilog(L_INFO, "Access denied: %s[%s]",      ilog(L_INFO, "Access denied: %s[%s]",
834           source_p->name, source_p->sockhost);           source_p->name, source_p->sockhost);
   }  
835    
836    switch (i)    switch (i)
837    {    {
# Line 882  check_client(va_list args) Line 883  check_client(va_list args)
883         * capture reject code here or rely on the connecting too fast code.         * capture reject code here or rely on the connecting too fast code.
884         * - Dianora         * - Dianora
885         */         */
886        if(REJECT_HOLD_TIME > 0)        if (REJECT_HOLD_TIME > 0)
887        {        {
888          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
889                     me.name, source_p->name);                     me.name, source_p->name);
# Line 1324  detach_conf(struct Client *client_p, Con Line 1325  detach_conf(struct Client *client_p, Con
1325        case OPER_TYPE:        case OPER_TYPE:
1326        case SERVER_TYPE:        case SERVER_TYPE:
1327          aconf = map_to_conf(conf);          aconf = map_to_conf(conf);
1328    
1329            /* Please, no ioccc entries - Dianora */
1330            if (aconf->clients > 0)
1331              --aconf->clients;
1332            if (aconf->clients == 0 && IsConfIllegal(aconf))
1333              delete_conf_item(conf);
1334    
1335          if ((aclass_conf = ClassPtr(aconf)) != NULL)          if ((aclass_conf = ClassPtr(aconf)) != NULL)
1336          {          {
1337            aclass = map_to_conf(aclass_conf);            aclass = map_to_conf(aclass_conf);
1338    
1339            if (conf->type == CLIENT_TYPE)            if (conf->type == CLIENT_TYPE)
1340              remove_from_cidr_check(&client_p->localClient->ip, aclass);              remove_from_cidr_check(&client_p->localClient->ip, aclass);
1341              if (aclass->curr_user_count > 0)
1342            if (CurrUserCount(aclass) > 0)              --aclass->curr_user_count;
1343              aclass->curr_user_count--;            if (aclass->active == 0 && aclass->curr_user_count <= 0)
           if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0)  
1344              delete_conf_item(aclass_conf);              delete_conf_item(aclass_conf);
1345          }          }
1346    
         /* Please, no ioccc entries - Dianora */  
         if (aconf->clients > 0)  
           --aconf->clients;  
         if (aconf->clients == 0 && IsConfIllegal(aconf))  
           delete_conf_item(conf);  
1347          break;          break;
1348    
1349        case LEAF_TYPE:        case LEAF_TYPE:
# Line 2567  clear_out_old_conf(void) Line 2569  clear_out_old_conf(void)
2569        /* XXX This is less than pretty */        /* XXX This is less than pretty */
2570        if (conf->type == SERVER_TYPE)        if (conf->type == SERVER_TYPE)
2571        {        {
2572          aconf = (struct AccessItem *)map_to_conf(conf);          aconf = map_to_conf(conf);
2573    
2574          if (aconf->clients != 0)          if (aconf->clients != 0)
2575          {          {
2576            SetConfIllegal(aconf);            SetConfIllegal(aconf);
# Line 2580  clear_out_old_conf(void) Line 2583  clear_out_old_conf(void)
2583        }        }
2584        else if (conf->type == OPER_TYPE)        else if (conf->type == OPER_TYPE)
2585        {        {
2586          aconf = (struct AccessItem *)map_to_conf(conf);          aconf = map_to_conf(conf);
2587    
2588          if (aconf->clients != 0)          if (aconf->clients != 0)
2589          {          {
2590            SetConfIllegal(aconf);            SetConfIllegal(aconf);
# Line 2593  clear_out_old_conf(void) Line 2597  clear_out_old_conf(void)
2597        }        }
2598        else if (conf->type == CLIENT_TYPE)        else if (conf->type == CLIENT_TYPE)
2599        {        {
2600          aconf = (struct AccessItem *)map_to_conf(conf);          aconf = map_to_conf(conf);
2601    
2602          if (aconf->clients != 0)          if (aconf->clients != 0)
2603          {          {
2604            SetConfIllegal(aconf);            SetConfIllegal(aconf);
# Line 2618  clear_out_old_conf(void) Line 2623  clear_out_old_conf(void)
2623        {        {
2624          if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))          if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2625          {          {
2626            match_item = (struct MatchItem *)map_to_conf(conf);            match_item = map_to_conf(conf);
2627            if ((match_item->ref_count <= 0))            if (match_item->ref_count <= 0)
2628              delete_conf_item(conf);              delete_conf_item(conf);
2629            else            else
2630            {            {
# Line 2633  clear_out_old_conf(void) Line 2638  clear_out_old_conf(void)
2638      }      }
2639    }    }
2640    
2641    /* don't delete the class table, rather mark all entries    /*
2642       * don't delete the class table, rather mark all entries
2643     * for deletion. The table is cleaned up by check_class. - avalon     * for deletion. The table is cleaned up by check_class. - avalon
2644     */     */
2645    DLINK_FOREACH(ptr, class_items.head)    DLINK_FOREACH(ptr, class_items.head)
2646    {    {
2647      conf = ptr->data;      cltmp = map_to_conf(ptr->data);
2648      cltmp = (struct ClassItem *)map_to_conf(conf);  
2649      if (ptr != class_items.tail)  /* never mark the "default" class */      if (ptr != class_items.tail)  /* never mark the "default" class */
2650        MaxTotal(cltmp) = -1;        cltmp->active = 0;
2651    }    }
2652    
2653    clear_out_address_conf();    clear_out_address_conf();
# Line 2891  find_class(const char *classname) Line 2897  find_class(const char *classname)
2897    struct ConfItem *conf;    struct ConfItem *conf;
2898    
2899    if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)    if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2900      return(conf);      return conf;
2901    
2902    return class_default;    return class_default;
2903  }  }
# Line 2905  find_class(const char *classname) Line 2911  find_class(const char *classname)
2911  void  void
2912  check_class(void)  check_class(void)
2913  {  {
2914    dlink_node *ptr;    dlink_node *ptr = NULL, *next_ptr = NULL;
   dlink_node *next_ptr;  
   struct ConfItem *conf;  
   struct ClassItem *aclass;  
2915    
2916    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)
2917    {    {
2918      conf = ptr->data;      struct ClassItem *aclass = map_to_conf(ptr->data);
     aclass = (struct ClassItem *)map_to_conf(conf);  
2919    
2920      if (MaxTotal(aclass) < 0)      if (!aclass->active)
2921      {      {
2922        destroy_cidr_class(aclass);        destroy_cidr_class(aclass);
2923        if (CurrUserCount(aclass) > 0)  
2924          dlinkDelete(&conf->node, &class_items);        if (!CurrUserCount(aclass))
2925        else          delete_conf_item(ptr->data);
         delete_conf_item(conf);  
2926      }      }
2927    }    }
2928  }  }
# Line 2938  init_class(void) Line 2939  init_class(void)
2939    struct ClassItem *aclass;    struct ClassItem *aclass;
2940    
2941    class_default = make_conf_item(CLASS_TYPE);    class_default = make_conf_item(CLASS_TYPE);
2942    aclass = (struct ClassItem *)map_to_conf(class_default);  
2943      aclass = map_to_conf(class_default);
2944      aclass->active = 1;
2945    DupString(class_default->name, "default");    DupString(class_default->name, "default");
2946    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2947    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
# Line 2997  get_sendq(struct Client *client_p) Line 3000  get_sendq(struct Client *client_p)
3000  void  void
3001  conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)  conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)
3002  {  {
3003    struct AccessItem *aconf;    struct AccessItem *aconf = map_to_conf(conf);
3004    struct ClassItem *aclass;    struct ClassItem *class = NULL;
   
   aconf = (struct AccessItem *)map_to_conf(conf);  
3005    
3006    if (class_name == NULL)    if (class_name == NULL)
3007    {    {
3008      aconf->class_ptr = class_default;      aconf->class_ptr = class_default;
3009    
3010      if (conf->type == CLIENT_TYPE)      if (conf->type == CLIENT_TYPE)
3011        sendto_realops_flags(UMODE_ALL, L_ALL,        sendto_realops_flags(UMODE_ALL, L_ALL,
3012                             "Warning *** Defaulting to default class for %s@%s",                             "Warning *** Defaulting to default class for %s@%s",
# Line 3015  conf_add_class_to_conf(struct ConfItem * Line 3017  conf_add_class_to_conf(struct ConfItem *
3017                             conf->name);                             conf->name);
3018    }    }
3019    else    else
   {  
3020      aconf->class_ptr = find_class(class_name);      aconf->class_ptr = find_class(class_name);
   }  
3021    
3022    if (aconf->class_ptr == NULL)    if (aconf->class_ptr)
3023        class = map_to_conf(aconf->class_ptr);
3024    
3025      if (aconf->class_ptr == NULL || !class->active)
3026    {    {
3027      if (conf->type == CLIENT_TYPE)      if (conf->type == CLIENT_TYPE)
3028        sendto_realops_flags(UMODE_ALL, L_ALL,        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 3031  conf_add_class_to_conf(struct ConfItem * Line 3034  conf_add_class_to_conf(struct ConfItem *
3034                             conf->name);                             conf->name);
3035      aconf->class_ptr = class_default;      aconf->class_ptr = class_default;
3036    }    }
   else  
   {  
     aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);  
     if (MaxTotal(aclass) < 0)  
     {  
       aconf->class_ptr = class_default;  
     }  
   }  
3037  }  }
3038    
 #define MAXCONFLINKS 150  
   
3039  /* conf_add_server()  /* conf_add_server()
3040   *   *
3041   * inputs       - pointer to config item   * inputs       - pointer to config item
# Line 3921  rebuild_cidr_class(struct ConfItem *conf Line 3914  rebuild_cidr_class(struct ConfItem *conf
3914  static void  static void
3915  destroy_cidr_list(dlink_list *list)  destroy_cidr_list(dlink_list *list)
3916  {  {
3917    dlink_node *ptr = NULL;    dlink_node *ptr = NULL, *next_ptr = NULL;
   dlink_node *next_ptr = NULL;  
   struct CidrItem *cidr;  
3918    
3919    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
3920    {    {
     cidr = ptr->data;  
3921      dlinkDelete(ptr, list);      dlinkDelete(ptr, list);
3922      MyFree(cidr);      MyFree(ptr->data);
3923    }    }
3924  }  }
3925    

Legend:
Removed from v.632  
changed lines
  Added in v.671

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26