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.])
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;
#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 */
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;
}
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);
}
}
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
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);
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.
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)
{
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; }
max_total,
max_global,
max_local,
- max_ident,
soft_sendq,
flood_burst,
flood_limit,
%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
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;
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 ';'
{
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)
static mp_pool_t *userhost_pool = NULL;
-static mp_pool_t *namehost_pool = NULL;
static unsigned int hashf_xor_key = 0;
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();
}
/* 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()
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);
/* 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);
}
}
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);
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))
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))
{