Back to Site
Loading...
Searching...
No Matches
librats::DhtDiscovery::Config Struct Reference

#include <dht_discovery.h>

Collaboration diagram for librats::DhtDiscovery::Config:
[legend]

Public Attributes

uint16_t dht_port = 0
 0 = ephemeral
std::string bind_address = ""
std::string data_dir = ""
 routing-table persistence dir (empty = cwd). Set to the node's data_dir to co-locate state.
bool enable_ipv4 = true
 run the IPv4 Kademlia network
bool enable_ipv6 = true
 run the IPv6 Kademlia network (BEP 32)
std::string discovery_key = ""
 DHT namespace.
std::vector< std::string > keys
 The keys to announce and search, in place of discovery_key when not empty (set_keys() changes them as the node runs).
std::vector< HostEndpoint > bootstrap_nodes
 empty → default internet nodes
std::chrono::milliseconds search_interval {30000}
std::chrono::milliseconds announce_interval {600000}
 every 30 seconds
bool discover_external_ip = true
 Ask STUN where we are: the public IP seeds the DHT node id per BEP 42 (without it we still converge via the slower in-DHT "ip" voting, but bootstrap under the wrong node id until then), and the port the NAT maps the shared datagram socket to is the one announced over IPv4.
std::vector< HostEndpoint > stun_servers
 empty → built-in public defaults
std::chrono::milliseconds stun_timeout {3000}
std::chrono::milliseconds stun_every {20000}
 STUN is asked again this often, on the search round it falls in — after a round with no answer, ten times as long.
std::chrono::milliseconds redial_every {5000}
 A peer found and not connected is punched this often, found again or not, for this long after it was first found (or last found connected: a link gone is dialed for anew).
std::chrono::milliseconds redial_for {120000}
std::chrono::milliseconds redial_slow {25000}
 After redial_for: punched again each time the DHT hands it out again, at most this often, for as long as it does.

Detailed Description

Definition at line 82 of file dht_discovery.h.

Member Data Documentation

◆ announce_interval

std::chrono::milliseconds librats::DhtDiscovery::Config::announce_interval {600000}

every 30 seconds

Re-announce cadence. Kept at ~⅓ of the peer TTL (librats stores announced peers for 30 min, libtorrent ~45 min) so we stay findable with a comfortable margin even if an announce or two is lost — libtorrent's own default is 15 min. A fresh node still announces immediately at startup regardless of this value (see loop()).

Definition at line 98 of file dht_discovery.h.

◆ bind_address

std::string librats::DhtDiscovery::Config::bind_address = ""

Definition at line 84 of file dht_discovery.h.

◆ bootstrap_nodes

std::vector<HostEndpoint> librats::DhtDiscovery::Config::bootstrap_nodes

empty → default internet nodes

Definition at line 92 of file dht_discovery.h.

◆ data_dir

std::string librats::DhtDiscovery::Config::data_dir = ""

routing-table persistence dir (empty = cwd). Set to the node's data_dir to co-locate state.

Definition at line 85 of file dht_discovery.h.

◆ dht_port

uint16_t librats::DhtDiscovery::Config::dht_port = 0

0 = ephemeral

Definition at line 83 of file dht_discovery.h.

◆ discover_external_ip

bool librats::DhtDiscovery::Config::discover_external_ip = true

Ask STUN where we are: the public IP seeds the DHT node id per BEP 42 (without it we still converge via the slower in-DHT "ip" voting, but bootstrap under the wrong node id until then), and the port the NAT maps the shared datagram socket to is the one announced over IPv4.

Definition at line 104 of file dht_discovery.h.

◆ discovery_key

std::string librats::DhtDiscovery::Config::discovery_key = ""

DHT namespace.

Empty → the node's protocol (resolved at attach), so peers of the same app/version discover each other and mismatched protocols (which can't handshake anyway) don't even meet. Set non-empty to override with a custom discovery network.

Definition at line 88 of file dht_discovery.h.

◆ enable_ipv4

bool librats::DhtDiscovery::Config::enable_ipv4 = true

run the IPv4 Kademlia network

Definition at line 86 of file dht_discovery.h.

◆ enable_ipv6

bool librats::DhtDiscovery::Config::enable_ipv6 = true

run the IPv6 Kademlia network (BEP 32)

Definition at line 87 of file dht_discovery.h.

◆ keys

std::vector<std::string> librats::DhtDiscovery::Config::keys

The keys to announce and search, in place of discovery_key when not empty (set_keys() changes them as the node runs).

Definition at line 91 of file dht_discovery.h.

◆ redial_every

std::chrono::milliseconds librats::DhtDiscovery::Config::redial_every {5000}

A peer found and not connected is punched this often, found again or not, for this long after it was first found (or last found connected: a link gone is dialed for anew).

A NAT lets in what comes from where it last sent to for some 30 s at least, so two nodes that keep punching each other more often than that get through on the second's punch.

Definition at line 118 of file dht_discovery.h.

◆ redial_for

std::chrono::milliseconds librats::DhtDiscovery::Config::redial_for {120000}

Definition at line 119 of file dht_discovery.h.

◆ redial_slow

std::chrono::milliseconds librats::DhtDiscovery::Config::redial_slow {25000}

After redial_for: punched again each time the DHT hands it out again, at most this often, for as long as it does.

A peer that comes online later at the address found (the DHT keeps an announce half an hour, and a NAT often keeps a port) is so met: its own punches, every redial_every, land while ours keep our NAT open to it. A little under search_interval: once a round.

Definition at line 126 of file dht_discovery.h.

◆ search_interval

std::chrono::milliseconds librats::DhtDiscovery::Config::search_interval {30000}

Definition at line 93 of file dht_discovery.h.

◆ stun_every

std::chrono::milliseconds librats::DhtDiscovery::Config::stun_every {20000}

STUN is asked again this often, on the search round it falls in — after a round with no answer, ten times as long.

Shorter than a NAT keeps an idle mapping (30 s at the least), with search_interval.

Definition at line 110 of file dht_discovery.h.

◆ stun_servers

std::vector<HostEndpoint> librats::DhtDiscovery::Config::stun_servers

empty → built-in public defaults

Definition at line 105 of file dht_discovery.h.

◆ stun_timeout

std::chrono::milliseconds librats::DhtDiscovery::Config::stun_timeout {3000}

Definition at line 106 of file dht_discovery.h.


The documentation for this struct was generated from the following file: