diff options
author | Andrew Chow <github@achow101.com> | 2023-03-20 12:43:17 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-03-20 12:49:10 -0400 |
commit | b7edd55c2204e9a2119c87884697091e8112800e (patch) | |
tree | 25b6371e2d5c9e15b7c75cdac6814b445c3ff1f4 | |
parent | 60f142e395171ab8b093a5dfae59a6a9761b38ab (diff) | |
parent | fabb95e7bf02f3d8e663a02dd845d42e09d330ec (diff) |
Merge bitcoin/bitcoin#26899: p2p: set `-dnsseed` and `-listen` false if `maxconnections=0`
fabb95e7bf02f3d8e663a02dd845d42e09d330ec doc: add release note for 26899 (brunoerg)
c84c5f6e89094749f90d7b0994278e50689e04dc p2p: set `-dnsseed` and `-listen` false if `maxconnections=0` (brunoerg)
Pull request description:
If `maxconnections=0`, it means our possible connections are going to be manual (e.g via `addnode`). For this reason, we can skip DNS seeds and set `listen` false.
ACKs for top commit:
achow101:
ACK fabb95e7bf02f3d8e663a02dd845d42e09d330ec
vasild:
ACK fabb95e7bf02f3d8e663a02dd845d42e09d330ec
1440000bytes:
reACK https://github.com/bitcoin/bitcoin/pull/26899/commits/fabb95e7bf02f3d8e663a02dd845d42e09d330ec
Tree-SHA512: 33919a784723a32450f39ee4f6de3e27cc7c7f4c6ab4b8ce673981d461df334197deaf43e3f882039fa1ac36b2fddc6c6ab4413512d6c393d4a6865302dd05e7
-rw-r--r-- | doc/release-notes-26899.md | 5 | ||||
-rw-r--r-- | src/init.cpp | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/doc/release-notes-26899.md b/doc/release-notes-26899.md new file mode 100644 index 0000000000..ceb9ec2f7a --- /dev/null +++ b/doc/release-notes-26899.md @@ -0,0 +1,5 @@ +Updated settings +---------------- + +- Setting `-maxconnections=0` will now disable `-dnsseed` + and `-listen` (users may still set them to override).
\ No newline at end of file diff --git a/src/init.cpp b/src/init.cpp index 8a45c38ce3..16909f7e47 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -472,11 +472,11 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-connect=<ip>", "Connect only to the specified node; -noconnect disables automatic connections (the rules for this peer are the same as for -addnode). This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION); argsman.AddArg("-discover", "Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-dns", strprintf("Allow DNS lookups for -addnode, -seednode and -connect (default: %u)", DEFAULT_NAME_LOOKUP), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); - argsman.AddArg("-dnsseed", strprintf("Query for peer addresses via DNS lookup, if low on addresses (default: %u unless -connect used)", DEFAULT_DNSSEED), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); + argsman.AddArg("-dnsseed", strprintf("Query for peer addresses via DNS lookup, if low on addresses (default: %u unless -connect used or -maxconnections=0)", DEFAULT_DNSSEED), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-externalip=<ip>", "Specify your own public address", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-fixedseeds", strprintf("Allow fixed seeds if DNS seeds don't provide peers (default: %u)", DEFAULT_FIXEDSEEDS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-forcednsseed", strprintf("Always query for peer addresses via DNS lookup (default: %u)", DEFAULT_FORCEDNSSEED), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); - argsman.AddArg("-listen", strprintf("Accept connections from outside (default: %u if no -proxy or -connect)", DEFAULT_LISTEN), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); + argsman.AddArg("-listen", strprintf("Accept connections from outside (default: %u if no -proxy, -connect or -maxconnections=0)", DEFAULT_LISTEN), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-listenonion", strprintf("Automatically create Tor onion service (default: %d)", DEFAULT_LISTEN_ONION), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-maxconnections=<n>", strprintf("Maintain at most <n> connections to peers (default: %u). This limit does not apply to connections manually added via -addnode or the addnode RPC, which have a separate limit of %u.", DEFAULT_MAX_PEER_CONNECTIONS, MAX_ADDNODE_CONNECTIONS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); argsman.AddArg("-maxreceivebuffer=<n>", strprintf("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXRECEIVEBUFFER), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); @@ -683,12 +683,12 @@ void InitParameterInteraction(ArgsManager& args) LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); } - if (args.IsArgSet("-connect")) { + if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default if (args.SoftSetBoolArg("-dnsseed", false)) - LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); + LogPrintf("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n", __func__); if (args.SoftSetBoolArg("-listen", false)) - LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__); + LogPrintf("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0\n", __func__); } std::string proxy_arg = args.GetArg("-proxy", ""); |