pub struct DhtConfig {Show 14 fields
pub bind_addr: SocketAddr,
pub bootstrap_nodes: Vec<String>,
pub own_id: Option<Id20>,
pub queries_per_second: usize,
pub query_timeout: Duration,
pub address_family: AddressFamily,
pub enforce_node_id: bool,
pub restrict_routing_ips: bool,
pub dht_max_items: usize,
pub dht_item_lifetime_secs: u64,
pub max_routing_nodes: usize,
pub state_dir: Option<PathBuf>,
pub read_only_mode: bool,
pub enable_multi_address: bool,
}Expand description
Configuration for the DHT.
Fields§
§bind_addr: SocketAddrAddress to bind the UDP socket.
bootstrap_nodes: Vec<String>Bootstrap nodes (host:port strings resolved at startup).
own_id: Option<Id20>Our node ID. Generated randomly if None.
queries_per_second: usizeMax outgoing queries per second (0 = unlimited).
query_timeout: DurationTimeout for individual KRPC queries.
address_family: AddressFamilyAddress family for this DHT instance (determines compact format and DNS filtering).
enforce_node_id: boolBEP 42: Enforce node ID verification when inserting into routing table. Nodes with IDs that don’t match their IP are rejected.
restrict_routing_ips: boolBEP 42: Restrict routing table to one node per IP address.
dht_max_items: usizeBEP 44: Maximum number of stored DHT items (immutable + mutable).
dht_item_lifetime_secs: u64BEP 44: Lifetime of DHT items in seconds before expiry.
max_routing_nodes: usizeMaximum number of nodes in the routing table. Prevents unbounded growth from adversarial node injection. Default: 512 (matches rqbit).
state_dir: Option<PathBuf>Directory for persisting DHT routing table state as JSON.
When set, the actor saves/loads dht_state.json (V4) or
dht_state_v6.json (V6) via atomic temp-file + rename.
read_only_mode: boolBEP 43: Read-only mode. When enabled, outgoing queries include ro: 1
and the node does not send announce_peer messages. Other nodes should
not add us to their routing tables.
enable_multi_address: boolBEP 45: Include want in outgoing find_node/get_peers to request
both IPv4 and IPv6 nodes from dual-stack peers.
Implementations§
Source§impl DhtConfig
impl DhtConfig
Sourcepub fn default_v6() -> Self
pub fn default_v6() -> Self
Default configuration for an IPv6 DHT instance (BEP 24).