Merge bitcoin/bitcoin#20769: net: fixes #20657 - Advertised address where nobody is listening

a38137479b net: do not advertise address where nobody is listening (Jadi)

Pull request description:

  If the bitcoind starts when listen=0 but listenonion=1, the daemon will
  advertise its onion address but nothing is listening for it.

  This update will enforce listenonion=0 when the listen is 0.

ACKs for top commit:
  vasild:
    ACK a38137479b
  jarolrod:
    ACK a38137479b
  amitiuttarwar:
    ACK a38137479b

Tree-SHA512: e84a0a9a51f2217edf35d06c6cd9085d1e664452655ba92027195a1e88ba081d157310c84e9709a99ce5d46c94f231477ca2d36f010648b0c8b4f2a737d54e5d
This commit is contained in:
MarcoFalke 2021-08-23 09:01:05 +02:00
commit 58b559fab0
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -860,6 +860,11 @@ bool AppInitParameterInteraction(const ArgsManager& args)
return InitError(Untranslated("Cannot set -bind or -whitebind together with -listen=0"));
}
// if listen=0, then disallow listenonion=1
if (!args.GetBoolArg("-listen", DEFAULT_LISTEN) && args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) {
return InitError(Untranslated("Cannot set -listen=0 together with -listenonion=1"));
}
// Make sure enough file descriptors are available
int nBind = std::max(nUserBind, size_t(1));
nUserMaxConnections = args.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);