@@ -1266,16 +1266,23 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1266
1266
}
1267
1267
}
1268
1268
1269
+ // Check for host lookup allowed before parsing any network related parameters
1270
+ fNameLookup = GetBoolArg (" -dns" , DEFAULT_NAME_LOOKUP);
1271
+
1269
1272
bool proxyRandomize = GetBoolArg (" -proxyrandomize" , DEFAULT_PROXYRANDOMIZE);
1270
1273
// -proxy sets a proxy for all outgoing network traffic
1271
1274
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
1272
1275
std::string proxyArg = GetArg (" -proxy" , " " );
1273
1276
SetLimited (NET_TOR);
1274
1277
if (proxyArg != " " && proxyArg != " 0" ) {
1275
- CService resolved (LookupNumeric (proxyArg.c_str (), 9050 ));
1276
- proxyType addrProxy = proxyType (resolved, proxyRandomize);
1278
+ CService proxyAddr;
1279
+ if (!Lookup (proxyArg.c_str (), proxyAddr, 9050 , fNameLookup )) {
1280
+ return InitError (strprintf (_ (" Invalid -proxy address or hostname: '%s'" ), proxyArg));
1281
+ }
1282
+
1283
+ proxyType addrProxy = proxyType (proxyAddr, proxyRandomize);
1277
1284
if (!addrProxy.IsValid ())
1278
- return InitError (strprintf (_ (" Invalid -proxy address: '%s'" ), proxyArg));
1285
+ return InitError (strprintf (_ (" Invalid -proxy address or hostname : '%s'" ), proxyArg));
1279
1286
1280
1287
SetProxy (NET_IPV4, addrProxy);
1281
1288
SetProxy (NET_IPV6, addrProxy);
@@ -1292,10 +1299,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1292
1299
if (onionArg == " 0" ) { // Handle -noonion/-onion=0
1293
1300
SetLimited (NET_TOR); // set onions as unreachable
1294
1301
} else {
1295
- CService resolved (LookupNumeric (onionArg.c_str (), 9050 ));
1296
- proxyType addrOnion = proxyType (resolved, proxyRandomize);
1302
+ CService onionProxy;
1303
+ if (!Lookup (onionArg.c_str (), onionProxy, 9050 , fNameLookup )) {
1304
+ return InitError (strprintf (_ (" Invalid -onion address or hostname: '%s'" ), onionArg));
1305
+ }
1306
+ proxyType addrOnion = proxyType (onionProxy, proxyRandomize);
1297
1307
if (!addrOnion.IsValid ())
1298
- return InitError (strprintf (_ (" Invalid -onion address: '%s'" ), onionArg));
1308
+ return InitError (strprintf (_ (" Invalid -onion address or hostname : '%s'" ), onionArg));
1299
1309
SetProxy (NET_TOR, addrOnion);
1300
1310
SetLimited (NET_TOR, false );
1301
1311
}
@@ -1304,7 +1314,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1304
1314
// see Step 2: parameter interactions for more information about these
1305
1315
fListen = GetBoolArg (" -listen" , DEFAULT_LISTEN);
1306
1316
fDiscover = GetBoolArg (" -discover" , true );
1307
- fNameLookup = GetBoolArg (" -dns" , DEFAULT_NAME_LOOKUP);
1308
1317
fRelayTxes = !GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY);
1309
1318
1310
1319
if (fListen ) {
0 commit comments