Add host mask exclude ability
This commit is contained in:
parent
79a88a0ba5
commit
bb8b2af086
6 changed files with 26 additions and 9 deletions
|
@ -4,6 +4,7 @@ Anything we add/remove/fix/change is in here (even our rants)
|
|||
Fish (F), Mark (M), DeadNotBuried (D)
|
||||
===============================================================================
|
||||
* NeoStats * Version 3.0.a3-dev
|
||||
- Add ability to exclude nick!user@host masks. (M)
|
||||
- Add nick!user@host and nick!user@vhost mask generation to core. (M)
|
||||
- DBA layer will now pass size of data fetched in FetchRows. (M)
|
||||
- Add support to ircd layer for processing ERROR messages from the uplink. (M)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
typedef struct Exclude {
|
||||
NS_EXCLUDE type;
|
||||
char pattern[MAXHOST];
|
||||
char pattern[USERHOSTLEN];
|
||||
char addedby[MAXNICK];
|
||||
char reason[MAXREASON];
|
||||
time_t addedon;
|
||||
|
|
|
@ -459,6 +459,7 @@ typedef enum NS_EXCLUDE {
|
|||
NS_EXCLUDE_HOST = 0,
|
||||
NS_EXCLUDE_SERVER,
|
||||
NS_EXCLUDE_CHANNEL,
|
||||
NS_EXCLUDE_USERHOST,
|
||||
NS_EXCLUDE_MAX,
|
||||
} NS_EXCLUDE;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ static int ea_cmd_access( CmdParams* cmdparams );
|
|||
typedef struct AccessEntry
|
||||
{
|
||||
char nick[MAXNICK];
|
||||
char mask[MAXHOST];
|
||||
char mask[USERHOSTLEN];
|
||||
int level;
|
||||
}AccessEntry;
|
||||
|
||||
|
@ -158,7 +158,7 @@ static int AccessAdd( CmdParams* cmdparams )
|
|||
}
|
||||
access = ns_calloc( sizeof( AccessEntry) );
|
||||
strlcpy( access->nick, cmdparams->av[1], MAXNICK );
|
||||
strlcpy( access->mask, cmdparams->av[2], MAXHOST );
|
||||
strlcpy( access->mask, cmdparams->av[2], USERHOSTLEN );
|
||||
access->level = level;
|
||||
hnode_create_insert( accesshash, access, access->nick );
|
||||
/* save the entry */
|
||||
|
@ -314,14 +314,14 @@ int ModFini( void)
|
|||
|
||||
int ModAuthUser( Client *u )
|
||||
{
|
||||
static char hostmask[MAXHOST];
|
||||
static char hostmask[USERHOSTLEN];
|
||||
AccessEntry *access;
|
||||
|
||||
dlog( DEBUG2, "ModAuthUser for %s", u->name );
|
||||
access =( AccessEntry *)hnode_find( accesshash, u->name );
|
||||
if( access)
|
||||
{
|
||||
ircsnprintf( hostmask, MAXHOST, "%s@%s", u->user->username, u->user->hostname );
|
||||
ircsnprintf( hostmask, USERHOSTLEN, "%s@%s", u->user->username, u->user->hostname );
|
||||
if( match( access->mask, hostmask ) )
|
||||
{
|
||||
return access->level;
|
||||
|
|
|
@ -49,6 +49,7 @@ const char* ExcludeDesc[NS_EXCLUDE_MAX] = {
|
|||
"Host",
|
||||
"Server",
|
||||
"Channel",
|
||||
"Userhost"
|
||||
};
|
||||
|
||||
bot_cmd mod_exclude_commands[]=
|
||||
|
@ -152,6 +153,12 @@ static int do_exclude_add(list_t *elist, CmdParams* cmdparams)
|
|||
return NS_SUCCESS;
|
||||
}
|
||||
type = NS_EXCLUDE_SERVER;
|
||||
} else if (!ircstrcasecmp("USERHOST", cmdparams->av[1])) {
|
||||
if (!index(cmdparams->av[2], '!') || !index(cmdparams->av[2], '@')) {
|
||||
irc_prefmsg (cmdparams->bot, cmdparams->source, "Invalid userhost mask");
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
type = NS_EXCLUDE_USERHOST;
|
||||
} else {
|
||||
irc_prefmsg (cmdparams->bot, cmdparams->source, "Invalid exclude type");
|
||||
return NS_SUCCESS;
|
||||
|
@ -315,12 +322,20 @@ void ns_do_exclude_user(Client *u)
|
|||
en = list_first(exclude_list);
|
||||
while (en != NULL) {
|
||||
e = lnode_get(en);
|
||||
if (e->type == NS_EXCLUDE_HOST) {
|
||||
if (e->type == NS_EXCLUDE_HOST)
|
||||
{
|
||||
if (match(e->pattern, u->user->hostname)) {
|
||||
u->flags |= NS_FLAG_EXCLUDED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (e->type == NS_EXCLUDE_USERHOST)
|
||||
{
|
||||
if (match(e->pattern, u->user->userhostmask)) {
|
||||
u->flags |= NS_FLAG_EXCLUDED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
en = list_next(exclude_list, en);
|
||||
}
|
||||
/* if we are here, there is no match */
|
||||
|
|
|
@ -71,7 +71,7 @@ const char *ns_help_jupe[] = {
|
|||
};
|
||||
|
||||
const char *ns_help_exclude[] = {
|
||||
"Syntax: \2EXCLUDE ADD <HOST|SERVER|CHANNEL> <pattern> <reason>\2",
|
||||
"Syntax: \2EXCLUDE ADD <HOST|SERVER|CHANNEL|USERHOST> <pattern> <reason>\2",
|
||||
" \2EXCLUDE DEL <pattern>\2",
|
||||
" \2EXCLUDE LIST\2",
|
||||
"",
|
||||
|
@ -79,8 +79,8 @@ const char *ns_help_exclude[] = {
|
|||
"users and servers from certain scans and events.",
|
||||
"",
|
||||
"\2ADD\2 Add a new exclusion to the list of the requested type.",
|
||||
"<pattern> is the host, server or channel name and may include",
|
||||
"wildcards such as * and ?.",
|
||||
"<pattern> is the userhost mask, host, server or channel name and",
|
||||
"may include wildcards such as * and ?.",
|
||||
"<reason> is the reason for the exclusion",
|
||||
"",
|
||||
"\2DEL\2 Delete an entry from the exclusion list.",
|
||||
|
|
Reference in a new issue