mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Merge e53310c47a into merged_master (Bitcoin PR bitcoin/bitcoin#30529)
This commit is contained in:
commit
b9a1c93e74
13 changed files with 96 additions and 42 deletions
44
src/init.cpp
44
src/init.cpp
|
|
@ -779,17 +779,18 @@ void InitParameterInteraction(ArgsManager& args)
|
|||
{
|
||||
// when specifying an explicit binding address, you want to listen on it
|
||||
// even when -connect or -proxy is specified
|
||||
if (args.IsArgSet("-bind")) {
|
||||
if (!args.GetArgs("-bind").empty()) {
|
||||
if (args.SoftSetBoolArg("-listen", true))
|
||||
LogInfo("parameter interaction: -bind set -> setting -listen=1\n");
|
||||
}
|
||||
if (args.IsArgSet("-whitebind")) {
|
||||
if (!args.GetArgs("-whitebind").empty()) {
|
||||
if (args.SoftSetBoolArg("-listen", true))
|
||||
LogInfo("parameter interaction: -whitebind set -> setting -listen=1\n");
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
|
||||
if (!args.GetArgs("-connect").empty() || args.IsArgNegated("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
|
||||
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
||||
// do the same when connections are disabled
|
||||
if (args.SoftSetBoolArg("-dnsseed", false))
|
||||
LogInfo("parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n");
|
||||
if (args.SoftSetBoolArg("-listen", false))
|
||||
|
|
@ -825,7 +826,7 @@ void InitParameterInteraction(ArgsManager& args)
|
|||
}
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-externalip")) {
|
||||
if (!args.GetArgs("-externalip").empty()) {
|
||||
// if an explicit public IP is specified, do not try to find others
|
||||
if (args.SoftSetBoolArg("-discover", false))
|
||||
LogInfo("parameter interaction: -externalip set -> setting -discover=0\n");
|
||||
|
|
@ -845,8 +846,8 @@ void InitParameterInteraction(ArgsManager& args)
|
|||
if (args.SoftSetBoolArg("-whitelistrelay", true))
|
||||
LogInfo("parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n");
|
||||
}
|
||||
if (args.IsArgSet("-onlynet")) {
|
||||
const auto onlynets = args.GetArgs("-onlynet");
|
||||
const auto onlynets = args.GetArgs("-onlynet");
|
||||
if (!onlynets.empty()) {
|
||||
bool clearnet_reachable = std::any_of(onlynets.begin(), onlynets.end(), [](const auto& net) {
|
||||
const auto n = ParseNetwork(net);
|
||||
return n == NET_IPV4 || n == NET_IPV6;
|
||||
|
|
@ -1125,13 +1126,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
|||
} catch (const std::exception& e) {
|
||||
return InitError(Untranslated(strprintf("Error in -assetdir: %s\n", e.what())));
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-test")) {
|
||||
|
||||
const std::vector<std::string> test_options = args.GetArgs("-test");
|
||||
if (!test_options.empty()) {
|
||||
if (chainparams.GetChainTypeMeta().chain_type != ChainType::REGTEST && chainparams.GetChainTypeMeta().chain_type != ChainType::CUSTOM) {
|
||||
return InitError(Untranslated("-test=<option> can only be used with regtest"));
|
||||
}
|
||||
const std::vector<std::string> options = args.GetArgs("-test");
|
||||
for (const std::string& option : options) {
|
||||
for (const std::string& option : test_options) {
|
||||
auto it = std::find_if(TEST_OPTIONS_DOC.begin(), TEST_OPTIONS_DOC.end(), [&option](const std::string& doc_option) {
|
||||
size_t pos = doc_option.find(" (");
|
||||
return (pos != std::string::npos) && (doc_option.substr(0, pos) == option);
|
||||
|
|
@ -1588,7 +1589,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
|
||||
// Read asmap file if configured
|
||||
std::vector<bool> asmap;
|
||||
if (args.IsArgSet("-asmap")) {
|
||||
if (args.IsArgSet("-asmap") && !args.IsArgNegated("-asmap")) {
|
||||
fs::path asmap_path = args.GetPathArg("-asmap", DEFAULT_ASMAP_FILENAME);
|
||||
if (!asmap_path.is_absolute()) {
|
||||
asmap_path = args.GetDataDirNet() / asmap_path;
|
||||
|
|
@ -1666,9 +1667,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-onlynet")) {
|
||||
const auto onlynets = args.GetArgs("-onlynet");
|
||||
if (!onlynets.empty()) {
|
||||
g_reachable_nets.RemoveAll();
|
||||
for (const std::string& snet : args.GetArgs("-onlynet")) {
|
||||
for (const std::string& snet : onlynets) {
|
||||
enum Network net = ParseNetwork(snet);
|
||||
if (net == NET_UNROUTABLE)
|
||||
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
|
||||
|
|
@ -1677,7 +1679,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
}
|
||||
|
||||
if (!args.IsArgSet("-cjdnsreachable")) {
|
||||
if (args.IsArgSet("-onlynet") && g_reachable_nets.Contains(NET_CJDNS)) {
|
||||
if (!onlynets.empty() && g_reachable_nets.Contains(NET_CJDNS)) {
|
||||
return InitError(
|
||||
_("Outbound connections restricted to CJDNS (-onlynet=cjdns) but "
|
||||
"-cjdnsreachable is not provided"));
|
||||
|
|
@ -1728,7 +1730,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
onion_proxy = addrProxy;
|
||||
}
|
||||
|
||||
const bool onlynet_used_with_onion{args.IsArgSet("-onlynet") && g_reachable_nets.Contains(NET_ONION)};
|
||||
const bool onlynet_used_with_onion{!onlynets.empty() && g_reachable_nets.Contains(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
|
||||
|
|
@ -2150,10 +2152,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
|
||||
connOptions.vSeedNodes = args.GetArgs("-seednode");
|
||||
|
||||
// Initiate outbound connections unless connect=0
|
||||
connOptions.m_use_addrman_outgoing = !args.IsArgSet("-connect");
|
||||
if (!connOptions.m_use_addrman_outgoing) {
|
||||
const auto connect = args.GetArgs("-connect");
|
||||
const auto connect = args.GetArgs("-connect");
|
||||
if (!connect.empty() || args.IsArgNegated("-connect")) {
|
||||
// Do not initiate other outgoing connections when connecting to trusted
|
||||
// nodes, or when -noconnect is specified.
|
||||
connOptions.m_use_addrman_outgoing = false;
|
||||
|
||||
if (connect.size() != 1 || connect[0] != "0") {
|
||||
connOptions.m_specified_outgoing = connect;
|
||||
}
|
||||
|
|
@ -2174,7 +2178,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
}
|
||||
SetProxy(NET_I2P, Proxy{addr.value()});
|
||||
} else {
|
||||
if (args.IsArgSet("-onlynet") && g_reachable_nets.Contains(NET_I2P)) {
|
||||
if (!onlynets.empty() && g_reachable_nets.Contains(NET_I2P)) {
|
||||
return InitError(
|
||||
_("Outbound connections restricted to i2p (-onlynet=i2p) but "
|
||||
"-i2psam is not provided"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue