Accepting TCP connections + publishing = works. Still yet to pass it to the live torrent
This commit is contained in:
parent
71d49a88b6
commit
41fb3bfd37
5 changed files with 93 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::{
|
||||
cmp::Reverse,
|
||||
net::SocketAddr,
|
||||
net::{SocketAddr, SocketAddrV4},
|
||||
sync::{
|
||||
atomic::{AtomicU16, Ordering},
|
||||
Arc,
|
||||
|
|
@ -1059,7 +1059,8 @@ pub struct DhtConfig {
|
|||
pub bootstrap_addrs: Option<Vec<String>>,
|
||||
pub routing_table: Option<RoutingTable>,
|
||||
pub listen_addr: Option<SocketAddr>,
|
||||
pub(crate) peer_store: Option<PeerStore>,
|
||||
pub announce_addr: Option<SocketAddr>,
|
||||
pub peer_store: Option<PeerStore>,
|
||||
}
|
||||
|
||||
impl DhtState {
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@ use crate::peer_store::PeerStore;
|
|||
use crate::routing_table::RoutingTable;
|
||||
use crate::{Dht, DhtConfig, DhtState};
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
#[derive(Default)]
|
||||
pub struct PersistentDhtConfig {
|
||||
pub dump_interval: Option<Duration>,
|
||||
pub config_filename: Option<PathBuf>,
|
||||
pub announce_addr: Option<SocketAddr>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
|
@ -111,11 +112,13 @@ impl PersistentDht {
|
|||
.map(|de| (Some(de.addr), Some(de.table), de.peer_store))
|
||||
.unwrap_or((None, None, None));
|
||||
let peer_id = routing_table.as_ref().map(|r| r.id());
|
||||
|
||||
let dht_config = DhtConfig {
|
||||
peer_id,
|
||||
routing_table,
|
||||
listen_addr,
|
||||
peer_store,
|
||||
announce_addr: config.announce_addr,
|
||||
..Default::default()
|
||||
};
|
||||
let dht = DhtState::with_config(dht_config).await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue