1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 06:03:12 +02:00

Some more BanAction fixes/improvements:

* stats S one thingy (multi-actions)
* STATS spamfilter (multi-actions)
* warn w/user target ('u') if using multi-actions
* moving some code
This commit is contained in:
Bram Matthys
2023-07-09 16:27:40 +02:00
parent e26ff1e9cf
commit d25fdeb950
5 changed files with 21 additions and 18 deletions
+1
View File
@@ -739,6 +739,7 @@ extern void free_all_ban_actions(BanAction *actions);
#define safe_free_all_ban_actions(x) do { free_all_ban_actions(x); x = NULL; } while(0)
#define safe_free_single_ban_action(x) do { free_single_ban_action(x); x = NULL; } while(0)
BanAction *duplicate_ban_actions(BanAction *actions);
extern int highest_spamfilter_action(BanAction *action);
extern BanActionValue banact_stringtoval(const char *s);
extern const char *banact_valtostring(BanActionValue val);
extern BanActionValue banact_chartoval(char c);
+12
View File
@@ -1094,6 +1094,18 @@ const char *ban_actions_to_string(BanAction *actions)
return buf;
}
/* Find the highest value in a BanAction linked list (the strongest action, eg gline>block) */
int highest_spamfilter_action(BanAction *action)
{
int highest = 0;
for (; action; action = action->next)
if (action->action > highest)
highest = action->action;
return highest;
}
void free_single_ban_action(BanAction *action)
{
safe_free(action->var);
+1 -1
View File
@@ -876,7 +876,7 @@ int blacklist_preconnect(Client *client)
return HOOK_CONTINUE; /* yup, so the softban does not apply. */
if (blacklist_action(client, blu->save_opernotice, blu->save_action, blu->save_reason, blu->save_tkltime,
blu->save_blacklist, blu->save_blacklist_dns_name, blu->save_blacklist_dns_reply))
blu->save_blacklist, blu->save_blacklist_dns_name, blu->save_blacklist_dns_reply) > 0)
{
return HOOK_DENY;
}
+1 -1
View File
@@ -868,7 +868,7 @@ int stats_set(Client *client, const char *para)
sendtxtnumeric(client, "link::bind-ip: %s", LINK_BINDIP);
sendtxtnumeric(client, "anti-flood::connect-flood: %d per %s", THROTTLING_COUNT, pretty_time_val(THROTTLING_PERIOD));
sendtxtnumeric(client, "anti-flood::handshake-data-flood::amount: %ld bytes", iConf.handshake_data_flood_amount);
sendtxtnumeric(client, "anti-flood::handshake-data-flood::ban-action: %s", banact_valtostring(iConf.handshake_data_flood_ban_action->action));
sendtxtnumeric(client, "anti-flood::handshake-data-flood::ban-action: %s", ban_actions_to_string(iConf.handshake_data_flood_ban_action));
sendtxtnumeric(client, "anti-flood::handshake-data-flood::ban-time: %s", pretty_time_val(iConf.handshake_data_flood_ban_time));
/* set::anti-flood */
+6 -16
View File
@@ -3756,7 +3756,7 @@ int tkl_stats_matcher(Client *client, int type, const char *para, TKLFlag *tklfl
(tkl->type & TKL_GLOBAL) ? 'F' : 'f',
unreal_match_method_valtostr(tkl->ptr.spamfilter->match->type),
spamfilter_target_inttostring(tkl->ptr.spamfilter->target),
banact_valtostring(tkl->ptr.spamfilter->action->action),
ban_actions_to_string(tkl->ptr.spamfilter->action),
(tkl->expire_at != 0) ? (long long)(tkl->expire_at - TStime()) : 0,
(long long)(TStime() - tkl->set_at),
(long long)tkl->ptr.spamfilter->tkl_duration,
@@ -4183,8 +4183,12 @@ void _tkl_added(Client *client, TKL *tkl)
sendnotice_tkl_add(tkl);
/* spamfilter 'warn' action is special */
if ((tkl->type & TKL_SPAMF) && (tkl->ptr.spamfilter->action->action == BAN_ACT_WARN) && (tkl->ptr.spamfilter->target & SPAMF_USER))
if ((tkl->type & TKL_SPAMF) &&
has_actions_of_type(tkl->ptr.spamfilter->action, BAN_ACT_WARN) &&
(tkl->ptr.spamfilter->target & SPAMF_USER))
{
spamfilter_check_users(tkl);
}
/* Ban checking executes during run loop for efficiency */
loop.do_bancheck = 1;
@@ -4761,10 +4765,8 @@ void ban_act_set(Client *client, BanAction *action)
void ban_action_run_all_sets(Client *client, BanAction *action)
{
for (; action; action = action->next)
{
if (action->action == BAN_ACT_SET)
ban_act_set(client, action);
}
}
/** Take an action on the user, such as banning or killing.
@@ -4899,18 +4901,6 @@ int _take_action(Client *client, BanAction *actions, char *reason, long duration
return highest;
}
/* Find the highest value in a BanAction linked list (the strongest action, eg gline>block) */
int highest_spamfilter_action(BanAction *action)
{
int highest = 0;
for (; action; action = action->next)
if (action->action > highest)
highest = action->action;
return highest;
}
/** This function compares two spamfilters ('one' and 'two') and will return
* a 'winner' based on which one has the strongest action.
* If both have equal action then some additional logic is applied simply