mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 05:16:38 +02:00
relay: add support of secured data in option relay.network.password (evaluate content) (patch from Nils Görs)
This commit is contained in:
@@ -1296,7 +1296,7 @@ void
|
||||
relay_irc_recv (struct t_relay_client *client, const char *data)
|
||||
{
|
||||
char str_time[128], str_signal[128], str_server_channel[256];
|
||||
char str_command[128], *target, **irc_argv, *pos;
|
||||
char str_command[128], *target, **irc_argv, *pos, *password;
|
||||
const char *irc_command, *irc_channel, *irc_args, *irc_args2;
|
||||
int irc_argc, redirect_msg;
|
||||
const char *nick, *irc_is_channel, *isupport, *info, *pos_password;
|
||||
@@ -1366,11 +1366,16 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
|
||||
pos_password = pos + 1;
|
||||
}
|
||||
}
|
||||
if (!RELAY_IRC_DATA(client, password_ok)
|
||||
&& (strcmp (weechat_config_string (relay_config_network_password),
|
||||
pos_password) == 0))
|
||||
if (!RELAY_IRC_DATA(client, password_ok))
|
||||
{
|
||||
RELAY_IRC_DATA(client, password_ok) = 1;
|
||||
password = weechat_string_eval_expression (weechat_config_string (relay_config_network_password),
|
||||
NULL, NULL, NULL);
|
||||
if (password)
|
||||
{
|
||||
if (strcmp (password, pos_password) == 0)
|
||||
RELAY_IRC_DATA(client, password_ok) = 1;
|
||||
free (password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1773,9 +1778,10 @@ void
|
||||
relay_irc_alloc (struct t_relay_client *client)
|
||||
{
|
||||
struct t_relay_irc_data *irc_data;
|
||||
const char *password;
|
||||
char *password;
|
||||
|
||||
password = weechat_config_string (relay_config_network_password);
|
||||
password = weechat_string_eval_expression (weechat_config_string (relay_config_network_password),
|
||||
NULL, NULL, NULL);
|
||||
|
||||
client->protocol_data = malloc (sizeof (*irc_data));
|
||||
if (client->protocol_data)
|
||||
@@ -1792,6 +1798,9 @@ relay_irc_alloc (struct t_relay_client *client)
|
||||
RELAY_IRC_DATA(client, hook_signal_irc_disc) = NULL;
|
||||
RELAY_IRC_DATA(client, hook_hsignal_irc_redir) = NULL;
|
||||
}
|
||||
|
||||
if (password)
|
||||
free (password);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -629,7 +629,8 @@ 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)"),
|
||||
"means no password required) (note: content is evaluated, see "
|
||||
"/help eval)"),
|
||||
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
relay_config_network_ssl_cert_key = weechat_config_new_option (
|
||||
relay_config_file, ptr_section,
|
||||
|
||||
@@ -165,7 +165,7 @@ relay_weechat_protocol_is_sync (struct t_relay_client *ptr_client,
|
||||
|
||||
RELAY_WEECHAT_PROTOCOL_CALLBACK(init)
|
||||
{
|
||||
char **options, *pos;
|
||||
char **options, *pos, *password;
|
||||
int num_options, i, compression;
|
||||
|
||||
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(1);
|
||||
@@ -182,10 +182,13 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(init)
|
||||
pos++;
|
||||
if (strcmp (options[i], "password") == 0)
|
||||
{
|
||||
if (strcmp (weechat_config_string (relay_config_network_password),
|
||||
pos) == 0)
|
||||
password = weechat_string_eval_expression (weechat_config_string (relay_config_network_password),
|
||||
NULL, NULL, NULL);
|
||||
if (password)
|
||||
{
|
||||
RELAY_WEECHAT_DATA(client, password_ok) = 1;
|
||||
if (strcmp (password, pos) == 0)
|
||||
RELAY_WEECHAT_DATA(client, password_ok) = 1;
|
||||
free (password);
|
||||
}
|
||||
}
|
||||
else if (strcmp (options[i], "compression") == 0)
|
||||
|
||||
@@ -167,9 +167,10 @@ void
|
||||
relay_weechat_alloc (struct t_relay_client *client)
|
||||
{
|
||||
struct t_relay_weechat_data *weechat_data;
|
||||
const char *password;
|
||||
char *password;
|
||||
|
||||
password = weechat_config_string (relay_config_network_password);
|
||||
password = weechat_string_eval_expression (weechat_config_string (relay_config_network_password),
|
||||
NULL, NULL, NULL);
|
||||
|
||||
client->protocol_data = malloc (sizeof (*weechat_data));
|
||||
if (client->protocol_data)
|
||||
@@ -198,6 +199,9 @@ relay_weechat_alloc (struct t_relay_client *client)
|
||||
|
||||
relay_weechat_hook_signals (client);
|
||||
}
|
||||
|
||||
if (password)
|
||||
free (password);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user