Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,888 Lines • ▼ Show 20 Lines | #endif | ||||
fNameLookup = gArgs.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP); | fNameLookup = gArgs.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP); | ||||
bool proxyRandomize = | bool proxyRandomize = | ||||
gArgs.GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE); | gArgs.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 | // -noproxy (or -proxy=0) as well as the empty string can be used to not set | ||||
// a proxy, this is the default | // a proxy, this is the default | ||||
std::string proxyArg = gArgs.GetArg("-proxy", ""); | std::string proxyArg = gArgs.GetArg("-proxy", ""); | ||||
SetLimited(NET_TOR); | SetLimited(NET_ONION); | ||||
if (proxyArg != "" && proxyArg != "0") { | if (proxyArg != "" && proxyArg != "0") { | ||||
CService proxyAddr; | CService proxyAddr; | ||||
if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) { | if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Invalid -proxy address or hostname: '%s'"), proxyArg)); | _("Invalid -proxy address or hostname: '%s'"), proxyArg)); | ||||
} | } | ||||
proxyType addrProxy = proxyType(proxyAddr, proxyRandomize); | proxyType addrProxy = proxyType(proxyAddr, proxyRandomize); | ||||
if (!addrProxy.IsValid()) { | if (!addrProxy.IsValid()) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Invalid -proxy address or hostname: '%s'"), proxyArg)); | _("Invalid -proxy address or hostname: '%s'"), proxyArg)); | ||||
} | } | ||||
SetProxy(NET_IPV4, addrProxy); | SetProxy(NET_IPV4, addrProxy); | ||||
SetProxy(NET_IPV6, addrProxy); | SetProxy(NET_IPV6, addrProxy); | ||||
SetProxy(NET_TOR, addrProxy); | SetProxy(NET_ONION, addrProxy); | ||||
SetNameProxy(addrProxy); | SetNameProxy(addrProxy); | ||||
// by default, -proxy sets onion as reachable, unless -noonion later | // by default, -proxy sets onion as reachable, unless -noonion later | ||||
SetLimited(NET_TOR, false); | SetLimited(NET_ONION, false); | ||||
} | } | ||||
// -onion can be used to set only a proxy for .onion, or override normal | // -onion can be used to set only a proxy for .onion, or override normal | ||||
// proxy for .onion addresses. | // proxy for .onion addresses. | ||||
// -noonion (or -onion=0) disables connecting to .onion entirely. An empty | // -noonion (or -onion=0) disables connecting to .onion entirely. An empty | ||||
// string is used to not override the onion proxy (in which case it defaults | // string is used to not override the onion proxy (in which case it defaults | ||||
// to -proxy set above, or none) | // to -proxy set above, or none) | ||||
std::string onionArg = gArgs.GetArg("-onion", ""); | std::string onionArg = gArgs.GetArg("-onion", ""); | ||||
if (onionArg != "") { | if (onionArg != "") { | ||||
if (onionArg == "0") { // Handle -noonion/-onion=0 | if (onionArg == "0") { // Handle -noonion/-onion=0 | ||||
SetLimited(NET_TOR); // set onions as unreachable | SetLimited(NET_ONION); // set onions as unreachable | ||||
} else { | } else { | ||||
CService onionProxy; | CService onionProxy; | ||||
if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) { | if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Invalid -onion address or hostname: '%s'"), onionArg)); | _("Invalid -onion address or hostname: '%s'"), onionArg)); | ||||
} | } | ||||
proxyType addrOnion = proxyType(onionProxy, proxyRandomize); | proxyType addrOnion = proxyType(onionProxy, proxyRandomize); | ||||
if (!addrOnion.IsValid()) { | if (!addrOnion.IsValid()) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Invalid -onion address or hostname: '%s'"), onionArg)); | _("Invalid -onion address or hostname: '%s'"), onionArg)); | ||||
} | } | ||||
SetProxy(NET_TOR, addrOnion); | SetProxy(NET_ONION, addrOnion); | ||||
SetLimited(NET_TOR, false); | SetLimited(NET_ONION, false); | ||||
} | } | ||||
} | } | ||||
// see Step 2: parameter interactions for more information about these | // see Step 2: parameter interactions for more information about these | ||||
fListen = gArgs.GetBoolArg("-listen", DEFAULT_LISTEN); | fListen = gArgs.GetBoolArg("-listen", DEFAULT_LISTEN); | ||||
fDiscover = gArgs.GetBoolArg("-discover", true); | fDiscover = gArgs.GetBoolArg("-discover", true); | ||||
fRelayTxes = !gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); | fRelayTxes = !gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); | ||||
▲ Show 20 Lines • Show All 427 Lines • Show Last 20 Lines |