1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

dont use std::optional

This commit is contained in:
Jeff Becker 2021-02-19 17:19:21 -05:00
parent 4478cf6f72
commit f7424b8bbe
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
2 changed files with 8 additions and 11 deletions

View file

@ -1022,19 +1022,16 @@ namespace llarp
bool
PeerSelectionConfig::Acceptable(const std::set<RouterContact>& rcs) const
{
if (m_UniqueHopsNetmaskSize)
const auto netmask = netmask_ipv6_bits(96 + m_UniqueHopsNetmaskSize);
std::set<IPRange> seenRanges;
for (const auto& hop : rcs)
{
const auto netmask = netmask_ipv6_bits(96 + *m_UniqueHopsNetmaskSize);
std::set<IPRange> seenRanges;
for (const auto& hop : rcs)
for (const auto& addr : hop.addrs)
{
for (const auto& addr : hop.addrs)
const auto network_addr = net::In6ToHUInt(addr.ip) & netmask;
if (auto [it, inserted] = seenRanges.emplace(network_addr, netmask); not inserted)
{
const auto network_addr = net::In6ToHUInt(addr.ip) & netmask;
if (auto [it, inserted] = seenRanges.emplace(network_addr, netmask); not inserted)
{
return false;
}
return false;
}
}
}

View file

@ -77,7 +77,7 @@ namespace llarp
/// in our hops what netmask will we use for unique ips for hops
/// i.e. 32 for every hop unique ip, 24 unique /24 per hop, etc
///
std::optional<int> m_UniqueHopsNetmaskSize;
int m_UniqueHopsNetmaskSize;
/// set of countrys to exclude from path building (2 char country code)
std::unordered_set<std::string> m_ExcludeCountries;