60#include "librats/util/rats_export.h"
71#include <unordered_map>
72#include <unordered_set>
123 void on_connected(
const Peer& peer);
125 void handle_request(
const Peer& requester, uint16_t max);
128 void introduce(
const PeerId& peer,
const std::vector<PeerInfo>& peers,
129 const std::vector<PeerId>& listed);
130 void handle_response(
ByteView body);
132 void on_dial_failed(
const Address& address);
134 const Address* pick_shareable(
const std::vector<Address>& addrs)
const;
135 bool should_dial(
const Address& addr);
145 std::atomic<HolePunchService*> punch_{
nullptr};
146 std::atomic<bool> running_{
false};
150 std::chrono::steady_clock::time_point started;
154 std::unordered_map<Address, std::chrono::steady_clock::time_point> recent_dials_;
155 std::unordered_map<Address, PendingDial> pending_dials_;
156 std::unordered_set<PeerId, PeerId::Hash> introduced_;
A dialable transport endpoint: a numeric IP + port.
Non-owning view over a contiguous run of bytes.
PeerExchange(Config config)
void attach(NodeContext &ctx) override
A pluggable network subsystem.
A lightweight handle to a connected peer.
Self-certifying peer identity.
The narrow contract a subsystem needs from the node — and nothing more.
size_t request_max
how many peers we ask for on connect
size_t max_pending_dials
Bound on dials awaiting their verdict — one entry is an address and an id.
std::chrono::milliseconds dial_cooldown
re-dial suppression
bool public_only
only share globally-routable addresses
bool introduce_requesters
Tell the peers an answer left out about the peer that asked, so that a small mesh whose members join ...
size_t peer_target
Stop dialing discovered peers once this many are connected.
size_t max_addresses_per_response
cap entries we send / act on per response
size_t max_recent_dials
bound the cooldown set
bool punch_on_dial_failure
Ask HolePunch to reach a discovered peer whose address would not dial.
std::chrono::milliseconds punch_window
How long a dial started here stays eligible for that fallback.