1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

relay: add option relay.weechat.commands (closes #928)

This commit is contained in:
Sébastien Helleu
2019-02-28 20:24:25 +01:00
parent 80b980b2af
commit d290de2cba
23 changed files with 228 additions and 15 deletions
+35
View File
@@ -75,6 +75,10 @@ struct t_config_option *relay_config_irc_backlog_since_last_message;
struct t_config_option *relay_config_irc_backlog_tags;
struct t_config_option *relay_config_irc_backlog_time_format;
/* relay config, weechat section */
struct t_config_option *relay_config_weechat_commands;
/* other */
regex_t *relay_config_regex_allowed_ips = NULL;
@@ -1003,6 +1007,37 @@ relay_config_init ()
NULL, 0, 0, "[%H:%M] ", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* section weechat */
ptr_section = weechat_config_new_section (relay_config_file, "weechat",
0, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (relay_config_file);
relay_config_file = NULL;
return 0;
}
relay_config_weechat_commands = weechat_config_new_option (
relay_config_file, ptr_section,
"commands", "string",
N_("comma-separated list of commands allowed/denied when input "
"data (text or command) is received from a client; "
"\"*\" means any command, a name beginning with \"!\" is "
"a negative value to prevent a command from being executed, "
"wildcard \"*\" is allowed in names; by default all commands "
"are allowed except /exec, /upgrade and /quit (which could lead "
"to denial of service or remote code execution if the client is "
"not trusted)"),
NULL, 0, 0, "*,!exec,!upgrade,!quit", NULL, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
/* section port */
ptr_section = weechat_config_new_section (
relay_config_file, "port",
+2
View File
@@ -57,6 +57,8 @@ extern struct t_config_option *relay_config_irc_backlog_since_last_message;
extern struct t_config_option *relay_config_irc_backlog_tags;
extern struct t_config_option *relay_config_irc_backlog_time_format;
extern struct t_config_option *relay_config_weechat_commands;
extern regex_t *relay_config_regex_allowed_ips;
extern regex_t *relay_config_regex_websocket_allowed_origins;
extern struct t_hashtable *relay_config_hashtable_irc_backlog_tags;
@@ -404,6 +404,7 @@ relay_weechat_protocol_input_timer_cb (const void *pointer,
char **timer_args;
int i;
struct t_gui_buffer *ptr_buffer;
struct t_hashtable *options;
/* make C compiler happy */
(void) data;
@@ -418,7 +419,21 @@ relay_weechat_protocol_input_timer_cb (const void *pointer,
{
ptr_buffer = weechat_buffer_search ("==", timer_args[0]);
if (ptr_buffer)
weechat_command (ptr_buffer, timer_args[1]);
{
options = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
if (options)
{
weechat_hashtable_set (
options,
"commands",
weechat_config_string (relay_config_weechat_commands));
weechat_command_options (ptr_buffer, timer_args[1], options);
weechat_hashtable_free (options);
}
}
}
for (i = 0; i < 2; i++)