Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common: Disallow calling IsArgSet() on ALLOW_LIST options #17783

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
20a9986
common: Grammar / formatting tweaks
ryanofsky Sep 25, 2024
30385f2
doc: Add detailed ArgsManager type flag documention
ryanofsky Jul 30, 2024
a7a35ed
common: Implement ArgsManager flags to parse and validate settings on…
ryanofsky Aug 4, 2019
225ab2b
common: Update ArgManager GetArg helper methods to work better with A…
ryanofsky Sep 21, 2022
350c715
test: Add tests to demonstrate usage of ArgsManager flags
ryanofsky Jul 30, 2024
b5ef854
test: Add test for settings.json parsing with type flags
ryanofsky Jun 5, 2024
afaf226
Merge remote-tracking branch 'origin/pull/16545/head'
ryanofsky Dec 5, 2024
f6d6383
test: Add test to make sure -noconnect disables -dnsseed and -listen …
ryanofsky Jul 29, 2024
da3bdd5
common: Add support for combining ArgsManager flags
ryanofsky Aug 19, 2024
0a954ce
refactor: Clarify handling of -noconnect option
ryanofsky Dec 19, 2019
603423e
scripted-diff: Add ALLOW_LIST flag to arguments retrieved with GetArgs
ryanofsky Nov 15, 2019
f6c966e
refactor: Clarify handling of -nodebug option
ryanofsky Dec 19, 2019
8f6aa85
refactor: Fix more ALLOW_LIST arguments
ryanofsky Nov 15, 2019
594acdb
Fix nonsensical -norpcwhitelist, -norpcallowip and related behavior
ryanofsky Dec 19, 2019
7a75635
Always reject empty -blockfilterindex="" arguments
ryanofsky Sep 22, 2022
54ad580
Fix nonsensical bitcoin-cli -norpcwallet behavior
ryanofsky Dec 19, 2019
d2edef6
refactor: Always enforce ALLOW_LIST in CheckArgFlags
ryanofsky Jul 19, 2024
f173d66
Merge remote-tracking branch 'origin/pull/30529/head'
ryanofsky Dec 5, 2024
f5aa87f
Merge remote-tracking branch 'origin/pull/17580/head'
ryanofsky Dec 5, 2024
e74d730
common: Disallow calling IsArgSet() on ALLOW_LIST options
ryanofsky Dec 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Clarify handling of -noconnect option
Handle -noconnect setting explicity with IsArgNegated() function instead of
implicitly with IsArgSet() and add comments so it is clearer what the code is
trying to do when -noconnect is specified.

This commit is a refactoring does not change behavior. Test coverage for this
behavior was added in the previous commit.

Not sure if it really makes sense not to warn about seednode being ignored if
-noconnect is specified, and only to warn about -dnsseed being ignored when
-proxy is specified, but these behaviors are not changed from before.
  • Loading branch information
ryanofsky committed Dec 5, 2024
commit 0a954ce80cf9d9744eaf213e3b81d4016b19bf88
13 changes: 8 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,9 @@ void InitParameterInteraction(ArgsManager& args)
LogInfo("parameter interaction: -whitebind set -> setting -listen=1\n");
}

if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
if (!args.GetArgs("-connect").empty() || args.IsArgNegated("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
// do the same when connections are disabled
if (args.SoftSetBoolArg("-dnsseed", false))
LogInfo("parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n");
if (args.SoftSetBoolArg("-listen", false))
Expand Down Expand Up @@ -1942,10 +1943,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)

connOptions.vSeedNodes = args.GetArgs("-seednode");

// Initiate outbound connections unless connect=0
connOptions.m_use_addrman_outgoing = !args.IsArgSet("-connect");
if (!connOptions.m_use_addrman_outgoing) {
const auto connect = args.GetArgs("-connect");
const auto connect = args.GetArgs("-connect");
if (!connect.empty() || args.IsArgNegated("-connect")) {
// Do not initiate other outgoing connections when connecting to trusted
// nodes, or when -noconnect is specified.
connOptions.m_use_addrman_outgoing = false;

if (connect.size() != 1 || connect[0] != "0") {
connOptions.m_specified_outgoing = connect;
}
Expand Down