]> jfr.im git - irc/rizon/plexus4.git/commitdiff
Remove namehost and no longer track usernames, based on upstream r7624
authorAdam <redacted>
Mon, 10 Oct 2016 22:06:18 +0000 (18:06 -0400)
committerAdam <redacted>
Mon, 10 Oct 2016 22:06:30 +0000 (18:06 -0400)
configure.ac
include/conf_class.h
include/userhost.h
modules/m_chghost.c
src/client.c
src/conf.c
src/conf_lexer.l
src/conf_parser.y
src/hash.c
src/s_user.c
src/upgrade.c

index 2b7b1a8d06743187691587424342a91cbab84d5f..ae0b7d713bd837be44c7b4acd87485064bc81420 100644 (file)
@@ -148,7 +148,6 @@ AC_DEFINE([MP_CHUNK_SIZE_DBUF], 512*1024, [Size of the dbuf mempool chunk.])
 AC_DEFINE([MP_CHUNK_SIZE_AUTH], 128*1024, [Size of the auth mempool chunk.])
 AC_DEFINE([MP_CHUNK_SIZE_DNS], 64*1024, [Size of the dns mempool chunk.])
 AC_DEFINE([MP_CHUNK_SIZE_WATCH], 8*1024, [Size of the watch mempool chunk.])
-AC_DEFINE([MP_CHUNK_SIZE_NAMEHOST], 64*1024, [Size of the namehost mempool chunk.])
 AC_DEFINE([MP_CHUNK_SIZE_USERHOST], 128*1024, [Size of the userhost mempool chunk.])
 AC_DEFINE([MP_CHUNK_SIZE_IP_ENTRY], 128*1024, [Size of the ip_entry mempool chunk.])
 AC_DEFINE([MP_CHUNK_SIZE_INVITE], 8*1024, [Size of the invite mempool chunk.])
index bafa488e3115870109fe5fba77c66bab17cc9a22..86003b30701e0c334f0023be398273572bc8b9d0 100644 (file)
@@ -50,7 +50,6 @@ struct ClassItem
   unsigned int max_total;
   unsigned int max_local;
   unsigned int max_global;
-  unsigned int max_ident;
   unsigned int max_perip;
   unsigned int min_idle;
   unsigned int max_idle;
index 2e3f1551bfd610a40e445d4703ebefd9e1512889..a48e7e5871af74172e560d569f2574af943964e3 100644 (file)
 #ifndef INCLUDED_userhost_h
 #define INCLUDED_userhost_h
 
-struct NameHost
-{
-  dlink_node node;  /* Point to other names on this hostname */
-  char name[USERLEN + 1];
-  unsigned int icount;  /* Number of =local= identd on this name*/
-  unsigned int gcount;  /* Global user count on this name */
-  unsigned int lcount;  /* Local user count on this name */
-};
-
 struct UserHost
 {
-  dlink_list list;  /* List of names on this hostname */
   struct UserHost *next;
   char host[HOSTLEN + 1];
+  unsigned int gcount; /* Global user count on this addr */
+  unsigned int lcount; /* Local user count on this addr */
 };
 
-extern void count_user_host(const char *, const char *, unsigned int *, unsigned int *, unsigned int *);
-extern void add_user_host(const char *, const char *, int);
-extern void delete_user_host(const char *, const char *, int);
+extern void count_user_host(const char *, unsigned int *, unsigned int *);
+extern void add_user_host(const char *, int);
+extern void delete_user_host(const char *, int);
 #endif  /* INCLUDED_userhost_h */
