@@ -1248,16 +1248,23 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1248
1248
}
1249
1249
}
1250
1250
1251
+ // Check for host lookup allowed before parsing any network related parameters
1252
+ fNameLookup = GetBoolArg (" -dns" , DEFAULT_NAME_LOOKUP);
1253
+
1251
1254
bool proxyRandomize = GetBoolArg (" -proxyrandomize" , DEFAULT_PROXYRANDOMIZE);
1252
1255
// -proxy sets a proxy for all outgoing network traffic
1253
1256
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
1254
1257
std::string proxyArg = GetArg (" -proxy" , " " );
1255
1258
SetLimited (NET_TOR);
1256
1259
if (proxyArg != " " && proxyArg != " 0" ) {
1257
- CService resolved (LookupNumeric (proxyArg.c_str (), 9050 ));
1258
- proxyType addrProxy = proxyType (resolved, proxyRandomize);
1260
+ CService proxyAddr;
1261
+ if (!Lookup (proxyArg.c_str (), proxyAddr, 9050 , fNameLookup )) {
1262
+ return InitError (strprintf (_ (" Invalid -proxy address or hostname: '%s'" ), proxyArg));
1263
+ }
1264
+
1265
+ proxyType addrProxy = proxyType (proxyAddr, proxyRandomize);
1259
1266
if (!addrProxy.IsValid ())
1260
- return InitError (strprintf (_ (" Invalid -proxy address: '%s'" ), proxyArg));
1267
+ return InitError (strprintf (_ (" Invalid -proxy address or hostname : '%s'" ), proxyArg));
1261
1268
1262
1269
SetProxy (NET_IPV4, addrProxy);
1263
1270
SetProxy (NET_IPV6, addrProxy);
@@ -1274,10 +1281,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1274
1281
if (onionArg == " 0" ) { // Handle -noonion/-onion=0
1275
1282
SetLimited (NET_TOR); // set onions as unreachable
1276
1283
} else {
1277
- CService resolved (LookupNumeric (onionArg.c_str (), 9050 ));
1278
- proxyType addrOnion = proxyType (resolved, proxyRandomize);
1284
+ CService onionProxy;
1285
+ if (!Lookup (onionArg.c_str (), onionProxy, 9050 , fNameLookup )) {
1286
+ return InitError (strprintf (_ (" Invalid -onion address or hostname: '%s'" ), onionArg));
1287
+ }
1288
+ proxyType addrOnion = proxyType (onionProxy, proxyRandomize);
1279
1289
if (!addrOnion.IsValid ())
1280
- return InitError (strprintf (_ (" Invalid -onion address: '%s'" ), onionArg));
1290
+ return InitError (strprintf (_ (" Invalid -onion address or hostname : '%s'" ), onionArg));
1281
1291
SetProxy (NET_TOR, addrOnion);
1282
1292
SetLimited (NET_TOR, false );
1283
1293
}
@@ -1286,7 +1296,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1286
1296
// see Step 2: parameter interactions for more information about these
1287
1297
fListen = GetBoolArg (" -listen" , DEFAULT_LISTEN);
1288
1298
fDiscover = GetBoolArg (" -discover" , true );
1289
- fNameLookup = GetBoolArg (" -dns" , DEFAULT_NAME_LOOKUP);
1290
1299
fRelayTxes = !GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY);
1291
1300
1292
1301
if (fListen ) {
0 commit comments