Make -disableipv4/-disableipv6 do something useful

This commit is contained in:
Duke
2025-02-12 13:38:53 -05:00
parent 46e6faa6fb
commit f98c34be1c

View File

@@ -1134,6 +1134,16 @@ 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)) {
SetReachable(NET_IPV6, false);
}
if (GetBoolArg("-disableipv4", false)) {
SetReachable(NET_IPV4, false);
}
// Read asmap file by default for HUSH3 and all Hush Arrakis Chains
if (GetArg("-asmap",1)) {
fs::path asmap_path = fs::path(GetArg("-asmap", ""));
@@ -1647,8 +1657,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
std::set<enum Network> nets;
BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) {
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
if (net == NET_UNROUTABLE) {
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
} else if (net == NET_IPV4 && GetBoolArg("-disableipv4", false)) {
return InitError(strprintf(_("-onlynet=ipv4 is incompatible with -disableipv4 !"), snet));
} else if (net == NET_IPV6 && GetBoolArg("-disableipv6", false)) {
return InitError(strprintf(_("-onlynet=ipv6 is incompatible with -disableipv6 !"), snet));
}
nets.insert(net);
}
for (int n = 0; n < NET_MAX; n++) {