index 0c02aa321faaec3f48f197bcfdc70adf6d2a2510..5f13c6ed5f70d8e3e277316b7be014c069bb5df0 100644 (file)
@@ -146,7 +146,7 @@ me_chgrealhost(struct Client *client_p, struct Client *source_p, int parc, char
 
   if (IsUserHostIp(target_p))
   {
-    delete_user_host(target_p->username, target_p->realhost, !MyConnect(target_p));
+    delete_user_host(target_p->realhost, !MyConnect(target_p));
     ClearUserHost(target_p);
     was_userhost = 1;
   }
@@ -186,7 +186,7 @@ me_chgrealhost(struct Client *client_p, struct Client *source_p, int parc, char
 
     if (was_userhost)
     {
-      add_user_host(target_p->username, target_p->realhost, !MyConnect(target_p));
+      add_user_host(target_p->realhost, !MyConnect(target_p));
       SetUserHost(target_p);
     }
   }
index 7d23d7ab7ec3e07aaec0797513bdbf1d334f437f..9195e037652c5d8bc5b51427017de37c9c1d0e44 100644 (file)
@@ -815,7 +815,7 @@ exit_one_client(struct Client *source_p, const char *quitmsg)
     hash_del_client(source_p);
 
   if (IsUserHostIp(source_p))
-    delete_user_host(source_p->username, source_p->realhost, !MyConnect(source_p));
+    delete_user_host(source_p->realhost, !MyConnect(source_p));
 
   /* remove from global client list
    * NOTE: source_p->node.next cannot be NULL if the client is added
index a8577c350f7315d53a619b92feb083edd5db7476..d8d5df5e4a3d960c7a82757ed8d71fb6565fa070 100644 (file)
@@ -466,7 +466,7 @@ attach_iline(struct Client *client_p, struct MaskItem *conf)
   struct ClassItem *class = NULL;
   struct ip_entry *ip_found;
   int a_limit_reached = 0;
-  unsigned int local = 0, global = 0, ident = 0;
+  unsigned int local = 0, global = 0;
 
   assert(conf->class);
 
@@ -476,8 +476,7 @@ attach_iline(struct Client *client_p, struct MaskItem *conf)
 
   class = conf->class;
 
-  count_user_host(client_p->username, client_p->realhost,
-                  &global, &local, &ident);
+  count_user_host(client_p->realhost, &global, &local);
 
   /* XXX blah. go down checking the various silly limits
    * setting a_limit_reached if any limit is reached.
@@ -487,13 +486,10 @@ attach_iline(struct Client *client_p, struct MaskItem *conf)
     a_limit_reached = 1;
   else if (class->max_perip != 0 && ip_found->count > class->max_perip)
     a_limit_reached = 1;
-  else if (class->max_local != 0 && local >= class->max_local)
+  else if (class->max_local != 0 && local >= class->max_local) /* XXX: redundant */
     a_limit_reached = 1;
   else if (class->max_global != 0 && global >= class->max_global)
     a_limit_reached = 1;
-  else if (class->max_ident != 0 && ident >= class->max_ident &&
-           client_p->username[0] != '~')
-    a_limit_reached = 1;
 
   if (a_limit_reached)
   {
index bd2ebf7e73eb3d85e71637268576820e2353ad18..5984eb606e1e09a165c8028ae4e777884a9a1cb4 100644 (file)
@@ -259,7 +259,6 @@ max_chans_per_oper          { return MAX_CHANS_PER_OPER; }
 max_chans_per_user          { return MAX_CHANS_PER_USER; }
 max_clients                 { return T_MAX_CLIENTS; }
 max_global                  { return MAX_GLOBAL; }
-max_ident                   { return MAX_IDENT; }
 max_idle                    { return MAX_IDLE; }
 max_local                   { return MAX_LOCAL; }
 max_nick_changes            { return MAX_NICK_CHANGES; }
index f94c965723d03ba9e1d38f371009fbd50f9804b3..ae1e1b6c82ac6e450ec5357fa972ef0e5e8fad06 100644 (file)
@@ -105,7 +105,6 @@ static struct
     max_total,
     max_global,
     max_local,
-    max_ident,
     soft_sendq,
     flood_burst,
     flood_limit,
@@ -257,7 +256,6 @@ reset_block_state(void)
 %token  MAX_CHANS_PER_OPER
 %token  MAX_CHANS_PER_USER
 %token  MAX_GLOBAL
-%token  MAX_IDENT
 %token  MAX_IDLE
 %token  MAX_LOCAL
 %token  MAX_NICK_CHANGES
@@ -1741,7 +1739,6 @@ class_entry: CLASS
   class->max_total = block_state.max_total.value;
   class->max_global = block_state.max_global.value;
   class->max_local = block_state.max_local.value;
-  class->max_ident = block_state.max_ident.value;
   class->soft_sendq = block_state.soft_sendq.value;
   class->flood_burst = block_state.flood_burst.value;
   class->flood_limit = block_state.flood_limit.value;
@@ -1768,20 +1765,19 @@ class_entry: CLASS
 
 class_items:    class_items class_item | class_item;
 class_item:     class_name |
-               class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
+                class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
                 class_ping_time |
-               class_number_per_cidr |
+                class_number_per_cidr |
                 class_number_per_ip |
                 class_connectfreq |
                 class_max_number |
-               class_max_global |
-               class_max_local |
-               class_max_ident |
+                class_max_global |
+                class_max_local |
                 class_soft_sendq | class_flood_burst | class_flood_limit | class_sendq | class_recvq |
                 class_min_idle |
                 class_max_idle |
                 class_flags |
-               error ';' ;
+                error ';' ;
 
 class_name: NAME '=' QSTRING ';'
 {
@@ -1825,12 +1821,6 @@ class_max_local: MAX_LOCAL '=' NUMBER ';'
     block_state.max_local.value = $3;
 };
 
-class_max_ident: MAX_IDENT '=' NUMBER ';'
-{
-  if (conf_parser_ctx.pass == 1)
-    block_state.max_ident.value = $3;
-};
-
 class_soft_sendq: SOFT_SENDQ '=' sizespec ';'
 {
   if (conf_parser_ctx.pass == 1)
index ae4d844faf708fad52d3381943bc3891986c27d4..92a3f3131989dac7b363e4a7870d6b9c9faa83d8 100644 (file)
@@ -46,7 +46,6 @@
 
 
 static mp_pool_t *userhost_pool = NULL;
-static mp_pool_t *namehost_pool = NULL;
 
 static unsigned int hashf_xor_key = 0;
 
@@ -72,7 +71,6 @@ void
 hash_init(void)
 {
   userhost_pool = mp_pool_new("userhost", sizeof(struct UserHost), MP_CHUNK_SIZE_USERHOST);
-  namehost_pool = mp_pool_new("namehost", sizeof(struct NameHost), MP_CHUNK_SIZE_NAMEHOST);
 
   hashf_xor_key = genrand_int32();
 }
@@ -504,41 +502,25 @@ hash_find_userhost(const char *host)
 
 /* count_user_host()
  *
- * inputs      - user name
+ * inputs
  *             - hostname
- *             - int flag 1 if global, 0 if local
  *             - pointer to where global count should go
  *             - pointer to where local count should go
- *             - pointer to where identd count should go (local clients only)
  * output      - none
  * side effects        -
  */
 void
-count_user_host(const char *user, const char *host, unsigned int *global_p,
-                unsigned int *local_p, unsigned int *icount_p)
+count_user_host(const char *host, unsigned int *global_p, unsigned int *local_p)
 {
-  dlink_node *ptr;
-  struct UserHost *found_userhost;
-  struct NameHost *nameh;
+  struct UserHost *userhost = hash_find_userhost(host);
 
-  if ((found_userhost = hash_find_userhost(host)) == NULL)
+  if (userhost == NULL)
     return;
 
-  DLINK_FOREACH(ptr, found_userhost->list.head)
-  {
-    nameh = ptr->data;
-
-    if (!irccmp(user, nameh->name))
-    {
-      if (global_p != NULL)
-        *global_p = nameh->gcount;
-      if (local_p != NULL)
-        *local_p  = nameh->lcount;
-      if (icount_p != NULL)
-        *icount_p = nameh->icount;
-      return;
-    }
-  }
+  if (global_p != NULL)
+    *global_p = userhost->gcount;
+  if (local_p != NULL)
+    *local_p  = userhost->lcount;
 }
 
 /* find_or_add_userhost()
@@ -550,9 +532,9 @@ count_user_host(const char *user, const char *host, unsigned int *global_p,
 static struct UserHost *
 find_or_add_userhost(const char *host)
 {
-  struct UserHost *userhost;
+  struct UserHost *userhost = hash_find_userhost(host);
 
-  if ((userhost = hash_find_userhost(host)) != NULL)
+  if (userhost != NULL)
     return userhost;
 
   userhost = mp_pool_get(userhost_pool);
@@ -566,119 +548,55 @@ find_or_add_userhost(const char *host)
 
 /* add_user_host()
  *
- * inputs      - user name
+ * inputs
  *             - hostname
  *             - int flag 1 if global, 0 if local
  * output      - none
  * side effects        - add given user@host to hash tables
  */
 void
-add_user_host(const char *user, const char *host, int global)
+add_user_host(const char *host, int global)
 {
-  dlink_node *ptr;
-  struct UserHost *found_userhost;
-  struct NameHost *nameh;
-  int hasident = 1;
-
-  if (*user == '~')
-  {
-    hasident = 0;
-    ++user;
-  }
+  struct UserHost *userhost = find_or_add_userhost(host);
 
-  if ((found_userhost = find_or_add_userhost(host)) == NULL)
+  if (userhost == NULL)
     return;
 
-  DLINK_FOREACH(ptr, found_userhost->list.head)
-  {
-    nameh = ptr->data;
-
-    if (!irccmp(user, nameh->name))
-    {
-      nameh->gcount++;
-
-      if (!global)
-      {
-        if (hasident)
-          nameh->icount++;
-        nameh->lcount++;
-      }
-
-      return;
-    }
-  }
-
-  nameh = mp_pool_get(namehost_pool);
-  memset(nameh, 0, sizeof(*nameh));
-  strlcpy(nameh->name, user, sizeof(nameh->name));
-
-  nameh->gcount = 1;
+  ++userhost->gcount;
 
   if (!global)
   {
-    if (hasident)
-      nameh->icount = 1;
-    nameh->lcount = 1;
+    ++userhost->lcount;
   }
-
-  dlinkAdd(nameh, &nameh->node, &found_userhost->list);
 }
 
 /* delete_user_host()
  *
- * inputs      - user name
+ * inputs
  *             - hostname
  *             - int flag 1 if global, 0 if local
  * output      - none
  * side effects        - delete given user@host to hash tables
  */
 void
-delete_user_host(const char *user, const char *host, int global)
+delete_user_host(const char *host, int global)
 {
-  dlink_node *ptr = NULL, *next_ptr = NULL;
-  struct UserHost *found_userhost;
-  struct NameHost *nameh;
-  int hasident = 1;
-
-  if (*user == '~')
-  {
-    hasident = 0;
-    ++user;
-  }
+  struct UserHost *userhost = hash_find_userhost(host);
 
-  if ((found_userhost = hash_find_userhost(host)) == NULL)
+  if (userhost == NULL)
     return;
 
-  DLINK_FOREACH_SAFE(ptr, next_ptr, found_userhost->list.head)
-  {
-    nameh = ptr->data;
+  if (userhost->gcount > 0)
+    --userhost->gcount;
 
-    if (!irccmp(user, nameh->name))
-    {
-      if (nameh->gcount > 0)
-        nameh->gcount--;
-      if (!global)
-      {
-        if (nameh->lcount > 0)
-          nameh->lcount--;
-        if (hasident && nameh->icount > 0)
-          nameh->icount--;
-      }
-
-      if (nameh->gcount == 0 && nameh->lcount == 0)
-      {
-        dlinkDelete(&nameh->node, &found_userhost->list);
-        mp_pool_release(nameh);
-      }
-
-      if (dlink_list_length(&found_userhost->list) == 0)
-      {
-        hash_del_userhost(found_userhost);
-        mp_pool_release(found_userhost);
-      }
+  if (!global)
+    if (userhost->lcount > 0)
+      --userhost->lcount;
 
-      return;
-    }
+  if (userhost->gcount == 0 && userhost->lcount == 0)
+  {
+    hash_del_userhost(userhost);
+    mp_pool_release(userhost);
   }
 }
 
index 8ebdee7da0cbb88162d8998f433a84f0a3e1cff4..c1c712fb290e34e41b7340706b40e4571d0c7e9a 100644 (file)
@@ -527,7 +527,7 @@ register_local_user(struct Client *source_p)
   user_welcome(source_p);
 
   assert(!IsUserHostIp(source_p));
-  add_user_host(source_p->username, source_p->realhost, 0);
+  add_user_host(source_p->realhost, 0);
   SetUserHost(source_p);
 
   introduce_client(source_p);
@@ -611,7 +611,7 @@ register_remote_user(struct Client *source_p,
   dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
 
   assert(!IsUserHostIp(source_p));
-  add_user_host(source_p->username, source_p->realhost, 1);
+  add_user_host(source_p->realhost, 1);
   SetUserHost(source_p);
 
   if(ConfigFileEntry.enable_cloak_system && !IsIPSpoof(source_p))
index 1b9fb843825f65c4e3ffaa7b5fd318ac85f865a5..564dfb0b05fe17fe5a452ae0d4312cb619224208 100644 (file)
@@ -469,7 +469,7 @@ unserialize_client(json_t *client, int migrate)
     hash_add_client(client_p);
     hash_add_id(client_p);
 
-    add_user_host(client_p->username, client_p->realhost, MyClient(client_p) ? 0 : 1);
+    add_user_host(client_p->realhost, MyClient(client_p) ? 0 : 1);
 
     if (MyClient(client_p))
     {