Add support for adding custom trackers
This commit is contained in:
parent
fb15e070a0
commit
f184e7f5bf
1 changed files with 17 additions and 4 deletions
|
|
@ -274,6 +274,9 @@ pub struct AddTorrentOptions {
|
||||||
// If true, will write to disk in separate threads. The downside is additional allocations.
|
// If true, will write to disk in separate threads. The downside is additional allocations.
|
||||||
// May be useful if the disk is slow.
|
// May be useful if the disk is slow.
|
||||||
pub defer_writes: Option<bool>,
|
pub defer_writes: Option<bool>,
|
||||||
|
|
||||||
|
// Custom trackers
|
||||||
|
pub trackers: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ListOnlyResponse {
|
pub struct ListOnlyResponse {
|
||||||
|
|
@ -888,7 +891,11 @@ impl Session {
|
||||||
if opts.disable_trackers {
|
if opts.disable_trackers {
|
||||||
Default::default()
|
Default::default()
|
||||||
} else {
|
} else {
|
||||||
magnet.trackers.clone()
|
let mut trackers = magnet.trackers.clone();
|
||||||
|
if let Some(custom_trackers) = opts.trackers.clone() {
|
||||||
|
trackers.extend(custom_trackers);
|
||||||
|
}
|
||||||
|
trackers
|
||||||
},
|
},
|
||||||
announce_port,
|
announce_port,
|
||||||
opts.force_tracker_interval,
|
opts.force_tracker_interval,
|
||||||
|
|
@ -922,7 +929,10 @@ impl Session {
|
||||||
seen,
|
seen,
|
||||||
} => {
|
} => {
|
||||||
trace!(?info, "received result from DHT");
|
trace!(?info, "received result from DHT");
|
||||||
let trackers = magnet.trackers.into_iter().unique().collect_vec();
|
let mut trackers = magnet.trackers.into_iter().unique().collect_vec();
|
||||||
|
if let Some(custom_trackers) = opts.trackers.clone() {
|
||||||
|
trackers.extend(custom_trackers);
|
||||||
|
}
|
||||||
InternalAddResult {
|
InternalAddResult {
|
||||||
info_hash,
|
info_hash,
|
||||||
torrent_bytes: torrent_file_from_info_bytes(
|
torrent_bytes: torrent_file_from_info_bytes(
|
||||||
|
|
@ -965,7 +975,7 @@ impl Session {
|
||||||
.context("error decoding torrent")?
|
.context("error decoding torrent")?
|
||||||
};
|
};
|
||||||
|
|
||||||
let trackers = torrent.info
|
let mut trackers = torrent.info
|
||||||
.iter_announce()
|
.iter_announce()
|
||||||
.unique()
|
.unique()
|
||||||
.filter_map(|tracker| match std::str::from_utf8(tracker.as_ref()) {
|
.filter_map(|tracker| match std::str::from_utf8(tracker.as_ref()) {
|
||||||
|
|
@ -976,6 +986,9 @@ impl Session {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
if let Some(custom_trackers) = opts.trackers.clone() {
|
||||||
|
trackers.extend(custom_trackers);
|
||||||
|
}
|
||||||
|
|
||||||
let peer_rx = if paused {
|
let peer_rx = if paused {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue