Browse Source

* fix jail defaults & stats

master
Alex 'AdUser' Z 4 years ago
parent
commit
dce63b7ecd
  1. 21
      src/jail.c
  2. 6
      src/jail.h

21
src/jail.c

@ -27,6 +27,7 @@ f2b_jail_t *jails = NULL;
static f2b_jail_t defaults = { static f2b_jail_t defaults = {
.bantime = DEFAULT_BANTIME, .bantime = DEFAULT_BANTIME,
.findtime = DEFAULT_FINDTIME, .findtime = DEFAULT_FINDTIME,
.expiretime = DEFAULT_EXPIRETIME,
.maxretry = DEFAULT_MAXRETRY, .maxretry = DEFAULT_MAXRETRY,
}; };
@ -515,19 +516,15 @@ void
f2b_jail_cmd_status(char *res, size_t ressize, f2b_jail_t *jail) { f2b_jail_cmd_status(char *res, size_t ressize, f2b_jail_t *jail) {
const char *fmt = const char *fmt =
"name: %s\n" "name: %s\n"
"maxretry: %d\n"
"flags:\n" "flags:\n"
" enabled: %s\n" " enabled: %s\n"
" state: %s\n" " state: %s\n"
" filter: %s\n" " filter: %s\n"
"maxretry: %d\n"
"times:\n" "times:\n"
" bantime: %d (+%d%%)\n" " bantime: %.1f hrs (+%d%%)\n"
" findtime: %d (+%d%%)\n" " findtime: %.1f min (+%d%%)\n"
" expiretime: %d (+%d%%)\n" " expiretime: %.1f min (+%d%%)\n"
"extend:\n"
" bantime: %.1f\n"
" findtime: %.1f\n"
" expiretime: %d\n"
"stats:\n" "stats:\n"
" hosts: %d\n" " hosts: %d\n"
" matches: %d\n" " matches: %d\n"
@ -537,13 +534,13 @@ f2b_jail_cmd_status(char *res, size_t ressize, f2b_jail_t *jail) {
assert(jail != NULL); assert(jail != NULL);
snprintf(res, ressize, fmt, jail->name, snprintf(res, ressize, fmt, jail->name,
jail->maxretry,
jail->flags & JAIL_ENABLED ? "yes" : "no", jail->flags & JAIL_ENABLED ? "yes" : "no",
jail->flags & JAIL_HAS_STATE ? "yes" : "no", jail->flags & JAIL_HAS_STATE ? "yes" : "no",
jail->flags & JAIL_HAS_FILTER ? "yes" : "no", jail->flags & JAIL_HAS_FILTER ? "yes" : "no",
jail->maxretry, jail->bantime / 3600, (int) jail->bantime_extend * 100,
jail->bantime, (int) (jail->bantime_extend - 1.0) * 100, jail->findtime / 60, (int) jail->findtime_extend * 100,
jail->findtime, (int) (jail->findtime_extend - 1.0) * 100, jail->expiretime / 60, (int) jail->expiretime_extend * 100,
jail->expiretime, (int) (jail->expiretime_extend - 1.0) * 100,
jail->stats.hosts, jail->stats.hosts,
jail->stats.matches, jail->stats.matches,
jail->stats.bans); jail->stats.bans);

6
src/jail.h

@ -28,9 +28,9 @@ typedef struct f2b_jail_t {
time_t bantime; /**< option: host ban time on excess activity (seconds) */ time_t bantime; /**< option: host ban time on excess activity (seconds) */
time_t expiretime; /**< option: forget about host after this time with no activity (seconds, for banned hosts - after it's release, for not banned - after latest match) */ time_t expiretime; /**< option: forget about host after this time with no activity (seconds, for banned hosts - after it's release, for not banned - after latest match) */
/** time period length modifiers for already banned hosts */ /** time period length modifiers for already banned hosts */
float findtime_extend; /**< findtime modifier for already banned hosts in past (float) */ float findtime_extend; /**< (float, 0.0 - 1.0) */
float bantime_extend; /**< bantime modifier for already banned hosts in past (float) */ float bantime_extend; /**< (float, 0.0 - 1.0) */
float expiretime_extend; /**< expiretime modifier for already banned hosts in past (float) */ float expiretime_extend; /**< (float, 0.0 - 1.0) */
/* jail stats */ /* jail stats */
struct { struct {
unsigned int hosts; /**< number of tracked hosts */ unsigned int hosts; /**< number of tracked hosts */

Loading…
Cancel
Save