|
|
@ -110,17 +110,15 @@ f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strlcpy(res, "ok", ressize); /* default reply */ |
|
|
|
if (msg->type == CMD_PING) { |
|
|
|
if (msg->type == CMD_PING) { |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
/* nothing to do */ |
|
|
|
} else if (msg->type == CMD_RELOAD) { |
|
|
|
} else if (msg->type == CMD_RELOAD) { |
|
|
|
state = reconfig; |
|
|
|
state = reconfig; |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
|
|
|
|
} else if (msg->type == CMD_ROTATE) { |
|
|
|
} else if (msg->type == CMD_ROTATE) { |
|
|
|
state = logrotate; |
|
|
|
state = logrotate; |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
|
|
|
|
} else if (msg->type == CMD_SHUTDOWN) { |
|
|
|
} else if (msg->type == CMD_SHUTDOWN) { |
|
|
|
state = stop; |
|
|
|
state = stop; |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
|
|
|
|
} else if (msg->type == CMD_STATUS) { |
|
|
|
} else if (msg->type == CMD_STATUS) { |
|
|
|
snprintf(line, sizeof(line), "pid: %u\npidfile: %s\ncsocket: %s\njails:\n", |
|
|
|
snprintf(line, sizeof(line), "pid: %u\npidfile: %s\ncsocket: %s\njails:\n", |
|
|
|
getpid(), opts.pidfile_path, opts.csocket_path); |
|
|
|
getpid(), opts.pidfile_path, opts.csocket_path); |
|
|
@ -151,22 +149,17 @@ f2b_cmsg_process(const f2b_cmsg_t *msg, char *res, size_t ressize) { |
|
|
|
jail->ipaddrs = f2b_addrlist_append(jail->ipaddrs, addr); |
|
|
|
jail->ipaddrs = f2b_addrlist_append(jail->ipaddrs, addr); |
|
|
|
} |
|
|
|
} |
|
|
|
f2b_jail_ban(jail, addr); |
|
|
|
f2b_jail_ban(jail, addr); |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
|
|
|
|
} else if (msg->type == CMD_JAIL_IP_RELEASE) { |
|
|
|
} else if (msg->type == CMD_JAIL_IP_RELEASE) { |
|
|
|
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) != NULL) { |
|
|
|
if ((addr = f2b_addrlist_lookup(jail->ipaddrs, args[1])) == NULL) { |
|
|
|
f2b_jail_unban(jail, addr); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
snprintf(res, ressize, "can't find ip '%s' in jail '%s'\n", args[1], args[0]); |
|
|
|
snprintf(res, ressize, "can't find ip '%s' in jail '%s'\n", args[1], args[0]); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
f2b_jail_unban(jail, addr); |
|
|
|
} else if (msg->type == CMD_JAIL_FILTER_STATS) { |
|
|
|
} else if (msg->type == CMD_JAIL_FILTER_STATS) { |
|
|
|
f2b_filter_stats(jail->filter, res, ressize); |
|
|
|
f2b_filter_stats(jail->filter, res, ressize); |
|
|
|
} else if (msg->type == CMD_JAIL_FILTER_RELOAD) { |
|
|
|
} else if (msg->type == CMD_JAIL_FILTER_RELOAD) { |
|
|
|
if (f2b_filter_reload(jail->filter)) { |
|
|
|
if (f2b_filter_reload(jail->filter) == false) |
|
|
|
strlcpy(res, "ok", ressize); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
strlcpy(res, f2b_filter_error(jail->filter), ressize); |
|
|
|
strlcpy(res, f2b_filter_error(jail->filter), ressize); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
strlcpy(res, "error: unsupported command type", ressize); |
|
|
|
strlcpy(res, "error: unsupported command type", ressize); |
|
|
|
} |
|
|
|
} |
|
|
|