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

Use proper HOOK_* return types in HOOKTYPE_PRE_LOCAL_CONNECT, fixes crashes.

This commit is contained in:
Bram Matthys
2019-10-05 15:19:40 +02:00
parent 9a8fd43873
commit b3947c7a14
3 changed files with 28 additions and 26 deletions
+15 -14
View File
@@ -953,24 +953,25 @@ int antirandom_preconnect(Client *client)
{
int score;
if (!is_exempt(client))
if (is_exempt(client))
return HOOK_CONTINUE;
score = get_spam_score(client);
if (score > cfg.threshold)
{
score = get_spam_score(client);
if (score > cfg.threshold)
if (cfg.ban_action == BAN_ACT_WARN)
{
if (cfg.ban_action == BAN_ACT_WARN)
{
sendto_ops_and_log("[antirandom] would have denied access to user with score %d: %s!%s@%s:%s",
score, client->name, client->user->username, client->user->realhost, client->info);
return 0;
}
if (cfg.show_failedconnects)
sendto_ops_and_log("[antirandom] denied access to user with score %d: %s!%s@%s:%s",
score, client->name, client->user->username, client->user->realhost, client->info);
return place_host_ban(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time);
sendto_ops_and_log("[antirandom] would have denied access to user with score %d: %s!%s@%s:%s",
score, client->name, client->user->username, client->user->realhost, client->info);
return HOOK_CONTINUE;
}
if (cfg.show_failedconnects)
sendto_ops_and_log("[antirandom] denied access to user with score %d: %s!%s@%s:%s",
score, client->name, client->user->username, client->user->realhost, client->info);
place_host_ban(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time);
return HOOK_DENY;
}
return 0;
return HOOK_CONTINUE;
}
static void free_stuff(void)
+6 -5
View File
@@ -719,11 +719,11 @@ int blacklist_parse_reply(struct hostent *he, int entry)
* from blacklist_preconnect() for softbans that need to be delayed
* as to give the user the opportunity to do SASL Authentication.
*/
int blacklist_action(Client *client, char *opernotice, BanAction ban_action, char *ban_reason, long ban_time)
void blacklist_action(Client *client, char *opernotice, BanAction ban_action, char *ban_reason, long ban_time)
{
sendto_snomask(SNO_BLACKLIST, "%s", opernotice);
ircd_log(LOG_KILL, "%s", opernotice);
return place_host_ban(client, ban_action, ban_reason, ban_time);
place_host_ban(client, ban_action, ban_reason, ban_time);
}
void blacklist_hit(Client *client, Blacklist *bl, int reply)
@@ -827,11 +827,12 @@ int blacklist_preconnect(Client *client)
BLUser *blu = BLUSER(client);
if (!blu || !blu->save_action)
return 0;
return HOOK_CONTINUE;
/* There was a pending softban... has the user authenticated via SASL by now? */
if (IsLoggedIn(client))
return 0; /* yup, so the softban does not apply. */
return HOOK_CONTINUE; /* yup, so the softban does not apply. */
return blacklist_action(client, blu->save_opernotice, blu->save_action, blu->save_reason, blu->save_tkltime);
blacklist_action(client, blu->save_opernotice, blu->save_action, blu->save_reason, blu->save_tkltime);
return HOOK_DENY;
}
+7 -7
View File
@@ -384,25 +384,25 @@ int ct_pre_lconnect(Client *client)
int score;
if (me.local->firsttime + cfg.start_delay > TStime())
return 0; /* no throttle: start delay */
return HOOK_CONTINUE; /* no throttle: start delay */
if (ucounter->disabled)
return 0; /* protection disabled: allow user */
return HOOK_CONTINUE; /* protection disabled: allow user */
if (still_reputation_gathering())
return 0; /* still gathering reputation data */
return HOOK_CONTINUE; /* still gathering reputation data */
if (cfg.sasl_bypass && IsLoggedIn(client))
{
/* Allowed in: user authenticated using SASL */
return 0;
return HOOK_CONTINUE;
}
score = GetReputation(client);
if (score >= cfg.minimum_reputation_score)
{
/* Allowed in: IP has enough reputation ("known user") */
return 0;
return HOOK_CONTINUE;
}
/* If we reach this then the user is NEW */
@@ -429,10 +429,10 @@ int ct_pre_lconnect(Client *client)
ucounter->throttling_banner_displayed = 1;
}
exit_client(client, NULL, cfg.reason);
return -1;
return HOOK_DENY;
}
return 0;
return HOOK_CONTINUE;
}
/** Increase the connect counter(s), nothing else. */