|
|
@ -79,15 +79,15 @@ struct f2b_cmd_t { |
|
|
|
.tokens = { "jail", "<jailname>", "release", "<ip>", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "release", "<ip>", NULL }, |
|
|
|
.help = "Forcefully release some ip in given jail", |
|
|
|
.help = "Forcefully release some ip in given jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_REGEX_STATS] = { |
|
|
|
[CMD_JAIL_FILTER_STATS] = { |
|
|
|
.argc = 1, .tokenc = 4, |
|
|
|
.argc = 1, .tokenc = 4, |
|
|
|
.tokens = { "jail", "<jailname>", "regex", "stats", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "filter", "stats", NULL }, |
|
|
|
.help = "Show matches stats for jail regexps", |
|
|
|
.help = "Show matches stats for jail regexps", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_REGEX_ADD] = { |
|
|
|
[CMD_JAIL_FILTER_RELOAD] = { |
|
|
|
.argc = 2, .tokenc = 5, |
|
|
|
.argc = 2, .tokenc = 4, |
|
|
|
.tokens = { "jail", "<jailname>", "regex", "add", "<regex>", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "filter", "reload", NULL }, |
|
|
|
.help = "Add new regexp to jail", |
|
|
|
.help = "Reload regexps for given jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -183,22 +183,11 @@ f2b_cmd_parse(const char *src, char *buf, size_t buflen) { |
|
|
|
strlcat(buf, "\n", buflen); |
|
|
|
strlcat(buf, "\n", buflen); |
|
|
|
return CMD_JAIL_IP_RELEASE; |
|
|
|
return CMD_JAIL_IP_RELEASE; |
|
|
|
} |
|
|
|
} |
|
|
|
if (tokenc == 4 && strcmp(tokens[2], "regex") == 0 && strcmp(tokens[3], "stats") == 0) { |
|
|
|
if (tokenc == 4 && strcmp(tokens[2], "filter") == 0 && strcmp(tokens[3], "stats") == 0) { |
|
|
|
return CMD_JAIL_REGEX_STATS; |
|
|
|
return CMD_JAIL_FILTER_STATS; |
|
|
|
} |
|
|
|
|
|
|
|
if (tokenc >= 5 && strcmp(tokens[2], "regex") == 0 && strcmp(tokens[3], "add") == 0) { |
|
|
|
|
|
|
|
/* TODO: rewrite, this version is very error-prone */ |
|
|
|
|
|
|
|
char *regex = strstr(src, "add"); |
|
|
|
|
|
|
|
regex += strlen("add"); |
|
|
|
|
|
|
|
while (isblank(*regex)) |
|
|
|
|
|
|
|
regex++; |
|
|
|
|
|
|
|
if (*regex == '\0') { |
|
|
|
|
|
|
|
/* empty regex */ |
|
|
|
|
|
|
|
return CMD_NONE; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
strlcat(buf, regex, buflen); |
|
|
|
if (tokenc == 4 && strcmp(tokens[2], "filter") == 0 && strcmp(tokens[3], "reload") == 0) { |
|
|
|
strlcat(buf, "\n", buflen); |
|
|
|
return CMD_JAIL_FILTER_RELOAD; |
|
|
|
return CMD_JAIL_REGEX_ADD; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|