|
|
@ -9,67 +9,83 @@ |
|
|
|
#include "commands.h" |
|
|
|
#include "commands.h" |
|
|
|
|
|
|
|
|
|
|
|
struct f2b_cmd_t { |
|
|
|
struct f2b_cmd_t { |
|
|
|
|
|
|
|
const short int argc; |
|
|
|
|
|
|
|
const short int tokenc; |
|
|
|
const char *help; |
|
|
|
const char *help; |
|
|
|
const char *tokens[CMD_TOKENS_MAX]; |
|
|
|
const char *tokens[CMD_TOKENS_MAX]; |
|
|
|
char *data; |
|
|
|
|
|
|
|
} commands[CMD_MAX_NUMBER] = { |
|
|
|
} commands[CMD_MAX_NUMBER] = { |
|
|
|
[CMD_NONE] = { |
|
|
|
[CMD_NONE] = { |
|
|
|
|
|
|
|
.argc = 0, .tokenc = 0, |
|
|
|
.tokens = { NULL }, |
|
|
|
.tokens = { NULL }, |
|
|
|
.help = "Unspecified command" |
|
|
|
.help = "Unspecified command" |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_RESP] = { |
|
|
|
[CMD_RESP] = { |
|
|
|
|
|
|
|
.argc = 1, .tokenc = 0, |
|
|
|
.tokens = { NULL }, |
|
|
|
.tokens = { NULL }, |
|
|
|
.help = "Command response, used internally", |
|
|
|
.help = "Command response, used internally", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_HELP] = { |
|
|
|
[CMD_HELP] = { |
|
|
|
|
|
|
|
.argc = 0, tokenc = 1, |
|
|
|
.tokens = { "help", NULL }, |
|
|
|
.tokens = { "help", NULL }, |
|
|
|
.help = "Show available commands", |
|
|
|
.help = "Show available commands", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_PING] = { |
|
|
|
[CMD_PING] = { |
|
|
|
|
|
|
|
.argc = 0, .tokenc = 1, |
|
|
|
.tokens = { "ping", NULL }, |
|
|
|
.tokens = { "ping", NULL }, |
|
|
|
.help = "Check the connection", |
|
|
|
.help = "Check the connection", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_STATUS] = { |
|
|
|
[CMD_STATUS] = { |
|
|
|
|
|
|
|
.argc = 0, .tokenc = 1, |
|
|
|
.tokens = { "status", NULL }, |
|
|
|
.tokens = { "status", NULL }, |
|
|
|
.help = "Show general stats and jails list", |
|
|
|
.help = "Show general stats and jails list", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_ROTATE] = { |
|
|
|
[CMD_ROTATE] = { |
|
|
|
|
|
|
|
.argc = 0, .tokenc = 1, |
|
|
|
.tokens = { "rotate", NULL }, |
|
|
|
.tokens = { "rotate", NULL }, |
|
|
|
.help = "Reopen daemon's own log file", |
|
|
|
.help = "Reopen daemon's own log file", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_RELOAD] = { |
|
|
|
[CMD_RELOAD] = { |
|
|
|
|
|
|
|
.argc = 0, .tokenc = 1, |
|
|
|
.tokens = { "reload", NULL }, |
|
|
|
.tokens = { "reload", NULL }, |
|
|
|
.help = "Reload own config, all jails will be reset.", |
|
|
|
.help = "Reload own config, all jails will be reset.", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_SHUTDOWN] = { |
|
|
|
[CMD_SHUTDOWN] = { |
|
|
|
|
|
|
|
.argc = 0, .tokenc = 1, |
|
|
|
.tokens = { "shutdown", NULL }, |
|
|
|
.tokens = { "shutdown", NULL }, |
|
|
|
.help = "Gracefully terminate f2b daemon", |
|
|
|
.help = "Gracefully terminate f2b daemon", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_STATUS] = { |
|
|
|
[CMD_JAIL_STATUS] = { |
|
|
|
|
|
|
|
.argc = 2, .tokenc = 3, |
|
|
|
.tokens = { "jail", "<jailname>", "status", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "status", NULL }, |
|
|
|
.help = "Show status and stats of given jail", |
|
|
|
.help = "Show status and stats of given jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_SET] = { |
|
|
|
[CMD_JAIL_SET] = { |
|
|
|
|
|
|
|
.argc = 3, .tokenc = 5, |
|
|
|
.tokens = { "jail", "<jailname>", "set", "<param>", "<value>", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "set", "<param>", "<value>", NULL }, |
|
|
|
.help = "Set parameter of given jail", |
|
|
|
.help = "Set parameter of given jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_IP_SHOW] = { |
|
|
|
[CMD_JAIL_IP_SHOW] = { |
|
|
|
|
|
|
|
.argc = 2, .tokenc = 4, |
|
|
|
.tokens = { "jail", "<jailname>", "show", "<ip>", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "show", "<ip>", NULL }, |
|
|
|
.help = "Show ip status in given jail", |
|
|
|
.help = "Show ip status in given jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_IP_BAN] = { |
|
|
|
[CMD_JAIL_IP_BAN] = { |
|
|
|
|
|
|
|
.argc = 2, .tokenc = 4, |
|
|
|
.tokens = { "jail", "<jailname>", "ban", "<ip>", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "ban", "<ip>", NULL }, |
|
|
|
.help = "Forcefully ban some ip in given jail", |
|
|
|
.help = "Forcefully ban some ip in given jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_IP_RELEASE] = { |
|
|
|
[CMD_JAIL_IP_RELEASE] = { |
|
|
|
|
|
|
|
.argc = 2, .tokenc = 4, |
|
|
|
.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_REGEX_STATS] = { |
|
|
|
|
|
|
|
.argc = 1, .tokenc = 4, |
|
|
|
.tokens = { "jail", "<jailname>", "regex", "stats", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "regex", "stats", NULL }, |
|
|
|
.help = "Show matches stats for jail regexps", |
|
|
|
.help = "Show matches stats for jail regexps", |
|
|
|
}, |
|
|
|
}, |
|
|
|
[CMD_JAIL_REGEX_ADD] = { |
|
|
|
[CMD_JAIL_REGEX_ADD] = { |
|
|
|
|
|
|
|
.argc = 2, .tokenc = 5, |
|
|
|
.tokens = { "jail", "<jailname>", "regex", "add", "<regex>", NULL }, |
|
|
|
.tokens = { "jail", "<jailname>", "regex", "add", "<regex>", NULL }, |
|
|
|
.help = "Add new regexp to jail", |
|
|
|
.help = "Add new regexp to jail", |
|
|
|
}, |
|
|
|
}, |
|
|
|