|
std::string | ConnectionTypeAsString (ConnectionType conn_type) |
| Convert ConnectionType enum to a string value. More...
|
|
void | Discover () |
|
uint16_t | GetListenPort () |
|
bool | IsPeerAddrLocalGood (CNode *pnode) |
|
std::optional< CAddress > | GetLocalAddrForPeer (CNode *pnode) |
| Returns a local address that we should advertise to this peer. More...
|
|
void | SetReachable (enum Network net, bool reachable) |
| Mark a network as reachable or unreachable (no automatic connects to it) More...
|
|
bool | IsReachable (enum Network net) |
|
bool | IsReachable (const CNetAddr &addr) |
|
bool | AddLocal (const CService &addr, int nScore=LOCAL_NONE) |
|
bool | AddLocal (const CNetAddr &addr, int nScore=LOCAL_NONE) |
|
void | RemoveLocal (const CService &addr) |
|
bool | SeenLocal (const CService &addr) |
| vote for a local address More...
|
|
bool | IsLocal (const CService &addr) |
| check whether a given address is potentially local More...
|
|
bool | GetLocal (CService &addr, const CNetAddr *paddrPeer=nullptr) |
|
CAddress | GetLocalAddress (const CNetAddr *paddrPeer, ServiceFlags nLocalServices) |
|
std::map< CNetAddr, LocalServiceInfo > mapLocalHost | GUARDED_BY (g_maplocalhost_mutex) |
|
void | CaptureMessage (const CAddress &addr, const std::string &msg_type, const Span< const unsigned char > &data, bool is_incoming) |
| Dump binary message to file, with timestamp. More...
|
|
std::optional< NodeId > | SelectNodeToEvict (std::vector< NodeEvictionCandidate > &&vEvictionCandidates) |
| Select an inbound peer to evict after filtering out (protecting) peers having distinct, difficult-to-forge characteristics. More...
|
|
void | ProtectEvictionCandidatesByRatio (std::vector< NodeEvictionCandidate > &vEvictionCandidates) |
| Protect desirable or disadvantaged inbound peers from eviction by ratio. More...
|
|
Different types of connections to a peer.
This enum encapsulates the information we have available at the time of opening or accepting the connection. Aside from INBOUND, all types are initiated by us.
If adding or removing types, please update CONNECTION_TYPE_DOC in src/rpc/net.cpp and src/qt/rpcconsole.cpp, as well as the descriptions in src/qt/guiutil.cpp and src/bitcoin-cli.cppNetinfoRequestHandler.
Enumerator |
---|
INBOUND | Inbound connections are those initiated by a peer.
This is the only property we know at the time of connection, until P2P messages are exchanged.
|
OUTBOUND_FULL_RELAY | These are the default connections that we use to connect with the network.
There is no restriction on what is relayed; by default we relay blocks, addresses & transactions. We automatically attempt to open MAX_OUTBOUND_FULL_RELAY_CONNECTIONS using addresses from our AddrMan.
|
MANUAL | We open manual connections to addresses that users explicitly requested via the addnode RPC or the -addnode/-connect configuration options.
Even if a manual connection is misbehaving, we do not automatically disconnect or add it to our discouragement filter.
|
FEELER | Feeler connections are short-lived connections made to check that a node is alive.
They can be useful for:
- test-before-evict: if one of the peers is considered for eviction from our AddrMan because another peer is mapped to the same slot in the tried table, evict only if this longer-known peer is offline.
- move node addresses from New to Tried table, so that we have more connectable addresses in our AddrMan. Note that in the literature ("Eclipse Attacks on Bitcoin’s Peer-to-Peer Network") only the latter feature is referred to as "feeler connections", although in our codebase feeler connections encompass test-before-evict as well. We make these connections approximately every FEELER_INTERVAL: first we resolve previously found collisions if they exist (test-before-evict), otherwise we connect to a node from the new table.
|
BLOCK_RELAY | We use block-relay-only connections to help prevent against partition attacks.
By not relaying transactions or addresses, these connections are harder to detect by a third party, thus helping obfuscate the network topology. We automatically attempt to open MAX_BLOCK_RELAY_ONLY_ANCHORS using addresses from our anchors.dat. Then addresses from our AddrMan if MAX_BLOCK_RELAY_ONLY_CONNECTIONS isn't reached yet.
|
ADDR_FETCH | AddrFetch connections are short lived connections used to solicit addresses from peers.
These are initiated to addresses submitted via the -seednode command line argument, or under certain conditions when the AddrMan is empty.
|
Definition at line 121 of file net.h.
Protect desirable or disadvantaged inbound peers from eviction by ratio.
This function protects half of the peers which have been connected the longest, to replicate the non-eviction implicit behavior and preclude attacks that start later.
Half of these protected spots (1/4 of the total) are reserved for the following categories of peers, sorted by longest uptime, even if they're not longest uptime overall:
- onion peers connected via our tor control service
- localhost peers, as manually configured hidden services not using
-bind=addr[:port]=onion
will not be detected as inbound onion connections
- I2P peers
This helps protect these privacy network peers, which tend to be otherwise disadvantaged under our eviction criteria for their higher min ping times relative to IPv4/IPv6 peers, and favorise the diversity of peer connections.
Definition at line 926 of file net.cpp.
Select an inbound peer to evict after filtering out (protecting) peers having distinct, difficult-to-forge characteristics.
The protection logic picks out fixed numbers of desirable peers per various criteria, followed by (mostly) ratios of desirable or disadvantaged peers. If any eviction candidates remain, the selection logic chooses a peer to evict.
Definition at line 999 of file net.cpp.