Fix for #270 to allow subnets

This seems to work as expected and allows CIDR, subnet, and single IP while rejecting IPs out of range.
This commit is contained in:
fekt
2023-02-18 17:30:33 +00:00
parent fb250487c8
commit 883e598994

View File

@@ -123,10 +123,8 @@ namespace { // better to use anonymous namespace for helper routines
if (mapMultiArgs.count("-stratumallowip")) {
const std::vector<std::string>& vAllow = mapMultiArgs["-stratumallowip"];
for(const std::string& strAllow : vAllow) {
CNetAddr netaddr;
// todo: v6
LookupHost(strAllow.c_str(), netaddr, false);
CSubNet subnet(netaddr);
CSubNet subnet;
LookupSubNet(strAllow.c_str(), subnet);
if (!subnet.IsValid()) {
uiInterface.ThreadSafeMessageBox(
strprintf("Invalid -stratumallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).", strAllow),