1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 09:43:13 +02:00

core: convert proxy option ipv6 from boolean to enum (disable, auto, force) (issue #2164)

This commit is contained in:
Sébastien Helleu
2024-08-04 23:43:05 +02:00
parent 5fe3b38892
commit 4e1a0731e7
7 changed files with 102 additions and 13 deletions
+19 -2
View File
@@ -994,8 +994,25 @@ network_connect_child (struct t_hook *hook_connect)
res_init ();
if (ptr_proxy)
{
hints.ai_family = (CONFIG_BOOLEAN(ptr_proxy->options[PROXY_OPTION_IPV6])) ?
AF_UNSPEC : AF_INET;
switch (CONFIG_ENUM(ptr_proxy->options[PROXY_OPTION_IPV6]))
{
case PROXY_IPV6_DISABLE:
/* force IPv4 */
hints.ai_family = AF_INET;
break;
case PROXY_IPV6_AUTO:
/* auto: IPv6 / IPv4 */
hints.ai_family = AF_UNSPEC;
break;
case PROXY_IPV6_FORCE:
/* force IPv6 */
hints.ai_family = AF_INET6;
break;
default:
/* auto by default */
hints.ai_family = AF_UNSPEC;
break;
}
snprintf (port, sizeof (port), "%d", CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
rc = getaddrinfo (CONFIG_STRING(ptr_proxy->options[PROXY_OPTION_ADDRESS]),
port, &hints, &res_remote);