|
|
|
@ -202,16 +202,16 @@ f2b_jail_find(f2b_jail_t *list, const char *name) {
|
|
|
|
|
|
|
|
|
|
size_t |
|
|
|
|
f2b_jail_process(f2b_jail_t *jail) { |
|
|
|
|
f2b_logfile_t *file = NULL; |
|
|
|
|
f2b_ipaddr_t *prev = NULL; |
|
|
|
|
f2b_ipaddr_t *addr = NULL; |
|
|
|
|
size_t processed = 0; |
|
|
|
|
char logline[LOGLINE_MAX] = ""; |
|
|
|
|
char line[LOGLINE_MAX] = ""; |
|
|
|
|
char matchbuf[IPADDR_MAX] = ""; |
|
|
|
|
time_t now = time(NULL); |
|
|
|
|
time_t findtime = 0; |
|
|
|
|
time_t expiretime = 0; |
|
|
|
|
bool remove = false; |
|
|
|
|
bool reset = true; /* source reset */ |
|
|
|
|
|
|
|
|
|
assert(jail != NULL); |
|
|
|
|
|
|
|
|
@ -219,17 +219,9 @@ f2b_jail_process(f2b_jail_t *jail) {
|
|
|
|
|
|
|
|
|
|
f2b_backend_ping(jail->backend); |
|
|
|
|
|
|
|
|
|
for (file = jail->logfiles; file != NULL; file = file->next) { |
|
|
|
|
if (f2b_logfile_rotated(file)) { |
|
|
|
|
f2b_log_msg(log_info, "jail '%s': file changed -- %s", jail->name, file->path); |
|
|
|
|
f2b_logfile_close(file); |
|
|
|
|
} |
|
|
|
|
if (!file->opened && !f2b_logfile_open(file, NULL)) { |
|
|
|
|
f2b_log_msg(log_error, "jail '%s': can't open file -- %s", jail->name, file->path); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
while (f2b_logfile_getline(file, logline, sizeof(logline))) { |
|
|
|
|
if (!f2b_filter_match(jail->filter, logline, matchbuf, sizeof(matchbuf))) |
|
|
|
|
while (f2b_source_next(jail->source, line, sizeof(line), reset)) { |
|
|
|
|
reset = false; |
|
|
|
|
if (!f2b_filter_match(jail->filter, line, matchbuf, sizeof(matchbuf))) |
|
|
|
|
continue; |
|
|
|
|
/* some regex matches the line */ |
|
|
|
|
jail->matchcount++; |
|
|
|
@ -266,8 +258,7 @@ f2b_jail_process(f2b_jail_t *jail) {
|
|
|
|
|
} |
|
|
|
|
/* limit reached, ban ip */ |
|
|
|
|
f2b_jail_ban(jail, addr); |
|
|
|
|
} /* while(lines) */ |
|
|
|
|
} /* for(files) */ |
|
|
|
|
} /* while(1) */ |
|
|
|
|
|
|
|
|
|
for (addr = jail->ipaddrs, prev = NULL; addr != NULL; ) { |
|
|
|
|
remove = false; |
|
|
|
|