cf-socket: turn off IPV6_V6ONLY on Windows if it is supported
IPV6_V6ONLY refs: https://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses https://github.com/golang/go/blob/master/src/net/ipsock_posix.go https://en.wikipedia.org/wiki/Unix-like https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options default value refs: https://datatracker.ietf.org/doc/html/rfc3493#section-5.3 https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html#proc-sys-net-ipv6-variables Closes #10975
This commit is contained in:
Родитель
65f03e507f
Коммит
ca3f6decb9
|
@ -80,6 +80,22 @@
|
|||
#include "memdebug.h"
|
||||
|
||||
|
||||
#if defined(ENABLE_IPV6) && defined(IPV6_V6ONLY) && defined(WIN32)
|
||||
/* It makes support for IPv4-mapped IPv6 addresses.
|
||||
* Linux kernel, NetBSD, FreeBSD and Darwin: default is off;
|
||||
* Windows Vista and later: default is on;
|
||||
* DragonFly BSD: acts like off, and dummy setting;
|
||||
* OpenBSD and earlier Windows: unsupported.
|
||||
* Linux: controlled by /proc/sys/net/ipv6/bindv6only.
|
||||
*/
|
||||
static void set_ipv6_v6only(curl_socket_t sockfd, int on)
|
||||
{
|
||||
(void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on));
|
||||
}
|
||||
#else
|
||||
#define set_ipv6_v6only(x,y)
|
||||
#endif
|
||||
|
||||
static void tcpnodelay(struct Curl_easy *data, curl_socket_t sockfd)
|
||||
{
|
||||
#if defined(TCP_NODELAY)
|
||||
|
@ -944,8 +960,10 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf,
|
|||
goto out;
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
if(ctx->addr.family == AF_INET6)
|
||||
if(ctx->addr.family == AF_INET6) {
|
||||
set_ipv6_v6only(ctx->sock, 0);
|
||||
ipmsg = " Trying [%s]:%d...";
|
||||
}
|
||||
else
|
||||
#endif
|
||||
ipmsg = " Trying %s:%d...";
|
||||
|
|
Загрузка…
Ссылка в новой задаче