#include <dht_discovery.h>
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. | |
Definition at line 82 of file dht_discovery.h.
| 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.
| std::string librats::DhtDiscovery::Config::bind_address = "" |
Definition at line 84 of file dht_discovery.h.
| std::vector<HostEndpoint> librats::DhtDiscovery::Config::bootstrap_nodes |
empty → default internet nodes
Definition at line 92 of file dht_discovery.h.
| 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.
| uint16_t librats::DhtDiscovery::Config::dht_port = 0 |
0 = ephemeral
Definition at line 83 of file dht_discovery.h.
| 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.
| 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.
| bool librats::DhtDiscovery::Config::enable_ipv4 = true |
run the IPv4 Kademlia network
Definition at line 86 of file dht_discovery.h.
| bool librats::DhtDiscovery::Config::enable_ipv6 = true |
run the IPv6 Kademlia network (BEP 32)
Definition at line 87 of file dht_discovery.h.
| 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.
| 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.
| std::chrono::milliseconds librats::DhtDiscovery::Config::redial_for {120000} |
Definition at line 119 of file dht_discovery.h.
| 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.
| std::chrono::milliseconds librats::DhtDiscovery::Config::search_interval {30000} |
Definition at line 93 of file dht_discovery.h.
| 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.
| std::vector<HostEndpoint> librats::DhtDiscovery::Config::stun_servers |
empty → built-in public defaults
Definition at line 105 of file dht_discovery.h.
| std::chrono::milliseconds librats::DhtDiscovery::Config::stun_timeout {3000} |
Definition at line 106 of file dht_discovery.h.