2021-07-12 19:55:23 +01:00
|
|
|
mod bprotocol;
|
|
|
|
|
mod dht;
|
2021-07-18 10:53:33 +01:00
|
|
|
mod persistence;
|
2021-07-12 19:55:23 +01:00
|
|
|
mod routing_table;
|
2021-07-14 13:40:56 +01:00
|
|
|
mod utils;
|
2021-07-12 19:55:23 +01:00
|
|
|
|
2023-11-28 08:03:12 +00:00
|
|
|
use std::sync::Arc;
|
2023-11-28 09:23:05 +00:00
|
|
|
use std::time::Duration;
|
2023-11-28 08:03:12 +00:00
|
|
|
|
2021-10-18 16:38:43 +01:00
|
|
|
pub use crate::dht::DhtStats;
|
2023-11-30 08:06:55 +00:00
|
|
|
pub use crate::dht::{DhtConfig, DhtState, RequestPeersStream};
|
2021-07-12 19:55:23 +01:00
|
|
|
pub use librqbit_core::id20::Id20;
|
2021-07-18 10:53:33 +01:00
|
|
|
pub use persistence::{PersistentDht, PersistentDhtConfig};
|
2021-07-12 21:59:08 +01:00
|
|
|
|
2023-11-28 08:03:12 +00:00
|
|
|
pub type Dht = Arc<DhtState>;
|
|
|
|
|
|
2023-11-28 09:23:05 +00:00
|
|
|
// How long do we wait for a response from a DHT node.
|
2023-11-30 15:38:22 +00:00
|
|
|
pub(crate) const RESPONSE_TIMEOUT: Duration = Duration::from_secs(60);
|
2023-11-28 15:35:27 +00:00
|
|
|
// TODO: Not sure if we should re-query tbh.
|
2023-11-30 15:38:22 +00:00
|
|
|
pub(crate) const REQUERY_INTERVAL: Duration = Duration::from_secs(60);
|
|
|
|
|
// After how long we consider a routing table node questionable.
|
|
|
|
|
pub(crate) const INACTIVITY_TIMEOUT: Duration = Duration::from_secs(15 * 60);
|
2023-11-28 09:23:05 +00:00
|
|
|
|
2023-11-28 08:03:12 +00:00
|
|
|
pub struct DhtBuilder {}
|
|
|
|
|
|
|
|
|
|
impl DhtBuilder {
|
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
|
pub async fn new() -> anyhow::Result<Dht> {
|
|
|
|
|
DhtState::new().await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn with_config(config: DhtConfig) -> anyhow::Result<Dht> {
|
|
|
|
|
DhtState::with_config(config).await
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 21:59:08 +01:00
|
|
|
pub static DHT_BOOTSTRAP: &[&str] = &["dht.transmissionbt.com:6881", "dht.libtorrent.org:25401"];
|