Browse Source

* f2b_jail_cmd_ip_status()

master
Alex 'AdUser' Z 8 years ago
parent
commit
320cede339
  1. 6
      src/daemon.c
  2. 21
      src/jail.c
  3. 3
      src/jail.h

6
src/daemon.c

@ -130,11 +130,7 @@ f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) {
} else if (msg->type == CMD_JAIL_STATUS) {
f2b_jail_cmd_status(res, ressize, args[0]);
} else if (msg->type == CMD_JAIL_IP_STATUS) {
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) != NULL) {
f2b_ipaddr_status(addr, res, ressize);
} else {
snprintf(res, ressize, "can't find ip '%s' in jail '%s'\n", args[1], args[0]);
}
f2b_jail_cmd_ip_status(res, ressize, args[0], args[1]);
} else if (msg->type == CMD_JAIL_IP_BAN) {
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) == NULL) {
/* TODO: this is copy-paste from f2b_jail_process */

21
src/jail.c

@ -444,3 +444,24 @@ f2b_jail_cmd_status(char *res, size_t ressize, const char *name) {
jail->incr_bantime, jail->incr_findtime,
jail->bancount, jail->matchcount);
}
void
f2b_jail_cmd_ip_status(char *res, size_t ressize, const char *name, const char *ip) {
f2b_jail_t *jail = NULL;
f2b_ipaddr_t *addr = NULL;
assert(res != NULL);
assert(name != NULL);
assert(ip != NULL);
if ((jail = f2b_jail_find(jails, name)) == NULL) {
snprintf(res, ressize, "can't find jail '%s'", name);
return;
}
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, ip)) == NULL) {
snprintf(res, ressize, "can't find ip '%s' in jail '%s'", ip, name);
return;
}
f2b_ipaddr_status(addr, res, ressize);
}

3
src/jail.h

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

Loading…
Cancel
Save