mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#27581: net: Continuous ASMap health check
3ea54e5db7net: Add continuous ASMap health check logging (Fabian Jahr)28d7e55dfftest: Add tests for unfiltered GetAddr usage (Fabian Jahr)b8843d37aefuzz: Let fuzzers use filter options in GetAddr/GetAddresses (Fabian Jahr)e16f420547net: Optionally include terrible addresses in GetAddr results (Fabian Jahr) Pull request description: There are certain statistics we can collect by running all our known clearnet addresses against the ASMap file. This could show issues with a maliciously manipulated file or with an old file that has decayed with time. This is just a proof of concept for now. My idea currently is to run the analysis once per day and print the results to logs if an ASMap file is used. ACKs for top commit: achow101: ACK3ea54e5db7mzumsande: ACK3ea54e5db7brunoerg: crACK3ea54e5db7Tree-SHA512: 777acbfac43cc43ce4a0a3612434e4ddbc65f59ae8ffc9e24f21de09011bccb297f0599cbaa82bcf40ef68e5af582c4e98556379db7ceff7d9f97574a1cf8e09
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <netgroup.h>
|
||||
|
||||
#include <hash.h>
|
||||
#include <logging.h>
|
||||
#include <util/asmap.h>
|
||||
|
||||
uint256 NetGroupManager::GetAsmapChecksum() const
|
||||
@@ -109,3 +110,23 @@ uint32_t NetGroupManager::GetMappedAS(const CNetAddr& address) const
|
||||
uint32_t mapped_as = Interpret(m_asmap, ip_bits);
|
||||
return mapped_as;
|
||||
}
|
||||
|
||||
void NetGroupManager::ASMapHealthCheck(const std::vector<CNetAddr>& clearnet_addrs) const {
|
||||
std::set<uint32_t> clearnet_asns{};
|
||||
int unmapped_count{0};
|
||||
|
||||
for (const auto& addr : clearnet_addrs) {
|
||||
uint32_t asn = GetMappedAS(addr);
|
||||
if (asn == 0) {
|
||||
++unmapped_count;
|
||||
continue;
|
||||
}
|
||||
clearnet_asns.insert(asn);
|
||||
}
|
||||
|
||||
LogPrintf("ASMap Health Check: %i clearnet peers are mapped to %i ASNs with %i peers being unmapped\n", clearnet_addrs.size(), clearnet_asns.size(), unmapped_count);
|
||||
}
|
||||
|
||||
bool NetGroupManager::UsingASMap() const {
|
||||
return m_asmap.size() > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user