net: Split resolving out of CService

This commit is contained in:
Cory Fields
2016-05-31 13:51:11 -04:00
committed by lateminer
parent e5dba2d293
commit 4de79a2a14
9 changed files with 94 additions and 101 deletions

View File

@@ -1108,7 +1108,9 @@ bool AppInit2(Config& config, boost::thread_group& threadGroup, CScheduler& sche
std::string proxyArg = GetArg("-proxy", "");
SetLimited(NET_TOR);
if (proxyArg != "" && proxyArg != "0") {
proxyType addrProxy = proxyType(CService(proxyArg, 9050), proxyRandomize);
CService resolved;
LookupNumeric(proxyArg.c_str(), resolved, 9050);
proxyType addrProxy = proxyType(resolved, proxyRandomize);
if (!addrProxy.IsValid())
return InitError(strprintf(_("Invalid -proxy address: '%s'"), proxyArg));
@@ -1127,7 +1129,9 @@ bool AppInit2(Config& config, boost::thread_group& threadGroup, CScheduler& sche
if (onionArg == "0") { // Handle -noonion/-onion=0
SetLimited(NET_TOR); // set onions as unreachable
} else {
proxyType addrOnion = proxyType(CService(onionArg, 9050), proxyRandomize);
CService resolved;
LookupNumeric(onionArg.c_str(), resolved, 9050);
proxyType addrOnion = proxyType(resolved, proxyRandomize);
if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -onion address: '%s'"), onionArg));
SetProxy(NET_TOR, addrOnion);