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