Skip to content

Commit

Permalink
Merge pull request #55 from brunoerg/2024-07-fix-addrv2
Browse files Browse the repository at this point in the history
addrv2: fix clearnet count to include Tor
  • Loading branch information
brunoerg authored Jul 3, 2024
2 parents 18b619a + e2093b4 commit 21c9ab9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions targets/addrv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ std::optional<std::pair<uint64_t, uint64_t>> Addrv2Core(Span<const uint8_t> buff
{
std::vector<CAddress> addrs;
DataStream ds{buffer};
uint64_t clearnet_count{0};
uint64_t clearnet_tor_count{0};
try {
ds >> CAddress::V2_NETWORK(addrs);
if (addrs.size() > 1000) return std::nullopt;
for (auto& addr : addrs) {
if (addr.IsIPv4() || addr.IsIPv6()) clearnet_count++;
if (addr.IsIPv4() || addr.IsIPv6() || addr.IsTor()) clearnet_tor_count++;
if (!addr.IsValid()) return std::nullopt;
}
} catch (const std::ios_base::failure&) {
return std::nullopt;
}

return std::make_pair(addrs.size(), clearnet_count);
return std::make_pair(addrs.size(), clearnet_tor_count);
}

void Addrv2(FuzzedDataProvider& provider)
Expand Down

0 comments on commit 21c9ab9

Please sign in to comment.