@@ -1902,6 +1902,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19021902
19031903 const uint16_t default_bind_port_onion = default_bind_port + 1 ;
19041904
1905+ // If the user did not specify -bind= or -whitebind= then we bind
1906+ // on any address - 0.0.0.0 (IPv4) and :: (IPv6).
1907+ connOptions.bind_on_any = args.GetArgs (" -bind" ).empty () && args.GetArgs (" -whitebind" ).empty ();
1908+
19051909 const auto BadPortWarning = [](const char * prefix, uint16_t port) {
19061910 return strprintf (_ (" %s request to listen on port %u. This port is considered \" bad\" and "
19071911 " thus it is unlikely that any peer will connect to it. See "
@@ -1916,6 +1920,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19161920 if (index == std::string::npos) {
19171921 bind_addr = Lookup (bind_arg, default_bind_port, /* fAllowLookup=*/ false );
19181922 if (bind_addr.has_value ()) {
1923+ connOptions.bind_on_any |= bind_addr.value ().IsBindAny ();
19191924 connOptions.vBinds .push_back (bind_addr.value ());
19201925 if (IsBadPort (bind_addr.value ().GetPort ())) {
19211926 InitWarning (BadPortWarning (" -bind" , bind_addr.value ().GetPort ()));
@@ -1928,6 +1933,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19281933 const std::string truncated_bind_arg = bind_arg.substr (0 , index);
19291934 bind_addr = Lookup (truncated_bind_arg, default_bind_port_onion, false );
19301935 if (bind_addr.has_value ()) {
1936+ connOptions.bind_on_any |= bind_addr.value ().IsBindAny ();
19311937 connOptions.onion_binds .push_back (bind_addr.value ());
19321938 continue ;
19331939 }
@@ -1943,10 +1949,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19431949 connOptions.vWhiteBinds .push_back (whitebind);
19441950 }
19451951
1946- // If the user did not specify -bind= or -whitebind= then we bind
1947- // on any address - 0.0.0.0 (IPv4) and :: (IPv6).
1948- connOptions.bind_on_any = args.GetArgs (" -bind" ).empty () && args.GetArgs (" -whitebind" ).empty ();
1949-
19501952 // Emit a warning if a bad port is given to -port= but only if -bind and -whitebind are not
19511953 // given, because if they are, then -port= is ignored.
19521954 if (connOptions.bind_on_any && args.IsArgSet (" -port" )) {
@@ -1963,7 +1965,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19631965 onion_service_target = connOptions.vBinds .front ();
19641966 } else {
19651967 onion_service_target = DefaultOnionServiceTarget (default_bind_port_onion);
1966- connOptions.onion_binds .push_back (onion_service_target);
19671968 }
19681969
19691970 if (args.GetBoolArg (" -listenonion" , DEFAULT_LISTEN_ONION)) {
0 commit comments