Browse Source

* update f2b_jail_cmd_status()

master
Alex 'AdUser' Z 8 years ago
parent
commit
2c0fce9814
  1. 2
      src/daemon.c
  2. 13
      src/jail.c
  3. 2
      src/jail.h

2
src/daemon.c

@ -128,7 +128,7 @@ f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) {
strlcat(res, line, ressize); strlcat(res, line, ressize);
} }
} else if (msg->type == CMD_JAIL_STATUS) { } else if (msg->type == CMD_JAIL_STATUS) {
f2b_jail_get_status(jail, res, ressize); f2b_jail_cmd_status(res, ressize, args[0]);
} else if (msg->type == CMD_JAIL_IP_SHOW) { } else if (msg->type == CMD_JAIL_IP_SHOW) {
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) != NULL) { if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) != NULL) {
f2b_ipaddr_status(addr, res, ressize); f2b_ipaddr_status(addr, res, ressize);

13
src/jail.c

@ -415,9 +415,8 @@ f2b_jail_stop(f2b_jail_t *jail) {
} }
void void
f2b_jail_get_status(f2b_jail_t *jail, char *res, size_t ressize) { f2b_jail_cmd_status(char *res, size_t ressize, const char *name) {
assert(jail != NULL); f2b_jail_t *jail = NULL;
assert(res != NULL);
const char *fmt = const char *fmt =
"name: %s\n" "name: %s\n"
"enabled: %s\n" "enabled: %s\n"
@ -432,6 +431,14 @@ f2b_jail_get_status(f2b_jail_t *jail, char *res, size_t ressize) {
"stats:\n" "stats:\n"
" banned: %d\n" " banned: %d\n"
" matched: %d\n"; " matched: %d\n";
assert(res != NULL);
assert(name != NULL);
if ((jail = f2b_jail_find(jails, name)) == NULL) {
snprintf(res, ressize, "can't find jail '%s'", name);
return;
}
snprintf(res, ressize, fmt, jail->name, jail->enabled ? "yes" : "no", jail->maxretry, snprintf(res, ressize, fmt, jail->name, jail->enabled ? "yes" : "no", jail->maxretry,
jail->bantime, jail->findtime, jail->expiretime, jail->bantime, jail->findtime, jail->expiretime,
jail->incr_bantime, jail->incr_findtime, jail->incr_bantime, jail->incr_findtime,

2
src/jail.h

@ -54,5 +54,5 @@ bool f2b_jail_init (f2b_jail_t *jail, f2b_config_t *config);
size_t f2b_jail_process (f2b_jail_t *jail); size_t f2b_jail_process (f2b_jail_t *jail);
bool f2b_jail_stop (f2b_jail_t *jail); bool f2b_jail_stop (f2b_jail_t *jail);
void f2b_jail_get_status(f2b_jail_t *jail, char *res, size_t ressize); void f2b_jail_cmd_status(char *res, size_t ressize, const char *jail);
#endif /* F2B_JAIL_H_ */ #endif /* F2B_JAIL_H_ */

Loading…
Cancel
Save