aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorbrunoerg <brunoely.gc@gmail.com>2022-09-13 18:19:40 -0300
committerbrunoerg <brunoely.gc@gmail.com>2023-05-30 16:27:21 -0300
commitfb3e812277041f239b97b88689a5076796d75b9b (patch)
treebfaeb888b221b38215901edf332fe54bec7ec4fd /src/netbase.cpp
parent71300489af362c3fed4736de6bffab4d758b6a84 (diff)
p2p: return `CSubNet` in `LookupSubNet`
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 8f6f92ea7d..d66721f2f9 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -655,10 +655,12 @@ bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_
return true;
}
-bool LookupSubNet(const std::string& subnet_str, CSubNet& subnet_out)
+CSubNet LookupSubNet(const std::string& subnet_str)
{
+ CSubNet subnet;
+ assert(!subnet.IsValid());
if (!ContainsNoNUL(subnet_str)) {
- return false;
+ return subnet;
}
const size_t slash_pos{subnet_str.find_last_of('/')};
@@ -671,23 +673,21 @@ bool LookupSubNet(const std::string& subnet_str, CSubNet& subnet_out)
uint8_t netmask;
if (ParseUInt8(netmask_str, &netmask)) {
// Valid number; assume CIDR variable-length subnet masking.
- subnet_out = CSubNet{addr.value(), netmask};
- return subnet_out.IsValid();
+ subnet = CSubNet{addr.value(), netmask};
} else {
// Invalid number; try full netmask syntax. Never allow lookup for netmask.
const std::optional<CNetAddr> full_netmask{LookupHost(netmask_str, /*fAllowLookup=*/false)};
if (full_netmask.has_value()) {
- subnet_out = CSubNet{addr.value(), full_netmask.value()};
- return subnet_out.IsValid();
+ subnet = CSubNet{addr.value(), full_netmask.value()};
}
}
} else {
// Single IP subnet (<ipv4>/32 or <ipv6>/128).
- subnet_out = CSubNet{addr.value()};
- return subnet_out.IsValid();
+ subnet = CSubNet{addr.value()};
}
}
- return false;
+
+ return subnet;
}
void InterruptSocks5(bool interrupt)