Browse Source

* chg jail commands 'show', 'ban' & 'release' : add expicit 'ip' prefix

master
Alex 'AdUser' Z 8 years ago
parent
commit
47cd2bcd38
  1. 28
      src/commands.c
  2. 2
      src/commands.h
  3. 2
      src/daemon.c

28
src/commands.c

@ -63,19 +63,19 @@ struct f2b_cmd_t {
.tokens = { "jail", "<jailname>", "set", "<param>", "<value>", NULL },
.help = "Set parameter of given jail",
},
[CMD_JAIL_IP_SHOW] = {
.argc = 2, .tokenc = 4,
.tokens = { "jail", "<jailname>", "show", "<ip>", NULL },
[CMD_JAIL_IP_STATUS] = {
.argc = 2, .tokenc = 5,
.tokens = { "jail", "<jailname>", "ip", "status", "<ip>", NULL },
.help = "Show ip status in given jail",
},
[CMD_JAIL_IP_BAN] = {
.argc = 2, .tokenc = 4,
.tokens = { "jail", "<jailname>", "ban", "<ip>", NULL },
.argc = 2, .tokenc = 5,
.tokens = { "jail", "<jailname>", "ip", "ban", "<ip>", NULL },
.help = "Forcefully ban some ip in given jail",
},
[CMD_JAIL_IP_RELEASE] = {
.argc = 2, .tokenc = 4,
.tokens = { "jail", "<jailname>", "release", "<ip>", NULL },
.argc = 2, .tokenc = 5,
.tokens = { "jail", "<jailname>", "ip", "release", "<ip>", NULL },
.help = "Forcefully release some ip in given jail",
},
[CMD_JAIL_FILTER_STATS] = {
@ -167,18 +167,18 @@ f2b_cmd_parse(const char *src, char *buf, size_t buflen) {
strlcat(buf, "\n", buflen);
return CMD_JAIL_SET;
}
if (tokenc == 4 && strcmp(tokens[2], "show") == 0) {
strlcat(buf, tokens[3], buflen);
if (tokenc == 5 && strcmp(tokens[2], "ip") == 0 && strcmp(tokens[3], "status") == 0) {
strlcat(buf, tokens[4], buflen);
strlcat(buf, "\n", buflen);
return CMD_JAIL_IP_SHOW;
return CMD_JAIL_IP_STATUS;
}
if (tokenc == 4 && strcmp(tokens[2], "ban") == 0) {
strlcat(buf, tokens[3], buflen);
if (tokenc == 5 && strcmp(tokens[2], "ip") == 0 && strcmp(tokens[3], "ban") == 0) {
strlcat(buf, tokens[4], buflen);
strlcat(buf, "\n", buflen);
return CMD_JAIL_IP_BAN;
}
if (tokenc == 4 && strcmp(tokens[2], "release") == 0) {
strlcat(buf, tokens[3], buflen);
if (tokenc == 5 && strcmp(tokens[2], "ip") == 0 && strcmp(tokens[3], "release") == 0) {
strlcat(buf, tokens[4], buflen);
strlcat(buf, "\n", buflen);
return CMD_JAIL_IP_RELEASE;
}

2
src/commands.h

@ -22,7 +22,7 @@ enum f2b_cmd_type {
CMD_SHUTDOWN,
CMD_JAIL_STATUS = 16,
CMD_JAIL_SET,
CMD_JAIL_IP_SHOW,
CMD_JAIL_IP_STATUS,
CMD_JAIL_IP_BAN,
CMD_JAIL_IP_RELEASE,
CMD_JAIL_FILTER_STATS,

2
src/daemon.c

@ -129,7 +129,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_SHOW) {
} 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 {

Loading…
Cancel
Save