commit 6951360748af18a62b6c743a132091fe8391fca0
parent ff798e2c79d66286b71d3e2c130e6c7693e10151
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Sun, 10 Oct 2021 00:07:04 +0200
Add support for blacklist and whitelist
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
@@ -1,3 +1,5 @@
+#include <sys/stat.h>
+
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -14,6 +16,9 @@
#define BUFSZ 512
+int fd_black;
+int fd_white;
+
static char buf[BUFSZ];
SLIST_HEAD(lhead, attacker) head = SLIST_HEAD_INITIALIZER(head);
@@ -90,13 +95,22 @@ main(int argc, char **argv)
if (fd == -1)
err(1, "open failed: %s", sshlog);
+ fd_black = open(black_list, O_RDWR | O_CREAT | O_APPEND,
+ S_IRUSR | S_IWUSR);
+ if (fd_black == -1)
+ err(1, "open failed: %s", black_list);
+
+ fd_white = open(white_list, O_RDWR | O_CREAT | O_APPEND,
+ S_IRUSR | S_IWUSR);
+ if (fd_white == -1)
+ err(1, "open failed: %s", white_list);
+
for ( ; ; ) {
while ((line = readline(fd)) == NULL) {
usleep(500000);
continue;
}
-
if (parse(line) == -1) {
fprintf(stderr, "parse failed\n");
continue;