Browse Source

* f2b_jail_cmd_ip_release()

master
Alex 'AdUser' Z 8 years ago
parent
commit
0b5e38d0e7
  1. 7
      src/daemon.c
  2. 22
      src/jail.c
  3. 1
      src/jail.h

7
src/daemon.c

@ -85,7 +85,6 @@ void
f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) {
const char *args[DATA_ARGS_MAX];
f2b_jail_t *jail = NULL;
f2b_ipaddr_t *addr = NULL;
char line[LINE_MAX];
assert(msg != NULL);
@ -134,11 +133,7 @@ f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) {
} else if (msg->type == CMD_JAIL_IP_BAN) {
f2b_jail_cmd_ip_ban(res, ressize, args[0], args[1]);
} else if (msg->type == CMD_JAIL_IP_RELEASE) {
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) == NULL) {
snprintf(res, ressize, "can't find ip '%s' in jail '%s'\n", args[1], args[0]);
return;
}
f2b_jail_unban(jail, addr);
f2b_jail_cmd_ip_release(res, ressize, args[0], args[1]);
} else if (msg->type == CMD_JAIL_FILTER_STATS) {
f2b_filter_stats(jail->filter, res, ressize);
} else if (msg->type == CMD_JAIL_FILTER_RELOAD) {

22
src/jail.c

@ -493,3 +493,25 @@ f2b_jail_cmd_ip_ban(char *res, size_t ressize, const char *name, const char *ip)
}
f2b_jail_unban(jail, addr);
}
void
f2b_jail_cmd_ip_release(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'", name, ip);
return;
}
f2b_jail_unban(jail, addr);
}

1
src/jail.h

@ -57,4 +57,5 @@ bool f2b_jail_stop (f2b_jail_t *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);
void f2b_jail_cmd_ip_ban (char *res, size_t ressize, const char *name, const char *ip);
void f2b_jail_cmd_ip_release(char *res, size_t ressize, const char *name, const char *ip);
#endif /* F2B_JAIL_H_ */

Loading…
Cancel
Save