Browse Source

Enable host lookups for -proxy and -onion parameters

* Extends -dns parameter (via fNameLookup) to control these two new
  parameters in addition to -addnode, -connect, and -seednode

* Moves fNameLookup assignment earlier as needed

* Changes -proxy and -onion to use Lookup() instead of LookupNumeric()
0.15
Johnathan Corgan 8 years ago
parent
commit
f36bdf02ce
  1. 23
      src/init.cpp

23
src/init.cpp

@ -1248,16 +1248,23 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
} }
// Check for host lookup allowed before parsing any network related parameters
fNameLookup = GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
bool proxyRandomize = GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE); bool proxyRandomize = GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
// -proxy sets a proxy for all outgoing network traffic // -proxy sets a proxy for all outgoing network traffic
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default // -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
std::string proxyArg = GetArg("-proxy", ""); std::string proxyArg = GetArg("-proxy", "");
SetLimited(NET_TOR); SetLimited(NET_TOR);
if (proxyArg != "" && proxyArg != "0") { if (proxyArg != "" && proxyArg != "0") {
CService resolved(LookupNumeric(proxyArg.c_str(), 9050)); CService proxyAddr;
proxyType addrProxy = proxyType(resolved, proxyRandomize); if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) {
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
}
proxyType addrProxy = proxyType(proxyAddr, proxyRandomize);
if (!addrProxy.IsValid()) if (!addrProxy.IsValid())
return InitError(strprintf(_("Invalid -proxy address: '%s'"), proxyArg)); return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
SetProxy(NET_IPV4, addrProxy); SetProxy(NET_IPV4, addrProxy);
SetProxy(NET_IPV6, addrProxy); SetProxy(NET_IPV6, addrProxy);
@ -1274,10 +1281,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
if (onionArg == "0") { // Handle -noonion/-onion=0 if (onionArg == "0") { // Handle -noonion/-onion=0
SetLimited(NET_TOR); // set onions as unreachable SetLimited(NET_TOR); // set onions as unreachable
} else { } else {
CService resolved(LookupNumeric(onionArg.c_str(), 9050)); CService onionProxy;
proxyType addrOnion = proxyType(resolved, proxyRandomize); if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) {
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
}
proxyType addrOnion = proxyType(onionProxy, proxyRandomize);
if (!addrOnion.IsValid()) if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -onion address: '%s'"), onionArg)); return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
SetProxy(NET_TOR, addrOnion); SetProxy(NET_TOR, addrOnion);
SetLimited(NET_TOR, false); SetLimited(NET_TOR, false);
} }
@ -1286,7 +1296,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// see Step 2: parameter interactions for more information about these // see Step 2: parameter interactions for more information about these
fListen = GetBoolArg("-listen", DEFAULT_LISTEN); fListen = GetBoolArg("-listen", DEFAULT_LISTEN);
fDiscover = GetBoolArg("-discover", true); fDiscover = GetBoolArg("-discover", true);
fNameLookup = GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
fRelayTxes = !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); fRelayTxes = !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
if (fListen) { if (fListen) {

Loading…
Cancel
Save