1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 07:46:38 +02:00

relay: add option relay.network.allow_empty_password (closes #735)

This commit is contained in:
Sébastien Helleu
2016-05-18 07:55:03 +02:00
parent ec86e1ac85
commit 499b9be1fb
23 changed files with 261 additions and 40 deletions
+12 -5
View File
@@ -52,6 +52,7 @@ struct t_config_option *relay_config_color_text_selected;
/* relay config, network section */
struct t_config_option *relay_config_network_allow_empty_password;
struct t_config_option *relay_config_network_allowed_ips;
struct t_config_option *relay_config_network_bind_address;
struct t_config_option *relay_config_network_clients_purge_delay;
@@ -750,6 +751,13 @@ relay_config_init ()
return 0;
}
relay_config_network_allow_empty_password = weechat_config_new_option (
relay_config_file, ptr_section,
"allow_empty_password", "boolean",
N_("allow empty password in relay (it should be enabled only for "
"tests or local network)"),
NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_allowed_ips = weechat_config_new_option (
relay_config_file, ptr_section,
"allowed_ips", "string",
@@ -768,9 +776,7 @@ relay_config_init ()
"interfaces, use \"127.0.0.1\" to allow connections from "
"local machine only)"),
NULL, 0, 0, "", NULL, 0,
NULL, NULL, NULL,
&relay_config_change_network_bind_address_cb, NULL, NULL,
NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_clients_purge_delay = weechat_config_new_option (
relay_config_file, ptr_section,
"clients_purge_delay", "integer",
@@ -806,8 +812,9 @@ relay_config_init ()
relay_config_file, ptr_section,
"password", "string",
N_("password required by clients to access this relay (empty value "
"means no password required) (note: content is evaluated, see "
"/help eval)"),
"means no password required, see option "
"relay.network.allow_empty_password) (note: content is evaluated, "
"see /help eval)"),
NULL, 0, 0, "", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
relay_config_network_ssl_cert_key = weechat_config_new_option (
+1
View File
@@ -36,6 +36,7 @@ extern struct t_config_option *relay_config_color_text;
extern struct t_config_option *relay_config_color_text_bg;
extern struct t_config_option *relay_config_color_text_selected;
extern struct t_config_option *relay_config_network_allow_empty_password;
extern struct t_config_option *relay_config_network_allowed_ips;
extern struct t_config_option *relay_config_network_bind_address;
extern struct t_config_option *relay_config_network_clients_purge_delay;
+17
View File
@@ -229,6 +229,7 @@ relay_server_sock_cb (const void *pointer, void *data, int fd)
int client_fd, flags, set, max_clients, num_clients_on_port;
char ipv4_address[INET_ADDRSTRLEN + 1], ipv6_address[INET6_ADDRSTRLEN + 1];
char *ptr_ip_address;
const char *relay_password;
/* make C compiler happy */
(void) data;
@@ -261,6 +262,22 @@ relay_server_sock_cb (const void *pointer, void *data, int fd)
return WEECHAT_RC_OK;
}
/* check if relay password is empty and if it is not allowed */
relay_password = weechat_string_eval_expression (
weechat_config_string (relay_config_network_password),
NULL, NULL, NULL);
if (!weechat_config_boolean (relay_config_network_allow_empty_password)
&& (!relay_password || !relay_password[0]))
{
weechat_printf (NULL,
_("%s%s: cannot accept client because relay password "
"is empty, and option "
"relay.network.allow_empty_password is off"),
weechat_prefix ("error"), RELAY_PLUGIN_NAME);
close (client_fd);
return WEECHAT_RC_OK;
}
/* check if we have reached the max number of clients on this port */
max_clients = weechat_config_integer (relay_config_network_max_clients);
if (max_clients > 0)