net: Exit with error message if -proxy is specified without arguments (instead of continuing without proxy server)#20003
Conversation
|
Thank you. Tested ACK 3bca86ae6b7cc5b2f5bb9ee4567052b34f613ba1. re-ACK 9b4fa0a |
|
We might want a functional test for this? This kind of parameter handling is easy to accidentally break when refactoring init, especially with fragments concerning the same parameters spread over the place. |
|
@laanwj Added :) |
|
Concept ACK. Testing... |
hebasto
left a comment
There was a problem hiding this comment.
Tested f3ee9bd29d22e32356edb2fa92eb62d229626c38 on Linux Mint 20 (x86_64).
nit:
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -456,7 +456,7 @@ void SetupServerArgs(NodeContext& node)
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet: %u, regtest: %u)", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
- argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
+ argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_STRING, OptionsCategory::CONNECTION);
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_BOOL, OptionsCategory::CONNECTION);f3ee9bd to
e40cecf
Compare
hebasto
left a comment
There was a problem hiding this comment.
ACK e40cecf2c6fc88fe39849c3f291abcd165be0f25
Why the test for the -proxy command line option is placed in test_config_file_parser functiion?
…stead of continuing without proxy server)
e40cecf to
9b4fa0a
Compare
That would break
Good point. Moved to newly introduced |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
No, we don't offer that kind of interaction in |
…ied without arguments (instead of continuing without proxy server) 9b4fa0a net: Print error message if -proxy is specified without arguments (instead of continuing without proxy server) (practicalswift) Pull request description: Exit with error message if `-proxy` is specified without arguments (instead of continuing without proxy server). Continuing without a proxy server when the end-user has specified `-proxy` may result in accidental loss of privacy. (The end-user might think he/she is using a proxy when he/she is not.) Before this patch: ``` $ src/bitcoind -proxy … 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -proxy set -> setting -listen=0 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -proxy set -> setting -upnp=0 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -proxy set -> setting -discover=0 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -listenonion=0 … 2020-09-23T00:24:33Z init message: Starting network threads... ``` `bitcoind` is now running *without* a proxy server (`GetProxy(…, …) == false`, `HaveNameProxy() == false`, etc.). Note that the "-proxy set" log messages above which the end-user might interpret as "good, my traffic is now routed via the proxy". After this patch: ``` $ src/bitcoind -proxy Error: No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>. $ echo $? 1 ``` ACKs for top commit: laanwj: re-ACK 9b4fa0a kristapsk: ACK 9b4fa0a, I have tested the code. hebasto: re-ACK 9b4fa0a Tree-SHA512: 4ba7a011991699a54b5bb87ec68367c681231bf5dcd36f8c89ff9ddc2e8d29df453817b7e362597e652ad6b341a22b7274be0fd78d435e5f0fd8058e5221c4ce
…stead of continuing without proxy server) Summary: This is a backport of [[bitcoin/bitcoin#20003 | core#20003]] Test Plan: `ninja && test/functional/test_runner.py feature_config_args` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10400
This drops the "No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>" error when "-noproxy" or "-proxy=" command line arguments are specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare "-proxy" argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking "-noproxy" and "-proxy=" arguments as well. The motivation for this change is actually to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message, and make parsing of the "-proxy" setting handling consistent within the InitParameterInteraction, AppInitParameterInteraction, and AppInitMain functions.
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
1d4122d init: Allow -proxy="" setting values (Ryan Ofsky) Pull request description: This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin/bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin/bitcoin#15936, reported in bitcoin/bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message. ACKs for top commit: hebasto: re-ACK 1d4122d, only rebased since my recent [review](bitcoin/bitcoin#24830 (review)). Tree-SHA512: 753adfce199ed078a6cd9e0ea78e76c0b14070f8fcfe2a4632cd0c6dfe6b4e135ddffbe11a97e5e30520ea9e5bda00bad1493cbaef74cf425aa8613249167f53
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin/bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin/bitcoin#15936, reported in bitcoin/bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
Exit with error message if
-proxyis specified without arguments (instead of continuing without proxy server).Continuing without a proxy server when the end-user has specified
-proxymay result in accidental loss of privacy. (The end-user might think he/she is using a proxy when he/she is not.)Before this patch:
bitcoindis now running without a proxy server (GetProxy(…, …) == false,HaveNameProxy() == false, etc.).Note that the "-proxy set" log messages above which the end-user might interpret as "good, my traffic is now routed via the proxy".
After this patch: