mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Merge 94d17845d0 into merged_master (Bitcoin PR bitcoin/bitcoin#24991)
This commit is contained in:
commit
74fbf6f59a
2 changed files with 27 additions and 10 deletions
16
src/init.cpp
16
src/init.cpp
|
|
@ -1463,6 +1463,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
onion_proxy = addrProxy;
|
||||
}
|
||||
|
||||
const bool onlynet_used_with_onion{args.IsArgSet("-onlynet") && IsReachable(NET_ONION)};
|
||||
|
||||
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
|
||||
// -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 to -proxy set above, or none)
|
||||
|
|
@ -1470,6 +1472,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
if (onionArg != "") {
|
||||
if (onionArg == "0") { // Handle -noonion/-onion=0
|
||||
onion_proxy = Proxy{};
|
||||
if (onlynet_used_with_onion) {
|
||||
return InitError(
|
||||
_("Outbound connections restricted to Tor (-onlynet=onion) but the proxy for "
|
||||
"reaching the Tor network is explicitly forbidden: -onion=0"));
|
||||
}
|
||||
} else {
|
||||
CService addr;
|
||||
if (!Lookup(onionArg, addr, 9050, fNameLookup) || !addr.IsValid()) {
|
||||
|
|
@ -1482,11 +1489,14 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
if (onion_proxy.IsValid()) {
|
||||
SetProxy(NET_ONION, onion_proxy);
|
||||
} else {
|
||||
if (args.IsArgSet("-onlynet") && IsReachable(NET_ONION)) {
|
||||
// If -listenonion is set, then we will (try to) connect to the Tor control port
|
||||
// later from the torcontrol thread and may retrieve the onion proxy from there.
|
||||
const bool listenonion_disabled{!args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)};
|
||||
if (onlynet_used_with_onion && listenonion_disabled) {
|
||||
return InitError(
|
||||
_("Outbound connections restricted to Tor (-onlynet=onion) but the proxy for "
|
||||
"reaching the Tor network is not provided (no -proxy= and no -onion= given) or "
|
||||
"it is explicitly forbidden (-onion=0)"));
|
||||
"reaching the Tor network is not provided: none of -proxy, -onion or "
|
||||
"-listenonion is given"));
|
||||
}
|
||||
SetReachable(NET_ONION, false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue