From 8bcf6740309f451527efdc6b9ab45434d08c3370 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Mon, 25 Jan 2021 10:44:11 +1000 Subject: [PATCH] * update jail processing for module interface changes --- src/jail.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/jail.c b/src/jail.c index e1f1211..9b85345 100644 --- a/src/jail.c +++ b/src/jail.c @@ -250,6 +250,8 @@ f2b_jail_process(f2b_jail_t *jail) { time_t expiretime = 0; bool remove = false; bool reset = true; /* source reset */ + uint32_t stag, ftag; + short int score; assert(jail != NULL); @@ -257,14 +259,18 @@ f2b_jail_process(f2b_jail_t *jail) { f2b_backend_ping(jail->backend); - while (f2b_source_next(jail->source, line, sizeof(line), reset)) { + while ((stag = f2b_source_next(jail->source, line, sizeof(line), reset)) > 0) { reset = false; + if (!match) match = f2b_match_create(now); + match->stag = stag; if (jail->flags & JAIL_HAS_FILTER) { - if (!f2b_filter_match(jail->filter, line, matchbuf, sizeof(matchbuf))) + if ((ftag = f2b_filter_match(jail->filter, line, matchbuf, sizeof(matchbuf), &score)) == 0) continue; + match->ftag = ftag; } else { /* without filter: 1) value always matches, 2) passed as-is */ memcpy(matchbuf, line, sizeof(matchbuf)); + match->ftag = 0; } /* some regex matches the line */ jail->stats.matches++; @@ -275,6 +281,8 @@ f2b_jail_process(f2b_jail_t *jail) { f2b_log_msg(log_debug, "jail '%s': found new ip %s", jail->name, matchbuf); } addr->lastseen = now; + f2b_matches_append(&addr->matches, match); + match = NULL; /* will create new object on next run */ if (addr->banned) { if (addr->banned_at != now) f2b_log_msg(log_warn, "jail '%s': ip %s was already banned", jail->name, matchbuf);