Skip to content

Commit 9b4fa0a

Browse files
net: Print error message if -proxy is specified without arguments (instead of continuing without proxy server)
1 parent 9e217f5 commit 9b4fa0a

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
@@ -1176,6 +1176,10 @@ bool AppInitParameterInteraction(const ArgsManager& args)
11761176

11771177
nMaxTipAge = args.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
11781178

1179+
if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "").empty()) {
1180+
return InitError(_("No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
1181+
}
1182+
11791183
return true;
11801184
}
11811185

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)