1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

relay: add proxy option in remote (issue #2066)

This commit is contained in:
Sébastien Helleu
2024-03-30 11:02:22 +01:00
parent 3f993f9422
commit c4c220f0a3
4 changed files with 29 additions and 14 deletions
+11 -10
View File
@@ -427,7 +427,7 @@ relay_command_remote (const void *pointer, void *data,
{
struct t_relay_remote *ptr_remote, *ptr_remote2;
int i, detailed_list, one_remote_found;
const char *ptr_password, *ptr_totp_secret;
const char *ptr_proxy, *ptr_password, *ptr_totp_secret;
char *remote_name;
/* make C compiler happy */
@@ -533,12 +533,17 @@ relay_command_remote (const void *pointer, void *data,
return WEECHAT_RC_OK;
}
ptr_proxy = NULL;
ptr_password = NULL;
ptr_totp_secret = NULL;
for (i = 4; i < argc; i++)
{
if (strncmp (argv[i], "-password=", 10) == 0)
if (strncmp (argv[i], "-proxy=", 7) == 0)
{
ptr_proxy = argv[i] + 7;
}
else if (strncmp (argv[i], "-password=", 10) == 0)
{
ptr_password = argv[i] + 10;
}
@@ -557,12 +562,8 @@ relay_command_remote (const void *pointer, void *data,
}
}
ptr_remote = relay_remote_new (
argv[2],
argv[3],
(ptr_password) ? ptr_password : "",
(ptr_totp_secret) ? ptr_totp_secret : "");
ptr_remote = relay_remote_new (argv[2], argv[3], ptr_proxy,
ptr_password, ptr_totp_secret);
if (ptr_remote)
{
weechat_printf (NULL, _("Remote \"%s\" created"), argv[2]);
@@ -790,7 +791,7 @@ relay_command_init ()
"options: relay.remote.name.xxx"),
N_("url: URL of the remote, format is https://example.com:9000 "
"or http://example.com:9000 (plain-text connection, not recommended)"),
N_("option: set option for remote: password or totp_secret"),
N_("option: set option for remote: proxy, password or totp_secret"),
N_("raw[connect]: connect to a remote relay server"),
N_("raw[rename]: rename a remote relay server"),
N_("raw[del]: delete a remote relay server"),
@@ -806,7 +807,7 @@ relay_command_init ()
"list %(relay_remotes)"
" || listfull %(relay_remotes)"
" || add %(relay_remotes) https://localhost:9000 "
"-password=${xxx}|-totp_secret=${xxx}|%*"
"-password=${xxx}|-proxy=xxx|-totp_secret=${xxx}|%*"
" || connect %(relay_remotes)"
" || rename %(relay_remotes) %(relay_remotes)"
" || del %(relay_remotes)",
+9
View File
@@ -997,6 +997,15 @@ relay_config_create_remote_option (const char *remote_name, int index_option,
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case RELAY_REMOTE_OPTION_PROXY:
ptr_option = weechat_config_new_option (
relay_config_file, relay_config_section_remote,
option_name, "string",
N_("name of proxy used for this remote (optional, proxy must "
"be defined with command /proxy)"),
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case RELAY_REMOTE_OPTION_PASSWORD:
ptr_option = weechat_config_new_option (
relay_config_file, relay_config_section_remote,
+7 -4
View File
@@ -38,9 +38,9 @@
char *relay_remote_option_string[RELAY_REMOTE_NUM_OPTIONS] =
{ "url", "password", "totp_secret" };
{ "url", "proxy", "password", "totp_secret" };
char *relay_remote_option_default[RELAY_REMOTE_NUM_OPTIONS] =
{ "", "", "" };
{ "", "", "", "" };
struct t_relay_remote *relay_remotes = NULL;
struct t_relay_remote *last_relay_remote = NULL;
@@ -362,8 +362,8 @@ relay_remote_new_with_options (const char *name, struct t_config_option **option
*/
struct t_relay_remote *
relay_remote_new (const char *name, const char *url, const char *password,
const char *totp_secret)
relay_remote_new (const char *name, const char *url, const char *proxy,
const char *password, const char *totp_secret)
{
struct t_config_option *option[RELAY_REMOTE_NUM_OPTIONS];
const char *value[RELAY_REMOTE_NUM_OPTIONS];
@@ -378,6 +378,7 @@ relay_remote_new (const char *name, const char *url, const char *password,
return NULL;
value[RELAY_REMOTE_OPTION_URL] = url;
value[RELAY_REMOTE_OPTION_PROXY] = proxy;
value[RELAY_REMOTE_OPTION_PASSWORD] = password;
value[RELAY_REMOTE_OPTION_TOTP_SECRET] = totp_secret;
@@ -659,6 +660,8 @@ relay_remote_print_log ()
weechat_log_printf (" name. . . . . . . . . : '%s'", ptr_remote->name);
weechat_log_printf (" url . . . . . . . . . : '%s'",
weechat_config_string (ptr_remote->options[RELAY_REMOTE_OPTION_URL]));
weechat_log_printf (" proxy . . . . . . . . : '%s'",
weechat_config_string (ptr_remote->options[RELAY_REMOTE_OPTION_PROXY]));
weechat_log_printf (" password. . . . . . . : '%s'",
weechat_config_string (ptr_remote->options[RELAY_REMOTE_OPTION_PASSWORD]));
weechat_log_printf (" totp_secret . . . . . : '%s'",
+2
View File
@@ -25,6 +25,7 @@
enum t_relay_remote_option
{
RELAY_REMOTE_OPTION_URL = 0, /* remote URL */
RELAY_REMOTE_OPTION_PROXY, /* proxy used for remote (optional) */
RELAY_REMOTE_OPTION_PASSWORD, /* password for remote relay */
RELAY_REMOTE_OPTION_TOTP_SECRET, /* TOTP secret for remote relay */
/* number of relay remote options */
@@ -68,6 +69,7 @@ extern void relay_remote_add (struct t_relay_remote *remote,
extern struct t_relay_remote *relay_remote_new_with_options (const char *name,
struct t_config_option **options);
extern struct t_relay_remote *relay_remote_new (const char *name,
const char *proxy,
const char *url,
const char *password,
const char *totp_secret);