gods

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

commit 278996e4b98821cf9c2ea5b19b5253a247e3c7cf
parent bcd3166a6491165d079b26831bf585570b10e587
Author: Naveen Narayanan <zerous@nocebo.space>
Date:   Mon, 27 Sep 2021 21:50:55 +0200

Implement ban() and unban()

Diffstat:
Mmain.c | 28+++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -2,11 +2,37 @@ #include <stdio.h> #include <string.h> -#include "param.h" +#include "attack.h" +#include "fw.h" +#include "queue.h" #define BUFSZ 512 char buf[BUFSZ]; +void +ban(struct attacker *a) +{ + printf("ban\n"); + a->nban++; + if (a->nban > 8) + blacklist(a); + fw_block(a->ip); +} + +void +unban(struct attacker *a, struct lhead *headp) +{ + struct attacker *ap; + + if (a) { + fw_unblock(a->ip); + return; + } + + SLIST_FOREACH(ap, headp, attackers) + if (isexpire(ap)) + fw_unblock(ap->ip); +} int main(int argc, char **argv)