|
|
|
@ -132,19 +132,7 @@ f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) {
|
|
|
|
|
} else if (msg->type == CMD_JAIL_IP_STATUS) { |
|
|
|
|
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 */ |
|
|
|
|
time_t now = time(NULL); |
|
|
|
|
addr = f2b_ipaddr_create(args[1], jail->maxretry); |
|
|
|
|
if (!addr) { |
|
|
|
|
snprintf(res, ressize, "can't parse ip address: %s", args[1]); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
addr->lastseen = now; |
|
|
|
|
f2b_matches_append(&addr->matches, now); |
|
|
|
|
jail->ipaddrs = f2b_addrlist_append(jail->ipaddrs, addr); |
|
|
|
|
} |
|
|
|
|
f2b_jail_ban(jail, addr); |
|
|
|
|
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]); |
|
|
|
|