/[svn]/ircd-hybrid-8/src/conf.c
ViewVC logotype

Diff of /ircd-hybrid-8/src/conf.c

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

revision 1376 by michael, Wed Apr 25 19:04:19 2012 UTC revision 1377 by michael, Mon Apr 30 19:35:16 2012 UTC
# Line 324  make_conf_item(ConfType type) Line 324  make_conf_item(ConfType type)
324    
325      aclass = map_to_conf(conf);      aclass = map_to_conf(conf);
326      aclass->active = 1;      aclass->active = 1;
327      ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;      aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
328      PingFreq(aclass) = DEFAULT_PINGFREQUENCY;      aclass->ping_freq = DEFAULT_PINGFREQUENCY;
329      MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;      aclass->max_total = MAXIMUM_LINKS_DEFAULT;
330      MaxSendq(aclass) = DEFAULT_SENDQ;      aclass->max_sendq = DEFAULT_SENDQ;
331    
332      break;      break;
333    
# Line 701  report_confitem_types(struct Client *sou Line 701  report_confitem_types(struct Client *sou
701        classitem = map_to_conf(conf);        classitem = map_to_conf(conf);
702        sendto_one(source_p, form_str(RPL_STATSYLINE),        sendto_one(source_p, form_str(RPL_STATSYLINE),
703                   me.name, source_p->name, 'Y',                   me.name, source_p->name, 'Y',
704                   conf->name, PingFreq(classitem),                   conf->name, classitem->ping_freq,
705                   ConFreq(classitem),                   classitem->con_freq,
706                   MaxTotal(classitem), MaxSendq(classitem),                   classitem->max_total, classitem->max_sendq,
707                   CurrUserCount(classitem),                   classitem->curr_user_count,
708                   classitem->active ? "active" : "disabled");                   classitem->active ? "active" : "disabled");
709      }      }
710      break;      break;
# Line 1014  attach_iline(struct Client *client_p, st Line 1014  attach_iline(struct Client *client_p, st
1014     * setting a_limit_reached if any limit is reached.     * setting a_limit_reached if any limit is reached.
1015     * - Dianora     * - Dianora
1016     */     */
1017    if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))    if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
1018      a_limit_reached = 1;      a_limit_reached = 1;
1019    else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))    else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
1020      a_limit_reached = 1;      a_limit_reached = 1;
1021    else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))    else if (aclass->max_local != 0 && local >= aclass->max_local)
1022      a_limit_reached = 1;      a_limit_reached = 1;
1023    else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))    else if (aclass->max_global != 0 && global >= aclass->max_global)
1024      a_limit_reached = 1;      a_limit_reached = 1;
1025    else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&    else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
1026             client_p->username[0] != '~')             client_p->username[0] != '~')
1027      a_limit_reached = 1;      a_limit_reached = 1;
1028    
# Line 1305  detach_conf(struct Client *client_p, Con Line 1305  detach_conf(struct Client *client_p, Con
1305    
1306          assert(aconf->clients > 0);          assert(aconf->clients > 0);
1307    
1308          if ((aclass_conf = ClassPtr(aconf)) != NULL)          if ((aclass_conf = aconf->class_ptr) != NULL)
1309          {          {
1310            aclass = map_to_conf(aclass_conf);            aclass = map_to_conf(aclass_conf);
1311    
# Line 1371  attach_conf(struct Client *client_p, str Line 1371  attach_conf(struct Client *client_p, str
1371                               &client_p->localClient->ip, aclass))                               &client_p->localClient->ip, aclass))
1372          return TOO_MANY;    /* Already at maximum allowed */          return TOO_MANY;    /* Already at maximum allowed */
1373    
1374      CurrUserCount(aclass)++;      aclass->curr_user_count++;
1375      aconf->clients++;      aconf->clients++;
1376    }    }
1377    else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)    else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
# Line 1467  find_conf_exact(ConfType type, const cha Line 1467  find_conf_exact(ConfType type, const cha
1467      {      {
1468        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1469    
1470        if (aconf->clients >= MaxTotal(aclass))        if (aconf->clients >= aclass->max_total)
1471          continue;          continue;
1472      }      }
1473    
# Line 2724  get_conf_ping(struct ConfItem *conf, int Line 2724  get_conf_ping(struct ConfItem *conf, int
2724      if (aconf->class_ptr != NULL)      if (aconf->class_ptr != NULL)
2725      {      {
2726        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2727        *pingwarn = PingWarning(aclass);        *pingwarn = aclass->ping_warning;
2728        return PingFreq(aclass);        return aclass->ping_freq;
2729      }      }
2730    }    }
2731    
# Line 2829  check_class(void) Line 2829  check_class(void)
2829    {    {
2830      struct ClassItem *aclass = map_to_conf(ptr->data);      struct ClassItem *aclass = map_to_conf(ptr->data);
2831    
2832      if (!aclass->active && !CurrUserCount(aclass))      if (!aclass->active && !aclass->curr_user_count)
2833      {      {
2834        destroy_cidr_class(aclass);        destroy_cidr_class(aclass);
2835        delete_conf_item(ptr->data);        delete_conf_item(ptr->data);
# Line 2853  init_class(void) Line 2853  init_class(void)
2853    aclass = map_to_conf(class_default);    aclass = map_to_conf(class_default);
2854    aclass->active = 1;    aclass->active = 1;
2855    DupString(class_default->name, "default");    DupString(class_default->name, "default");
2856    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;    aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2857    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2858    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2859    MaxSendq(aclass) = DEFAULT_SENDQ;    aclass->max_sendq = DEFAULT_SENDQ;
2860    
2861    client_check_cb = register_callback("check_client", check_client);    client_check_cb = register_callback("check_client", check_client);
2862  }  }
# Line 2889  get_sendq(struct Client *client_p) Line 2889  get_sendq(struct Client *client_p)
2889          if ((class_conf = aconf->class_ptr) == NULL)          if ((class_conf = aconf->class_ptr) == NULL)
2890            continue;            continue;
2891          aclass = (struct ClassItem *)map_to_conf(class_conf);          aclass = (struct ClassItem *)map_to_conf(class_conf);
2892          sendq = MaxSendq(aclass);          sendq = aclass->max_sendq;
2893          return sendq;          return sendq;
2894        }        }
2895      }      }
# Line 3568  cidr_limit_reached(int over_rule, Line 3568  cidr_limit_reached(int over_rule,
3568    dlink_node *ptr = NULL;    dlink_node *ptr = NULL;
3569    struct CidrItem *cidr;    struct CidrItem *cidr;
3570    
3571    if (NumberPerCidr(aclass) <= 0)    if (aclass->number_per_cidr <= 0)
3572      return 0;      return 0;
3573    
3574    if (ip->ss.ss_family == AF_INET)    if (ip->ss.ss_family == AF_INET)
3575    {    {
3576      if (CidrBitlenIPV4(aclass) <= 0)      if (aclass->cidr_bitlen_ipv4 <= 0)
3577        return 0;        return 0;
3578    
3579      DLINK_FOREACH(ptr, aclass->list_ipv4.head)      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3580      {      {
3581        cidr = ptr->data;        cidr = ptr->data;
3582        if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))        if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3583        {        {
3584          if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))          if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3585            return -1;            return -1;
3586          cidr->number_on_this_cidr++;          cidr->number_on_this_cidr++;
3587          return 0;          return 0;
# Line 3590  cidr_limit_reached(int over_rule, Line 3590  cidr_limit_reached(int over_rule,
3590      cidr = MyMalloc(sizeof(struct CidrItem));      cidr = MyMalloc(sizeof(struct CidrItem));
3591      cidr->number_on_this_cidr = 1;      cidr->number_on_this_cidr = 1;
3592      cidr->mask = *ip;      cidr->mask = *ip;
3593      mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));      mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3594      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3595    }    }
3596  #ifdef IPV6  #ifdef IPV6
3597    else if (CidrBitlenIPV6(aclass) > 0)    else if (aclass->cidr_bitlen_ipv6 > 0)
3598    {    {
3599      DLINK_FOREACH(ptr, aclass->list_ipv6.head)      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3600      {      {
3601        cidr = ptr->data;        cidr = ptr->data;
3602        if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))        if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3603        {        {
3604          if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))          if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3605            return -1;            return -1;
3606          cidr->number_on_this_cidr++;          cidr->number_on_this_cidr++;
3607          return 0;          return 0;
# Line 3610  cidr_limit_reached(int over_rule, Line 3610  cidr_limit_reached(int over_rule,
3610      cidr = MyMalloc(sizeof(struct CidrItem));      cidr = MyMalloc(sizeof(struct CidrItem));
3611      cidr->number_on_this_cidr = 1;      cidr->number_on_this_cidr = 1;
3612      cidr->mask = *ip;      cidr->mask = *ip;
3613      mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));      mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3614      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3615    }    }
3616  #endif  #endif
# Line 3632  remove_from_cidr_check(struct irc_ssaddr Line 3632  remove_from_cidr_check(struct irc_ssaddr
3632    dlink_node *next_ptr = NULL;    dlink_node *next_ptr = NULL;
3633    struct CidrItem *cidr;    struct CidrItem *cidr;
3634    
3635    if (NumberPerCidr(aclass) == 0)    if (aclass->number_per_cidr == 0)
3636      return;      return;
3637    
3638    if (ip->ss.ss_family == AF_INET)    if (ip->ss.ss_family == AF_INET)
3639    {    {
3640      if (CidrBitlenIPV4(aclass) <= 0)      if (aclass->cidr_bitlen_ipv4 <= 0)
3641        return;        return;
3642    
3643      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3644      {      {
3645        cidr = ptr->data;        cidr = ptr->data;
3646        if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))        if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3647        {        {
3648          cidr->number_on_this_cidr--;          cidr->number_on_this_cidr--;
3649          if (cidr->number_on_this_cidr == 0)          if (cidr->number_on_this_cidr == 0)
# Line 3656  remove_from_cidr_check(struct irc_ssaddr Line 3656  remove_from_cidr_check(struct irc_ssaddr
3656      }      }
3657    }    }
3658  #ifdef IPV6  #ifdef IPV6
3659    else if (CidrBitlenIPV6(aclass) > 0)    else if (aclass->cidr_bitlen_ipv6 > 0)
3660    {    {
3661      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3662      {      {
3663        cidr = ptr->data;        cidr = ptr->data;
3664        if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))        if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3665        {        {
3666          cidr->number_on_this_cidr--;          cidr->number_on_this_cidr--;
3667          if (cidr->number_on_this_cidr == 0)          if (cidr->number_on_this_cidr == 0)
# Line 3724  rebuild_cidr_class(struct ConfItem *conf Line 3724  rebuild_cidr_class(struct ConfItem *conf
3724  {  {
3725    struct ClassItem *old_class = map_to_conf(conf);    struct ClassItem *old_class = map_to_conf(conf);
3726    
3727    if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)    if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3728    {    {
3729      if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)      if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3730        rebuild_cidr_list(AF_INET, conf, new_class,        rebuild_cidr_list(AF_INET, conf, new_class,
3731                          &old_class->list_ipv4, &new_class->list_ipv4,                          &old_class->list_ipv4, &new_class->list_ipv4,
3732                          CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));                          old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3733    
3734  #ifdef IPV6  #ifdef IPV6
3735      if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)      if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3736        rebuild_cidr_list(AF_INET6, conf, new_class,        rebuild_cidr_list(AF_INET6, conf, new_class,
3737                          &old_class->list_ipv6, &new_class->list_ipv6,                          &old_class->list_ipv6, &new_class->list_ipv6,
3738                          CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));                          old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3739  #endif  #endif
3740    }    }
3741    

Legend:
Removed from v.1376  
changed lines
  Added in v.1377

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