Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | bool AddNewAddresses(const std::vector<CAddress> &vAddr, | ||||
const CAddress &addrFrom, int64_t nTimePenalty = 0); | const CAddress &addrFrom, int64_t nTimePenalty = 0); | ||||
std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct); | std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct); | ||||
/** | /** | ||||
* Cache is used to minimize topology leaks, so it should | * Cache is used to minimize topology leaks, so it should | ||||
* be used for all non-trusted calls, for example, p2p. | * be used for all non-trusted calls, for example, p2p. | ||||
* A non-malicious call (from RPC or a peer with addr permission) should | * A non-malicious call (from RPC or a peer with addr permission) should | ||||
* call the function without a parameter to avoid using the cache. | * call the function without a parameter to avoid using the cache. | ||||
*/ | */ | ||||
std::vector<CAddress> GetAddresses(Network requestor_network, | std::vector<CAddress> GetAddresses(CNode &requestor, size_t max_addresses, | ||||
size_t max_addresses, size_t max_pct); | size_t max_pct); | ||||
// This allows temporarily exceeding m_max_outbound_full_relay, with the | // This allows temporarily exceeding m_max_outbound_full_relay, with the | ||||
// goal of finding a peer that is better than all our current peers. | // goal of finding a peer that is better than all our current peers. | ||||
void SetTryNewOutboundPeer(bool flag); | void SetTryNewOutboundPeer(bool flag); | ||||
bool GetTryNewOutboundPeer(); | bool GetTryNewOutboundPeer(); | ||||
// Return the number of outbound peers we have in excess of our target (eg, | // Return the number of outbound peers we have in excess of our target (eg, | ||||
// if we previously called SetTryNewOutboundPeer(true), and have since set | // if we previously called SetTryNewOutboundPeer(true), and have since set | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | private: | ||||
*/ | */ | ||||
struct CachedAddrResponse { | struct CachedAddrResponse { | ||||
std::vector<CAddress> m_addrs_response_cache; | std::vector<CAddress> m_addrs_response_cache; | ||||
std::chrono::microseconds m_update_addr_response{0}; | std::chrono::microseconds m_update_addr_response{0}; | ||||
}; | }; | ||||
/** | /** | ||||
* Addr responses stored in different caches | * Addr responses stored in different caches | ||||
* per network prevent cross-network node identification. | * per (network, local socket) prevent cross-network node identification. | ||||
* If a node for example is multi-homed under Tor and IPv6, | * If a node for example is multi-homed under Tor and IPv6, | ||||
* a single cache (or no cache at all) would let an attacker | * a single cache (or no cache at all) would let an attacker | ||||
* to easily detect that it is the same node by comparing responses. | * to easily detect that it is the same node by comparing responses. | ||||
* Indexing by local socket prevents leakage when a node has multiple | |||||
* listening addresses on the same network. | |||||
* | |||||
* The used memory equals to 1000 CAddress records (or around 32 bytes) per | * The used memory equals to 1000 CAddress records (or around 32 bytes) per | ||||
* distinct Network (up to 5) we have/had an inbound peer from, | * distinct Network (up to 5) we have/had an inbound peer from, | ||||
* resulting in at most ~160 KB. | * resulting in at most ~160 KB. Every separate local socket may | ||||
* add up to ~160 KB extra. | |||||
*/ | */ | ||||
std::map<Network, CachedAddrResponse> m_addr_response_caches; | std::map<uint64_t, CachedAddrResponse> m_addr_response_caches; | ||||
/** | /** | ||||
* Services this instance offers. | * Services this instance offers. | ||||
* | * | ||||
* This data is replicated in each CNode instance we create during peer | * This data is replicated in each CNode instance we create during peer | ||||
* connection (in ConnectNode()) under a member also called | * connection (in ConnectNode()) under a member also called | ||||
* nLocalServices. | * nLocalServices. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 800 Lines • Show Last 20 Lines |