Bitcoin Core 30.99.0
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
NetGroupManager Class Reference

Netgroup manager. More...

#include <netgroup.h>

Public Member Functions

 NetGroupManager (const NetGroupManager &)=delete
 
 NetGroupManager (NetGroupManager &&)=default
 
NetGroupManageroperator= (const NetGroupManager &)=delete
 
NetGroupManageroperator= (NetGroupManager &&)=delete
 
uint256 GetAsmapVersion () const
 Get the asmap version, a checksum identifying the asmap being used. More...
 
std::vector< unsigned char > GetGroup (const CNetAddr &address) const
 Get the canonical identifier of the network group for address. More...
 
uint32_t GetMappedAS (const CNetAddr &address) const
 Get the autonomous system on the BGP path to address. More...
 
void ASMapHealthCheck (const std::vector< CNetAddr > &clearnet_addrs) const
 Analyze and log current health of ASMap based buckets. More...
 
bool UsingASMap () const
 Indicates whether ASMap is being used for clearnet bucketing. More...
 

Static Public Member Functions

static NetGroupManager WithEmbeddedAsmap (std::span< const std::byte > asmap)
 
static NetGroupManager WithLoadedAsmap (std::vector< std::byte > &&asmap)
 
static NetGroupManager NoAsmap ()
 

Private Member Functions

 NetGroupManager (std::span< const std::byte > embedded_asmap, std::vector< std::byte > &&loaded_asmap)
 

Private Attributes

const std::span< const std::byte > m_asmap
 Compressed IP->ASN mapping. More...
 
std::vector< std::byte > m_loaded_asmap
 

Detailed Description

Netgroup manager.

Definition at line 17 of file netgroup.h.

Constructor & Destructor Documentation

◆ NetGroupManager() [1/3]

NetGroupManager::NetGroupManager ( const NetGroupManager )
delete
Here is the caller graph for this function:

◆ NetGroupManager() [2/3]

NetGroupManager::NetGroupManager ( NetGroupManager &&  )
default

◆ NetGroupManager() [3/3]

NetGroupManager::NetGroupManager ( std::span< const std::byte >  embedded_asmap,
std::vector< std::byte > &&  loaded_asmap 
)
inlineexplicitprivate

Definition at line 96 of file netgroup.h.

Here is the call graph for this function:

Member Function Documentation

◆ ASMapHealthCheck()

void NetGroupManager::ASMapHealthCheck ( const std::vector< CNetAddr > &  clearnet_addrs) const

Analyze and log current health of ASMap based buckets.

Definition at line 109 of file netgroup.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAsmapVersion()

uint256 NetGroupManager::GetAsmapVersion ( ) const

Get the asmap version, a checksum identifying the asmap being used.

Definition at line 14 of file netgroup.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGroup()

std::vector< unsigned char > NetGroupManager::GetGroup ( const CNetAddr address) const

Get the canonical identifier of the network group for address.

The groups are assigned in a way where it should be costly for an attacker to obtain addresses with many different group identifiers, even if it is cheap to obtain addresses with the same identifier.

Note
No two connections will be attempted to addresses with the same network group.

Definition at line 19 of file netgroup.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMappedAS()

uint32_t NetGroupManager::GetMappedAS ( const CNetAddr address) const

Get the autonomous system on the BGP path to address.

The ip->AS mapping depends on how asmap is constructed.

Definition at line 82 of file netgroup.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NoAsmap()

static NetGroupManager NetGroupManager::NoAsmap ( )
inlinestatic

Definition at line 32 of file netgroup.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

NetGroupManager & NetGroupManager::operator= ( const NetGroupManager )
delete

◆ operator=() [2/2]

NetGroupManager & NetGroupManager::operator= ( NetGroupManager &&  )
delete

◆ UsingASMap()

bool NetGroupManager::UsingASMap ( ) const

Indicates whether ASMap is being used for clearnet bucketing.

Definition at line 125 of file netgroup.cpp.

Here is the caller graph for this function:

◆ WithEmbeddedAsmap()

static NetGroupManager NetGroupManager::WithEmbeddedAsmap ( std::span< const std::byte >  asmap)
inlinestatic

Definition at line 24 of file netgroup.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WithLoadedAsmap()

static NetGroupManager NetGroupManager::WithLoadedAsmap ( std::vector< std::byte > &&  asmap)
inlinestatic

Definition at line 28 of file netgroup.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_asmap

const std::span<const std::byte> NetGroupManager::m_asmap
private

Compressed IP->ASN mapping.

Data may be loaded from a file when a node starts or embedded in the binary.

This mapping is then used for bucketing nodes in Addrman and for ensuring we connect to a diverse set of peers in Connman. The map is empty if no file was provided.

If asmap is provided, nodes will be bucketed by AS they belong to, in order to make impossible for a node to connect to several nodes hosted in a single AS. This is done in response to Erebus attack, but also to generally diversify the connections every node creates, especially useful when a large fraction of nodes operate under a couple of cloud providers.

If a new asmap is provided, the existing addrman records are re-bucketed.

This is initialized in the constructor, const, and therefore is thread-safe. m_asmap can either point to m_loaded_asmap which holds data loaded from an external file at runtime or it can point to embedded asmap data.

Definition at line 93 of file netgroup.h.

◆ m_loaded_asmap

std::vector<std::byte> NetGroupManager::m_loaded_asmap
private

Definition at line 94 of file netgroup.h.


The documentation for this class was generated from the following files: