Skip to content

Commit a381374

Browse files
Jadijadijadi
authored andcommitted
net: do not advertise address where nobody is listening
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 bitcoin#20657
1 parent 01bb3af commit a381374

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/init.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,11 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10471047
return InitError(Untranslated("Cannot set -bind or -whitebind together with -listen=0"));
10481048
}
10491049

1050+
// if listen=0, then disallow listenonion=1
1051+
if (!args.GetBoolArg("-listen", DEFAULT_LISTEN) && args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) {
1052+
return InitError(Untranslated("Cannot set -listen=0 together with -listenonion=1"));
1053+
}
1054+
10501055
// Make sure enough file descriptors are available
10511056
int nBind = std::max(nUserBind, size_t(1));
10521057
nUserMaxConnections = args.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);

0 commit comments

Comments
 (0)