1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-05 21:13:12 +02:00

Rename place_host_ban() to take_action() since it is not only about banning...

This commit is contained in:
Bram Matthys
2023-07-08 19:54:40 +02:00
parent 8f4a19978a
commit 5d65e4a400
11 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -840,7 +840,7 @@ extern MODVAR TKL *(*find_tkline_match_zap)(Client *cptr);
extern MODVAR void (*tkl_stats)(Client *cptr, int type, const char *para, int *cnt);
extern MODVAR void (*tkl_sync)(Client *client);
extern MODVAR void (*cmd_tkl)(Client *client, MessageTag *recv_mtags, int parc, const char *parv[]);
extern MODVAR int (*place_host_ban)(Client *client, BanAction *actions, const char *reason, long duration, int skip_set);
extern MODVAR int (*take_action)(Client *client, BanAction *actions, const char *reason, long duration, int skip_set);
extern MODVAR int (*match_spamfilter)(Client *client, const char *str_in, int type, const char *cmd, const char *target, int flags, TKL **rettk);
extern MODVAR int (*match_spamfilter_mtags)(Client *client, MessageTag *mtags, const char *cmd);
extern MODVAR int (*join_viruschan)(Client *client, TKL *tk, int type);
+7 -7
View File
@@ -1203,8 +1203,8 @@ extern void SavePersistentLongLongX(ModuleInfo *modinfo, const char *varshortnam
#define HOOKTYPE_SASL_CONTINUATION 91
/** See hooktype_sasl_result() */
#define HOOKTYPE_SASL_RESULT 92
/** See hooktype_place_host_ban() */
#define HOOKTYPE_PLACE_HOST_BAN 93
/** See hooktype_take_action() */
#define HOOKTYPE_TAKE_ACTION 93
/** See hooktype_find_tkline_match() */
#define HOOKTYPE_FIND_TKLINE_MATCH 94
/** See hooktype_welcome() */
@@ -2095,7 +2095,7 @@ int hooktype_sasl_continuation(Client *client, const char *buf);
*/
int hooktype_sasl_result(Client *client, int success);
/** Called when a TKL ban should be added on the host (function prototype for HOOKTYPE_PLACE_HOST_BAN).
/** Called when a TKL ban should be added on the host (function prototype for HOOKTYPE_TAKE_ACTION).
* This is called for automated bans such as spamfilter hits, flooding, etc.
* This hook can be used to prevent the ban, or as used by the authprompt to delay it.
* @param client The client that should be banned
@@ -2104,11 +2104,11 @@ int hooktype_sasl_result(Client *client, int success);
* @param duration The duration of the ban, 0 for permanent ban
* @return The magic value 99 is used to exempt the user (=do not ban!), otherwise the ban is added.
*/
int hooktype_place_host_ban(Client *client, BanActionValue action, const char *reason, long duration);
int hooktype_take_action(Client *client, BanActionValue action, const char *reason, long duration);
/** Called when a TKL ban is hit by this user (function prototype for HOOKTYPE_FIND_TKLINE_MATCH).
* This is called when an existing TKL entry is hit by the user.
* To prevent an automated ban to be added on a host/ip, see hooktype_place_host_ban().
* To prevent an automated ban to be added on a host/ip, see hooktype_take_action().
* @param client The client
* @param tkl The TKL entry
* @return The magic value 99 is used to exempt the user (=do not kill!), otherwise the ban is executed.
@@ -2431,7 +2431,7 @@ _UNREAL_ERROR(_hook_error_incompatible, "Incompatible hook function. Check argum
((hooktype == HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION) && !ValidateHook(hooktype_can_bypass_channel_message_restriction, func)) || \
((hooktype == HOOKTYPE_SASL_CONTINUATION) && !ValidateHook(hooktype_sasl_continuation, func)) || \
((hooktype == HOOKTYPE_SASL_RESULT) && !ValidateHook(hooktype_sasl_result, func)) || \
((hooktype == HOOKTYPE_PLACE_HOST_BAN) && !ValidateHook(hooktype_place_host_ban, func)) || \
((hooktype == HOOKTYPE_TAKE_ACTION) && !ValidateHook(hooktype_take_action, func)) || \
((hooktype == HOOKTYPE_FIND_TKLINE_MATCH) && !ValidateHook(hooktype_find_tkline_match, func)) || \
((hooktype == HOOKTYPE_WELCOME) && !ValidateHook(hooktype_welcome, func)) || \
((hooktype == HOOKTYPE_PRE_COMMAND) && !ValidateHook(hooktype_pre_command, func)) || \
@@ -2507,7 +2507,7 @@ enum EfunctionType {
EFUNC_TKL_STATS,
EFUNC_TKL_SYNCH,
EFUNC_CMD_TKL,
EFUNC_PLACE_HOST_BAN,
EFUNC_TAKE_ACTION,
EFUNC_MATCH_SPAMFILTER,
EFUNC_MATCH_SPAMFILTER_MTAGS,
EFUNC_JOIN_VIRUSCHAN,
+1 -1
View File
@@ -1171,7 +1171,7 @@ typedef enum BanActionValue {
BAN_ACT_BLOCK = 200,
BAN_ACT_SOFT_BLOCK = 150,
BAN_ACT_WARN = 100,
// do not use 99, it is special in tkl place_host_ban
// do not use 99, it is special in tkl take_action
BAN_ACT_SOFT_WARN = 50,
BAN_ACT_REPORT = 40,
BAN_ACT_SET = 30,
+2 -2
View File
@@ -74,7 +74,7 @@ TKL *(*find_tkline_match_zap)(Client *client);
void (*tkl_stats)(Client *client, int type, const char *para, int *cnt);
void (*tkl_sync)(Client *client);
void (*cmd_tkl)(Client *client, MessageTag *mtags, int parc, const char *parv[]);
int (*place_host_ban)(Client *client, BanAction *action, const char *reason, long duration, int skip_set);
int (*take_action)(Client *client, BanAction *action, const char *reason, long duration, int skip_set);
int (*match_spamfilter)(Client *client, const char *str_in, int type, const char *cmd, const char *target, int flags, TKL **rettk);
int (*match_spamfilter_mtags)(Client *client, MessageTag *mtags, const char *cmd);
int (*join_viruschan)(Client *client, TKL *tk, int type);
@@ -362,7 +362,7 @@ void efunctions_init(void)
efunc_init_function(EFUNC_TKL_STATS, tkl_stats, NULL);
efunc_init_function(EFUNC_TKL_SYNCH, tkl_sync, NULL);
efunc_init_function(EFUNC_CMD_TKL, cmd_tkl, NULL);
efunc_init_function(EFUNC_PLACE_HOST_BAN, place_host_ban, NULL);
efunc_init_function(EFUNC_TAKE_ACTION, take_action, NULL);
efunc_init_function(EFUNC_MATCH_SPAMFILTER, match_spamfilter, NULL);
efunc_init_function(EFUNC_MATCH_SPAMFILTER_MTAGS, match_spamfilter_mtags, NULL);
efunc_init_function(EFUNC_JOIN_VIRUSCHAN, join_viruschan, NULL);
+1 -1
View File
@@ -697,7 +697,7 @@ CMD_OVERRIDE_FUNC(override_msg)
log_data_string("scripts", logbuf));
/* Take the action */
retval = place_host_ban(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time, 0);
retval = take_action(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time, 0);
if (retval == 1)
return;
if (retval == BAN_ACT_BLOCK)
+1 -1
View File
@@ -878,7 +878,7 @@ int antirandom_preconnect(Client *client)
"[antirandom] denied access to user with score $score: $client.details:$client.user.realname",
log_data_integer("score", score));
}
if (place_host_ban(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time, 0))
if (take_action(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time, 0))
return HOOK_DENY;
}
return HOOK_CONTINUE;
+3 -3
View File
@@ -54,7 +54,7 @@ int authprompt_config_test(ConfigFile *, ConfigEntry *, int, int *);
int authprompt_config_run(ConfigFile *, ConfigEntry *, int);
int authprompt_sasl_continuation(Client *client, const char *buf);
int authprompt_sasl_result(Client *client, int success);
int authprompt_place_host_ban(Client *client, BanActionValue action, const char *reason, long duration);
int authprompt_take_action(Client *client, BanActionValue action, const char *reason, long duration);
int authprompt_find_tkline_match(Client *client, TKL *tk);
int authprompt_pre_local_handshake_timeout(Client *client, const char **comment);
int authprompt_pre_connect(Client *client);
@@ -93,7 +93,7 @@ MOD_INIT()
HookAdd(modinfo->handle, HOOKTYPE_CONFIGRUN, 0, authprompt_config_run);
HookAdd(modinfo->handle, HOOKTYPE_SASL_CONTINUATION, 0, authprompt_sasl_continuation);
HookAdd(modinfo->handle, HOOKTYPE_SASL_RESULT, 0, authprompt_sasl_result);
HookAdd(modinfo->handle, HOOKTYPE_PLACE_HOST_BAN, 0, authprompt_place_host_ban);
HookAdd(modinfo->handle, HOOKTYPE_TAKE_ACTION, 0, authprompt_take_action);
HookAdd(modinfo->handle, HOOKTYPE_FIND_TKLINE_MATCH, 0, authprompt_find_tkline_match);
HookAdd(modinfo->handle, HOOKTYPE_PRE_LOCAL_HANDSHAKE_TIMEOUT, 0, authprompt_pre_local_handshake_timeout);
/* For HOOKTYPE_PRE_LOCAL_CONNECT we want a low priority, so we are called last.
@@ -398,7 +398,7 @@ void authprompt_send_auth_required_message(Client *client)
}
/* Called upon "place a host ban on this user" (eg: spamfilter, blacklist, ..) */
int authprompt_place_host_ban(Client *client, BanActionValue action, const char *reason, long duration)
int authprompt_take_action(Client *client, BanActionValue action, const char *reason, long duration)
{
/* If it's a soft-xx action and the user is not logged in
* and the user is not yet online, then we will handle this user.
+1 -1
View File
@@ -753,7 +753,7 @@ int blacklist_action(Client *client, char *opernotice, BanAction *ban_action, ch
log_data_string("ban_action", ban_actions_to_string(ban_action)),
log_data_string("ban_reason", ban_reason),
log_data_integer("ban_time", ban_time));
return place_host_ban(client, ban_action, ban_reason, ban_time, 0);
return take_action(client, ban_action, ban_reason, ban_time, 0);
}
void blacklist_hit(Client *client, Blacklist *bl, int reply)
+1 -1
View File
@@ -619,7 +619,7 @@ int ban_version(Client *client, const char *text)
if (find_tkl_exception(TKL_BAN_VERSION, client))
return 0; /* we are exempt */
return place_host_ban(client, ban->action, ban->reason, BAN_VERSION_TKL_TIME, 0);
return take_action(client, ban->action, ban->reason, BAN_VERSION_TKL_TIME, 0);
}
return 0;
+6 -6
View File
@@ -90,7 +90,7 @@ TKL *_find_tkline_match_zap(Client *client);
void _tkl_stats(Client *client, int type, const char *para, int *cnt);
void _tkl_sync(Client *client);
CMD_FUNC(_cmd_tkl);
int _place_host_ban(Client *client, BanAction *action, char *reason, long duration, int skip_set);
int _take_action(Client *client, BanAction *action, char *reason, long duration, int skip_set);
int _match_spamfilter(Client *client, const char *str_in, int type, const char *cmd, const char *target, int flags, TKL **rettk);
int _match_spamfilter_mtags(Client *client, MessageTag *mtags, char *cmd);
int check_mtag_spamfilters_present(void);
@@ -207,7 +207,7 @@ MOD_TEST()
EfunctionAddVoid(modinfo->handle, EFUNC_TKL_STATS, _tkl_stats);
EfunctionAddVoid(modinfo->handle, EFUNC_TKL_SYNCH, _tkl_sync);
EfunctionAddVoid(modinfo->handle, EFUNC_CMD_TKL, _cmd_tkl);
EfunctionAdd(modinfo->handle, EFUNC_PLACE_HOST_BAN, _place_host_ban);
EfunctionAdd(modinfo->handle, EFUNC_TAKE_ACTION, _take_action);
EfunctionAdd(modinfo->handle, EFUNC_MATCH_SPAMFILTER, _match_spamfilter);
EfunctionAdd(modinfo->handle, EFUNC_MATCH_SPAMFILTER_MTAGS, _match_spamfilter_mtags);
EfunctionAdd(modinfo->handle, EFUNC_JOIN_VIRUSCHAN, _join_viruschan);
@@ -4780,7 +4780,7 @@ void ban_action_run_all_sets(Client *client, BanAction *action)
* @note Be sure to check IsDead(client) if return value is 1 and you are
* considering to continue processing.
*/
int _place_host_ban(Client *client, BanAction *actions, char *reason, long duration, int skip_set)
int _take_action(Client *client, BanAction *actions, char *reason, long duration, int skip_set)
{
BanAction *action;
int previous_highest = 0;
@@ -4851,7 +4851,7 @@ int _place_host_ban(Client *client, BanAction *actions, char *reason, long durat
tkllayer[7] = mo2;
tkllayer[8] = reason;
cmd_tkl(&me, NULL, 9, tkllayer);
RunHookReturnInt(HOOKTYPE_PLACE_HOST_BAN, !=99, client, action->action, reason, duration);
RunHookReturnInt(HOOKTYPE_TAKE_ACTION, !=99, client, action->action, reason, duration);
if ((action->action == BAN_ACT_SHUN) || (action->action == BAN_ACT_SOFT_SHUN))
{
find_shun(client);
@@ -4866,7 +4866,7 @@ int _place_host_ban(Client *client, BanAction *actions, char *reason, long durat
}
case BAN_ACT_SOFT_KILL:
case BAN_ACT_KILL:
RunHookReturnInt(HOOKTYPE_PLACE_HOST_BAN, !=99, client, action->action, reason, duration);
RunHookReturnInt(HOOKTYPE_TAKE_ACTION, !=99, client, action->action, reason, duration);
exit_client(client, NULL, reason);
break;
case BAN_ACT_SOFT_TEMPSHUN:
@@ -5237,7 +5237,7 @@ int _match_spamfilter(Client *client, const char *str_in, int target, const char
/* Spamfilter matched, take action: */
reason = unreal_decodespace(tkl->ptr.spamfilter->tkl_reason);
ret = place_host_ban(client, tkl->ptr.spamfilter->action, reason, tkl->ptr.spamfilter->tkl_duration, 1);
ret = take_action(client, tkl->ptr.spamfilter->action, reason, tkl->ptr.spamfilter->tkl_duration, 1);
if (!IsDead(client))
{
if ((ret == BAN_ACT_BLOCK) || (ret == BAN_ACT_SOFT_BLOCK))
+2 -2
View File
@@ -602,8 +602,8 @@ static void ban_handshake_data_flooder(Client *client)
}
else
{
/* place_host_ban also takes care of removing any other clients with same host/ip */
place_host_ban(client, iConf.handshake_data_flood_ban_action, "Handshake data flood detected", iConf.handshake_data_flood_ban_time, 0);
/* take_action also takes care of removing any other clients with same host/ip */
take_action(client, iConf.handshake_data_flood_ban_action, "Handshake data flood detected", iConf.handshake_data_flood_ban_time, 0);
}
}