diff --git a/ChangeLog b/ChangeLog index c1b8f746..5c045bd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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) diff --git a/include/exclude.h b/include/exclude.h index d3f38e35..48122a91 100644 --- a/include/exclude.h +++ b/include/exclude.h @@ -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; diff --git a/include/neostats.h b/include/neostats.h index 16684c47..aea3cd6e 100755 --- a/include/neostats.h +++ b/include/neostats.h @@ -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; diff --git a/modules/extauth/extauth.c b/modules/extauth/extauth.c index 26513d47..053bd029 100644 --- a/modules/extauth/extauth.c +++ b/modules/extauth/extauth.c @@ -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; diff --git a/src/exclude.c b/src/exclude.c index fc824cb9..4f5ec083 100644 --- a/src/exclude.c +++ b/src/exclude.c @@ -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 */ diff --git a/src/ns_help.c b/src/ns_help.c index 195801e4..ba0922f8 100644 --- a/src/ns_help.c +++ b/src/ns_help.c @@ -71,7 +71,7 @@ const char *ns_help_jupe[] = { }; const char *ns_help_exclude[] = { - "Syntax: \2EXCLUDE ADD \2", + "Syntax: \2EXCLUDE ADD \2", " \2EXCLUDE DEL \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.", - " is the host, server or channel name and may include", - "wildcards such as * and ?.", + " is the userhost mask, host, server or channel name and", + "may include wildcards such as * and ?.", " is the reason for the exclusion", "", "\2DEL\2 Delete an entry from the exclusion list.",