When using -bind=0.0.0.0:port, the Discover() function was not being executed because the condition only checked bind_on_any. This fix modifies the condition to also check for any bind addresses that use 0.0.0.0 or ::.
The fix:
- Checks both bind_on_any and any bind addresses using IsBindAny()
- Ensures Discover() runs when binding to 0.0.0.0
- Maintains backward compatibility
- Updates test to use dynamic ports instead of hardcoded port
This PR differs from #31492 by:
- Preserving the semantic meaning of bind_on_any as defined in net.h: “True if the user did not specify -bind= or -whitebind= and thus we should bind on
0.0.0.0
(IPv4) and::
(IPv6)” - Using a simpler approach that checks IsBindAny() on bind addresses without modifying GetListenPort()
- Avoiding code duplication with DefaultOnionServiceTarget()
The implementation follows the approach I proposed in my review comment#31492:
Closes #31293