…regardless of -onlynet.
-onlynet is documented to only affect automatic outbound connections (this naming is not ideal!), but it also currently prevents -externalip addresses from being advertised when their network isn’t in the -onlynet set, which will affect inbound behaviour/performance. This is because of the g_reachable_nets.Contains() check in AddLocal(), which rejects all addresses outside the reachable set, regardless of how they were specified.
Previous attempts to fix this (#24835 and #25690) both tried removal of the g_reachable_nets check from AddLocal(). A concern raised was that IsPeerAddrLocalGood() would also need adjusting for consistency. I am not sure this applies though, because -externalip sets fDiscover=false, so IsPeerAddrLocalGood() is short-circuited before its g_reachable_nets check is reached. In the -listenonion path (where fDiscover may be true), g_reachable_nets.Contains() still returns false for the excluded network, but this is correct — IsPeerAddrLocalGood() is checking whether to replace our “known” address with a peer’s claim, and there doesn’t seem any reason to override an address that tor control already knows?
In the approach in this changeset, instead of removing the check entirely, skip it only when nScore >= LOCAL_MANUAL. This limits the bypass to addresses explicitly provided by the user (-externalip, -torcontrol).
This also means that we would not advertise non-onlynet discovered addresses, only those which are manually specified, which I believe addresses #25690 (comment):
I think it might also be weird for a user to activate -onlynet and keep on advertising their clearnet address to the network
Fixes: #25336