Skip to content

Commit 8aa6178

Browse files
committed
Merge #20003: net: Exit with error message if -proxy is specified 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
2 parents d82b2c6 + 9b4fa0a commit 8aa6178

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/init.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,10 @@ bool AppInitParameterInteraction(const ArgsManager& args)
11921192

11931193
nMaxTipAge = args.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
11941194

1195+
if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "").empty()) {
1196+
return InitError(_("No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
1197+
}
1198+
11951199
return true;
11961200
}
11971201

test/functional/feature_config_args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ def test_config_file_parser(self):
7878
with open(inc_conf_file2_path, 'w', encoding='utf-8') as conf:
7979
conf.write('') # clear
8080

81+
def test_invalid_command_line_options(self):
82+
self.nodes[0].assert_start_raises_init_error(
83+
expected_msg='Error: No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>.',
84+
extra_args=['-proxy'],
85+
)
86+
8187
def test_log_buffer(self):
8288
with self.nodes[0].assert_debug_log(expected_msgs=['Warning: parsed potentially confusing double-negative -connect=0\n']):
8389
self.start_node(0, extra_args=['-noconnect=0'])
@@ -146,6 +152,7 @@ def run_test(self):
146152
self.test_networkactive()
147153

148154
self.test_config_file_parser()
155+
self.test_invalid_command_line_options()
149156

150157
# Remove the -datadir argument so it doesn't override the config file
151158
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]

0 commit comments

Comments
 (0)