gods

a simple blocklist for ssh
Log | Files | Refs | README | LICENSE

commit b994f7efa9c60d5152661c090d2a7cb75a4c970d
parent 32c35de205805b3d672e6fed31c7f733d9cec75c
Author: Naveen Narayanan <zerous@nocebo.space>
Date:   Sat, 23 Oct 2021 11:50:13 +0200

Set last to a max value post fw_unblock()

Setting attacker->last to a max value like LLONG_MAX is intended to
obviate unban() from trying to use fw_unblock() on attackers who have
already been unbanned. Using a flag for this could be optimal.

Diffstat:
Mmain.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c @@ -3,6 +3,7 @@ #include <err.h> #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -42,13 +43,15 @@ unban(struct attacker *a, struct lhead *headp) struct attacker *ap; if (a) { - fw_unblock(a->ip); + if (fw_unblock(a->ip)) + a->last = LLONG_MAX; return; } SLIST_FOREACH(ap, headp, attackers) if (ap->list == GREY && isexpire(ap)) - fw_unblock(ap->ip); + if (fw_unblock(ap->ip)) + ap->last = LLONG_MAX; } void