Refactor clear_out_address_conf*
This commit is contained in:
parent
35eccf4930
commit
625cbb195b
4 changed files with 18 additions and 41 deletions
|
@ -33,6 +33,12 @@ enum
|
||||||
HM_IPV6,
|
HM_IPV6,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum aconf_category
|
||||||
|
{
|
||||||
|
AC_CONFIG,
|
||||||
|
AC_BANDB,
|
||||||
|
};
|
||||||
|
|
||||||
int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
|
int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
|
||||||
int parse_netmask_strict(const char *, struct rb_sockaddr_storage *, int *);
|
int parse_netmask_strict(const char *, struct rb_sockaddr_storage *, int *);
|
||||||
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
|
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
|
||||||
|
@ -42,8 +48,7 @@ struct ConfItem *find_exact_conf_by_address(const char *address, int type,
|
||||||
const char *username);
|
const char *username);
|
||||||
void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
|
void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
|
||||||
void delete_one_address_conf(const char *, struct ConfItem *);
|
void delete_one_address_conf(const char *, struct ConfItem *);
|
||||||
void clear_out_address_conf(void);
|
void clear_out_address_conf(enum aconf_category);
|
||||||
void clear_out_address_conf_bans(void);
|
|
||||||
void init_host_hash(void);
|
void init_host_hash(void);
|
||||||
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
|
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
|
||||||
const char *, const char *, struct sockaddr *,
|
const char *, const char *, struct sockaddr *,
|
||||||
|
|
|
@ -327,7 +327,7 @@ bandb_handle_finish(void)
|
||||||
struct ConfItem *aconf;
|
struct ConfItem *aconf;
|
||||||
rb_dlink_node *ptr, *next_ptr;
|
rb_dlink_node *ptr, *next_ptr;
|
||||||
|
|
||||||
clear_out_address_conf_bans();
|
clear_out_address_conf(AC_BANDB);
|
||||||
clear_s_newconf_bans();
|
clear_s_newconf_bans();
|
||||||
|
|
||||||
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, bandb_pending.head)
|
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, bandb_pending.head)
|
||||||
|
|
|
@ -631,7 +631,7 @@ delete_one_address_conf(const char *address, struct ConfItem *aconf)
|
||||||
* them, otherwise sets them as illegal.
|
* them, otherwise sets them as illegal.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clear_out_address_conf(void)
|
clear_out_address_conf(enum aconf_category clear_type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct AddressRec **store_next;
|
struct AddressRec **store_next;
|
||||||
|
@ -642,11 +642,17 @@ clear_out_address_conf(void)
|
||||||
store_next = &atable[i];
|
store_next = &atable[i];
|
||||||
for (arec = atable[i]; arec; arec = arecn)
|
for (arec = atable[i]; arec; arec = arecn)
|
||||||
{
|
{
|
||||||
|
enum aconf_category cur_type;
|
||||||
arecn = arec->next;
|
arecn = arec->next;
|
||||||
|
|
||||||
|
if (arec->type == CONF_CLIENT || arec->type == CONF_EXEMPTDLINE || arec->type == CONF_SECURE)
|
||||||
|
cur_type = AC_CONFIG;
|
||||||
|
else
|
||||||
|
cur_type = AC_BANDB;
|
||||||
|
|
||||||
/* We keep the temporary K-lines and destroy the
|
/* We keep the temporary K-lines and destroy the
|
||||||
* permanent ones, just to be confusing :) -A1kmm */
|
* permanent ones, just to be confusing :) -A1kmm */
|
||||||
if(arec->aconf->flags & CONF_FLAGS_TEMPORARY ||
|
if (arec->aconf->flags & CONF_FLAGS_TEMPORARY || cur_type != clear_type)
|
||||||
(arec->type != CONF_CLIENT && arec->type != CONF_EXEMPTDLINE && arec->type != CONF_SECURE))
|
|
||||||
{
|
{
|
||||||
*store_next = arec;
|
*store_next = arec;
|
||||||
store_next = &arec->next;
|
store_next = &arec->next;
|
||||||
|
@ -663,40 +669,6 @@ clear_out_address_conf(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
clear_out_address_conf_bans(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct AddressRec **store_next;
|
|
||||||
struct AddressRec *arec, *arecn;
|
|
||||||
|
|
||||||
for (i = 0; i < ATABLE_SIZE; i++)
|
|
||||||
{
|
|
||||||
store_next = &atable[i];
|
|
||||||
for (arec = atable[i]; arec; arec = arecn)
|
|
||||||
{
|
|
||||||
arecn = arec->next;
|
|
||||||
/* We keep the temporary K-lines and destroy the
|
|
||||||
* permanent ones, just to be confusing :) -A1kmm */
|
|
||||||
if(arec->aconf->flags & CONF_FLAGS_TEMPORARY ||
|
|
||||||
(arec->type == CONF_CLIENT || arec->type == CONF_EXEMPTDLINE || arec->type == CONF_SECURE))
|
|
||||||
{
|
|
||||||
*store_next = arec;
|
|
||||||
store_next = &arec->next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
arec->aconf->status |= CONF_ILLEGAL;
|
|
||||||
if(!arec->aconf->clients)
|
|
||||||
free_conf(arec->aconf);
|
|
||||||
rb_free(arec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*store_next = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* show_iline_prefix()
|
* show_iline_prefix()
|
||||||
*
|
*
|
||||||
|
|
|
@ -1491,7 +1491,7 @@ clear_out_old_conf(void)
|
||||||
MaxUsers(cltmp) = -1;
|
MaxUsers(cltmp) = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_out_address_conf();
|
clear_out_address_conf(AC_CONFIG);
|
||||||
clear_s_newconf();
|
clear_s_newconf();
|
||||||
|
|
||||||
/* clean out module paths */
|
/* clean out module paths */
|
||||||
|
|
Loading…
Reference in a new issue