Struct DHTSettings

Source
#[non_exhaustive]
pub struct DHTSettings {
Show 22 fields pub token_secret_size: usize, pub max_peers_response: usize, pub max_sample_response: usize, pub min_sample_interval_secs: i32, pub router_ping_interval_secs: u64, pub reverify_interval_secs: u64, pub reverify_grace_period_secs: u64, pub verify_grace_period_secs: u64, pub get_peers_freshness_secs: u64, pub find_nodes_interval_secs: u64, pub find_nodes_skip_count: usize, pub max_torrents: usize, pub max_peers_per_torrent: usize, pub ping_check_interval_secs: u64, pub outgoing_request_prune_secs: u64, pub outgoing_reqiest_check_interval_secs: u64, pub read_only: bool, pub routers: Vec<String>, pub throttle_packet_count: usize, pub throttle_period_secs: u64, pub throttle_naughty_timeout_secs: u64, pub throttle_max_tracking_secs: u64,
}
Expand description

Struct that represents configuration for DHT that, in general, does not change after the DHT is started.

You may need one of these to pass into DHTBuilder.

Use DHTSettings::default() to create an instance with the ‘recommended’ defaults (which can be customized). Or use DHTSettingsBuilder to construct a customized one. DHTSettings has the non_exhaustive attribute and can’t be constructed directly.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§token_secret_size: usize

Number of bytes for token secrets for get_peers responses

§max_peers_response: usize

Max number of peers to provide in response to a get_peers. Shouldn’t be much higher than this as the entire response packet needs to be less than 1500

§max_sample_response: usize

Max number of info hashes to provide in response to a sample_infohashes request

§min_sample_interval_secs: i32

How often we claim to rotate our sample_infohashes response

§router_ping_interval_secs: u64

We’ll ping the “routers” at least this often (we may ping more frequently if needed)

§reverify_interval_secs: u64

We’ll ping previously-verified nodes at least this often to re-verify them

§reverify_grace_period_secs: u64

Verified nodes that we don’t reverify within this amount of time are dropped

§verify_grace_period_secs: u64

New nodes have this long to respond to a ping before we drop them

§get_peers_freshness_secs: u64

When asked to provide peers, we’ll only provide ones that announced within this time

§find_nodes_interval_secs: u64

We’ll think about sending a find_nodes request at least this often. If we have enough nodes already we might not do it.

§find_nodes_skip_count: usize

We won’t send a periodic find_nodes request if we have at least this many unverified nodes

§max_torrents: usize

Max number of torrents to store peers for

§max_peers_per_torrent: usize

Max number of peers per torrent to store

§ping_check_interval_secs: u64

We’ll think about pinging and pruning nodes at this interval

§outgoing_request_prune_secs: u64

Outgoing requests may be pruned after this many seconds

§outgoing_reqiest_check_interval_secs: u64

We’ll think about pruning outgoing requests at this interval

§read_only: bool

If true, we will set the read only flag in outgoing requests to prevent other nodes from adding us to their routing tables. This is useful if we’re behind a restrictive NAT/firewall and can’t accept incoming packets from IPs that we haven’t sent anything to.

§routers: Vec<String>

Vector of hostnames/ports that the DHT will use as DHT routers for bootstrapping purposes.

E.g., “router.example.org:6881”

§throttle_packet_count: usize

The maximum number of packets that will be accepted from an IP (during a period) before packets from that IP will be temporarily ignored.

§throttle_period_secs: u64

The number of seconds that the throttler keeps a packet count record for an IP. If the IP sends more than throttle_packet_count packets during this period then packets from it will be blocked.

§throttle_naughty_timeout_secs: u64

If the throttler blocks an IP, it will be blocked for at least this amount of time. Every time the blocked IP sends another packet, the counter is reset again (up to a limit of throttle_max_tracking_secs).

§throttle_max_tracking_secs: u64

The maximum amount of time that the throttler will keep any record, even if the IP on the record is still sending traffic.

Trait Implementations§

Source§

impl Clone for DHTSettings

Source§

fn clone(&self) -> DHTSettings

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DHTSettings

Returns DHTSettings with a default set of options.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V