@@ -1561,16 +1561,23 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1561
1561
}
1562
1562
}
1563
1563
1564
+ // Check for host lookup allowed before parsing any network related parameters
1565
+ fNameLookup = GetBoolArg (" -dns" , DEFAULT_NAME_LOOKUP);
1566
+
1564
1567
bool proxyRandomize = GetBoolArg (" -proxyrandomize" , DEFAULT_PROXYRANDOMIZE);
1565
1568
// -proxy sets a proxy for all outgoing network traffic
1566
1569
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
1567
1570
std::string proxyArg = GetArg (" -proxy" , " " );
1568
1571
SetLimited (NET_TOR);
1569
1572
if (proxyArg != " " && proxyArg != " 0" ) {
1570
- CService resolved (LookupNumeric (proxyArg.c_str (), 9050 ));
1571
- proxyType addrProxy = proxyType (resolved, proxyRandomize);
1573
+ CService proxyAddr;
1574
+ if (!Lookup (proxyArg.c_str (), proxyAddr, 9050 , fNameLookup )) {
1575
+ return InitError (strprintf (_ (" Invalid -proxy address or hostname: '%s'" ), proxyArg));
1576
+ }
1577
+
1578
+ proxyType addrProxy = proxyType (proxyAddr, proxyRandomize);
1572
1579
if (!addrProxy.IsValid ())
1573
- return InitError (strprintf (_ (" Invalid -proxy address: '%s'" ), proxyArg));
1580
+ return InitError (strprintf (_ (" Invalid -proxy address or hostname : '%s'" ), proxyArg));
1574
1581
1575
1582
SetProxy (NET_IPV4, addrProxy);
1576
1583
SetProxy (NET_IPV6, addrProxy);
@@ -1587,10 +1594,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1587
1594
if (onionArg == " 0" ) { // Handle -noonion/-onion=0
1588
1595
SetLimited (NET_TOR); // set onions as unreachable
1589
1596
} else {
1590
- CService resolved (LookupNumeric (onionArg.c_str (), 9050 ));
1591
- proxyType addrOnion = proxyType (resolved, proxyRandomize);
1597
+ CService onionProxy;
1598
+ if (!Lookup (onionArg.c_str (), onionProxy, 9050 , fNameLookup )) {
1599
+ return InitError (strprintf (_ (" Invalid -onion address or hostname: '%s'" ), onionArg));
1600
+ }
1601
+ proxyType addrOnion = proxyType (onionProxy, proxyRandomize);
1592
1602
if (!addrOnion.IsValid ())
1593
- return InitError (strprintf (_ (" Invalid -onion address: '%s'" ), onionArg));
1603
+ return InitError (strprintf (_ (" Invalid -onion address or hostname : '%s'" ), onionArg));
1594
1604
SetProxy (NET_TOR, addrOnion);
1595
1605
SetLimited (NET_TOR, false );
1596
1606
}
@@ -1599,7 +1609,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1599
1609
// see Step 2: parameter interactions for more information about these
1600
1610
fListen = GetBoolArg (" -listen" , DEFAULT_LISTEN);
1601
1611
fDiscover = GetBoolArg (" -discover" , true );
1602
- fNameLookup = GetBoolArg (" -dns" , DEFAULT_NAME_LOOKUP);
1603
1612
fRelayTxes = !GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY);
1604
1613
1605
1614
if (fListen ) {
0 commit comments