Skip to content

Auto detect IPv6 connectivity #28061

@vasild

Description

@vasild

Please describe the feature you'd like to see added.

Auto detect if the host has connectivity to the IPv6 network and only attempt to make automatic outbound connections if it has.

Is your feature related to a problem, if so please describe it.

IPv6 is set to reachable by default. If it is not in practice then some outbound connection attempts will be made in vain, trying to connect to IPv6 hosts.

Describe the solution you'd like

If the kernel does not have IPv6 support compiled in then socket(2):

SOCKET hSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP);

should return EAFNOSUPPORT.

Or if the kernel has support, but the error from connect(2):

if (sock.Connect(reinterpret_cast<struct sockaddr*>(&sockaddr), len) == SOCKET_ERROR) {

is EADDRNOTAVAIL then that means the machine has no IPv6 address configured (but it may be configured later).

In those cases, I guess, we can disable IPv6 with SetReachable(NET_IPV6, false) or at least log a warning prompting the user to explicitly list all reachable networks with -onlynet and omit IPv6 if it is not.

Describe any alternatives you've considered

A workaround would be to list all other networks on onlynet, e.g. if there is connectivity to IPv4 and I2P, use -onlynet=ipv4 -onlynet=i2p.

Please leave any additional context

Inspired by #27213 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions