Skip to content

Commit

Permalink
net: do not advertise address where nobody is listening
Browse files Browse the repository at this point in the history
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.

fixes #20657
  • Loading branch information
Jadi authored and jadijadi committed Mar 16, 2021
1 parent 01bb3af commit a381374
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,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);
Expand Down

0 comments on commit a381374

Please sign in to comment.