1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

relay/api: fix connection to remote using an IPv6 address with square brackets (closes #2156)

This commit is contained in:
Sébastien Helleu
2024-07-22 17:24:50 +02:00
parent 9ece7b4d8c
commit 8c48b2f310
4 changed files with 175 additions and 125 deletions
@@ -57,13 +57,17 @@ relay_remote_network_get_url_resource (struct t_relay_remote *remote,
const char *resource)
{
char *url;
int colon_in_address;
if (!remote || !remote->address || !resource || !resource[0])
return NULL;
weechat_asprintf (&url, "%s://%s:%d/api/%s",
colon_in_address = (strchr (remote->address, ':')) ? 1 : 0;
weechat_asprintf (&url, "%s://%s%s%s:%d/api/%s",
(remote->tls) ? "https" : "http",
(colon_in_address) ? "[" : "",
remote->address,
(colon_in_address) ? "]" : "",
remote->port,
resource);