Currently, -onlynet
does not work well in connection with initial peer discovery, because DNS seeds only resolve to IPv6 and IPv4 adresses:
With -onlynet=i2p
, we would load clearnet addresses from DNS seeds into addrman, be content our addrman isn’t empty so we don’t try to query hardcoded seeds (although these exist for i2p!), and never attempt to make an automatic outbound connection.
With -onlynet=onion
and -proxy
set, we wouldn’t load addresses via DNS, but will make AddrFetch connections (through a tor exit node) to a random clearnet peer the DNS seed resolves to (see #6808 (comment)), thus breaching the -onlynet
preference of the user - this has been reported in the two issues listed below.
This PR proposes two changes:
1.) Don’t load addresses that are unreachable (so that we wouldn’t connect to them) into addrman. This is already the case for addresses received via p2p addr messages, this PR implements the same for addresses received from DNS seeds and fixed seeds. This means that in the case of -onlynet=onion
, we wouldn’t load fixed seed IPv4 addresses into addrman, only the onion ones.
2.) Skip trying the DNS seeds if neither IPv4 nor IPv6 are reachable and move directly to adding the hardcoded seeds from networks we can connect to. This is done by soft-setting -dnsseed
to 0 in this case, unless -dnsseed=1
was explicitly specified, in which case we abort with an InitError
.