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 8314 by michael, Wed Feb 28 17:47:23 2018 UTC vs.
Revision 8496 by michael, Thu Apr 5 12:46:00 2018 UTC

# Line 27 | Line 27
27   #include "stdinc.h"
28   #include "list.h"
29   #include "ircd_defs.h"
30 + #include "parse.h"
31   #include "conf.h"
32   #include "conf_cluster.h"
33   #include "conf_gecos.h"
# Line 50 | Line 51
51   #include "send.h"
52   #include "memory.h"
53   #include "res.h"
53 #include "userhost.h"
54   #include "user.h"
55   #include "channel_mode.h"
56 #include "parse.h"
56   #include "misc.h"
57   #include "conf_db.h"
58   #include "conf_class.h"
# Line 218 | Line 217 | static int
217   attach_iline(struct Client *client_p, struct MaskItem *conf)
218   {
219    const struct ClassItem *const class = conf->class;
221  struct ip_entry *ip_found;
220    int a_limit_reached = 0;
223  unsigned int local = 0, global = 0;
221  
222 <  ip_found = ipcache_find_or_add_address(&client_p->connection->ip);
223 <  ip_found->count++;
222 >  struct ip_entry *ipcache = ipcache_find_or_add_address(&client_p->ip);
223 >  ++ipcache->count_local;
224    AddFlag(client_p, FLAGS_IPHASH);
225  
229  userhost_count(client_p->sockhost, &global, &local);
230
231  /* XXX blah. go down checking the various silly limits
232   * setting a_limit_reached if any limit is reached.
233   * - Dianora
234   */
226    if (class->max_total && class->ref_count >= class->max_total)
227      a_limit_reached = 1;
228 <  else if (class->max_perip && ip_found->count > class->max_perip)
238 <    a_limit_reached = 1;
239 <  else if (class->max_local && local >= class->max_local) /* XXX: redundant */
228 >  else if (class->max_perip_local && ipcache->count_local > class->max_perip_local)
229      a_limit_reached = 1;
230 <  else if (class->max_global && global >= class->max_global)
230 >  else if (class->max_perip_global &&
231 >           (ipcache->count_local + ipcache->count_remote) > class->max_perip_global)
232      a_limit_reached = 1;
233  
234    if (a_limit_reached)
# Line 250 | Line 240 | attach_iline(struct Client *client_p, st
240                        "but you have exceed_limit = yes;");
241    }
242  
243 <  return attach_conf(client_p, conf);
243 >  return conf_attach(client_p, conf);
244   }
245  
246   /* verify_access()
# Line 267 | Line 257 | verify_access(struct Client *client_p)
257    if (HasFlag(client_p, FLAGS_GOTID))
258    {
259      conf = find_address_conf(client_p->host, client_p->username,
260 <                             &client_p->connection->ip,
260 >                             &client_p->ip,
261                               client_p->connection->aftype,
262                               client_p->connection->password);
263    }
# Line 277 | Line 267 | verify_access(struct Client *client_p)
267  
268      strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
269      conf = find_address_conf(client_p->host, non_ident,
270 <                             &client_p->connection->ip,
270 >                             &client_p->ip,
271                               client_p->connection->aftype,
272                               client_p->connection->password);
273    }
# Line 389 | Line 379 | check_client(struct Client *source_p)
379    return !(i < 0);
380   }
381  
382 < /* detach_conf()
383 < *
384 < * inputs       - pointer to client to detach
385 < *              - type of conf to detach
396 < * output       - 0 for success, -1 for failure
397 < * side effects - Disassociate configuration from the client.
398 < *                Also removes a class from the list if marked for deleting.
382 > /*! \brief Disassociate configuration from the client. Also removes a class
383 > *         from the list if marked for deleting.
384 > * \param client_p Client to operate on
385 > * \param type     Type of conf to detach
386   */
387   void
388 < detach_conf(struct Client *client_p, enum maskitem_type type)
388 > conf_detach(struct Client *client_p, enum maskitem_type type)
389   {
390 <  dlink_node *node = NULL, *node_next = NULL;
390 >  dlink_node *node, *node_next;
391  
392    DLINK_FOREACH_SAFE(node, node_next, client_p->connection->confs.head)
393    {
# Line 417 | Line 404 | detach_conf(struct Client *client_p, enu
404      free_dlink_node(node);
405  
406      if (conf->type == CONF_CLIENT)
407 <      remove_from_cidr_check(&client_p->connection->ip, conf->class);
407 >      remove_from_cidr_check(&client_p->ip, conf->class);
408  
409      if (--conf->class->ref_count == 0 && conf->class->active == 0)
410      {
# Line 430 | Line 417 | detach_conf(struct Client *client_p, enu
417    }
418   }
419  
420 < /* attach_conf()
421 < *
422 < * inputs       - client pointer
423 < *              - conf pointer
424 < * output       -
438 < * side effects - Associate a specific configuration entry to a *local*
439 < *                client (this is the one which used in accepting the
440 < *                connection). Note, that this automatically changes the
441 < *                attachment if there was an old one...
420 > /*! \brief Associate a specific configuration entry to a *local* client (this
421 > *         is the one which used in accepting the connection). Note, that this
422 > *         automatically changes the attachment if there was an old one.
423 > * \param client_p Client to attach the conf to
424 > * \param conf Configuration record to attach
425   */
426   int
427 < attach_conf(struct Client *client_p, struct MaskItem *conf)
427 > conf_attach(struct Client *client_p, struct MaskItem *conf)
428   {
429    if (dlinkFind(&client_p->connection->confs, conf))
430      return 1;
431  
432    if (conf->type == CONF_CLIENT)
433      if (cidr_limit_reached(IsConfExemptLimits(conf),
434 <                           &client_p->connection->ip, conf->class))
434 >                           &client_p->ip, conf->class))
435        return TOO_MANY;    /* Already at maximum allowed */
436  
437    conf->class->ref_count++;
# Line 459 | Line 442 | attach_conf(struct Client *client_p, str
442    return 0;
443   }
444  
462 /* attach_connect_block()
463 *
464 * inputs       - pointer to server to attach
465 *              - name of server
466 *              - hostname of server
467 * output       - true (1) if both are found, otherwise return false (0)
468 * side effects - find connect block and attach them to connecting client
469 */
470 int
471 attach_connect_block(struct Client *client_p, const char *name,
472                     const char *host)
473 {
474  dlink_node *node = NULL;
475
476  assert(host);
477
478  DLINK_FOREACH(node, connect_items.head)
479  {
480    struct MaskItem *conf = node->data;
481
482    if (irccmp(conf->name, name) ||
483        irccmp(conf->host, host))
484      continue;
485
486    attach_conf(client_p, conf);
487    return 1;
488  }
489
490  return 0;
491 }
492
445   /* find_conf_name()
446   *
447   * inputs       - pointer to conf link list to search
# Line 518 | Line 470 | find_conf_name(dlink_list *list, const c
470    return NULL;
471   }
472  
473 < /* find_matching_name_conf()
474 < *
475 < * inputs       - type of link list to look in
524 < *              - pointer to name string to find
525 < *              - pointer to user
526 < *              - pointer to host
527 < *              - optional flags to match on as well
528 < * output       - NULL or pointer to found struct MaskItem
529 < * side effects - looks for a match on name field
473 > /*! \brief Find a connect {} conf that has a name that matches \a name.
474 > * \param name Name to match
475 > * \param compare Pointer to function to be used for string matching
476   */
477   struct MaskItem *
478 < connect_find(const char *name, const char *host, int (*compare)(const char *, const char *))
478 > connect_find(const char *name, int (*compare)(const char *, const char *))
479   {
480 <  dlink_node *node = NULL;
480 >  dlink_node *node;
481  
482    DLINK_FOREACH(node, connect_items.head)
483    {
484      struct MaskItem *conf = node->data;
485  
486 <    if (name && !compare(name, conf->name))
541 <      return conf;
542 <    if (host && !compare(host, conf->host))
486 >    if (!compare(name, conf->name))
487        return conf;
488    }
489  
# Line 580 | Line 524 | operator_find(const struct Client *who,
524              break;
525            case HM_IPV4:
526              if (who->connection->aftype == AF_INET)
527 <              if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
527 >              if (match_ipv4(&who->ip, &conf->addr, conf->bits))
528                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
529                    return conf;
530              break;
531            case HM_IPV6:
532              if (who->connection->aftype == AF_INET6)
533 <              if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
533 >              if (match_ipv6(&who->ip, &conf->addr, conf->bits))
534                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
535                    return conf;
536              break;
# Line 1047 | Line 991 | clear_out_old_conf(void)
991    xfree(ConfigAdminInfo.description);
992    ConfigAdminInfo.description = NULL;
993  
994 +  /* Clean out ConfigServerHide */
995    xfree(ConfigServerHide.flatten_links_file);
996    ConfigServerHide.flatten_links_file = NULL;
997 +  xfree(ConfigServerHide.hidden_name);
998 +  ConfigServerHide.hidden_name = NULL;
999  
1000    /* Clean out listeners */
1001    listener_close_marked();
# Line 1134 | Line 1081 | read_conf_files(int cold)
1081    snprintf(chanlimit, sizeof(chanlimit), "#:%u",
1082             ConfigChannel.max_channels);
1083    isupport_add("CHANLIMIT", chanlimit, -1);
1084 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstuCLMORST");
1084 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstuCLMNORST");
1085    isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1086    isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1087    isupport_add("CHANMODES", chanmodes, -1);

Diff Legend

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