Use constants for the defaults of disableipv4/disableipv6 so the code and docs cannot be out of sync

This commit is contained in:
Duke
2025-02-12 17:23:48 -05:00
parent 85605737f0
commit 53cf574c03
2 changed files with 12 additions and 8 deletions

View File

@@ -429,8 +429,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-i2psam=<ip:port>", strprintf(_("I2P SAM proxy to reach I2P peers and accept I2P connections (default: none)")));
strUsage += HelpMessageOpt("-i2pacceptincoming", strprintf(_("If set and -i2psam is also set then incoming I2P connections are accepted via the SAM proxy. If this is not set but -i2psam is set then only outgoing connections will be made to the I2P network. Ignored if -i2psam is not set. Listening for incoming I2P connections is done through the SAM proxy, not by binding to a local address and port (default: 1)")));
strUsage += HelpMessageOpt("-onlynet=<net>", _("Only connect to nodes in network <net> (ipv4, ipv6, onion or i2p)"));
strUsage += HelpMessageOpt("-disableipv4", _("Disable Ipv4 network connections") + " " + _("(default: 0)"));
strUsage += HelpMessageOpt("-disableipv6", _("Disable Ipv6 network connections") + " " + _("(default: 0)"));
strUsage += HelpMessageOpt("-disableipv4", _("Disable Ipv4 network connections") + " " + strprintf(_("(default: %u)"), DEFAULT_DISABLE_IPV4));
strUsage += HelpMessageOpt("-disableipv6", _("Disable Ipv6 network connections") + " " + strprintf(_("(default: %u)"), DEFAULT_DISABLE_IPV6));
strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), 1));
strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with Bloom filters (default: %u)"), 1));
@@ -1134,13 +1134,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
}
//TODO: define a constant for the default of each of these that the CLI
//help also uses
if (GetBoolArg("-disableipv6", false)) {
if (GetBoolArg("-disableipv6", DEFAULT_DISABLE_IPV6)) {
SetReachable(NET_IPV6, false);
}
if (GetBoolArg("-disableipv4", false)) {
if (GetBoolArg("-disableipv4", DEFAULT_DISABLE_IPV4)) {
SetReachable(NET_IPV4, false);
}
@@ -1659,9 +1657,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE) {
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
} else if (net == NET_IPV4 && GetBoolArg("-disableipv4", false)) {
} else if (net == NET_IPV4 && GetBoolArg("-disableipv4", DEFAULT_DISABLE_IPV4)) {
return InitError(strprintf(_("-onlynet=ipv4 is incompatible with -disableipv4 !")));
} else if (net == NET_IPV6 && GetBoolArg("-disableipv6", false)) {
} else if (net == NET_IPV6 && GetBoolArg("-disableipv6", DEFAULT_DISABLE_IPV4)) {
return InitError(strprintf(_("-onlynet=ipv6 is incompatible with -disableipv6 !")));
}
nets.insert(net);