Disable upload: do not expose in default builds, move under a feature flag.
This commit is contained in:
parent
b99a1e2b73
commit
990c5f866b
11 changed files with 45 additions and 16 deletions
|
|
@ -525,7 +525,7 @@ impl TorrentStateLive {
|
|||
let state = self;
|
||||
loop {
|
||||
let addr = peer_queue_rx.recv().await.context("torrent closed")?;
|
||||
if state.torrent.options.disable_upload && state.is_finished_and_no_active_streams() {
|
||||
if state.torrent.options.disable_upload() && state.is_finished_and_no_active_streams() {
|
||||
debug!("ignoring peer {} as we are finished", addr);
|
||||
state.peers.mark_peer_not_needed(addr);
|
||||
continue;
|
||||
|
|
@ -939,7 +939,7 @@ impl<'a> PeerConnectionHandler for &'a PeerHandler {
|
|||
}
|
||||
|
||||
fn should_send_bitfield(&self) -> bool {
|
||||
if self.state.torrent().options.disable_upload {
|
||||
if self.state.torrent().options.disable_upload() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -947,7 +947,7 @@ impl<'a> PeerConnectionHandler for &'a PeerHandler {
|
|||
}
|
||||
|
||||
fn should_transmit_have(&self, id: ValidPieceIndex) -> bool {
|
||||
if self.state.torrent.options.disable_upload {
|
||||
if self.state.torrent.options.disable_upload() {
|
||||
return false;
|
||||
}
|
||||
let have = self
|
||||
|
|
@ -1187,7 +1187,7 @@ impl PeerHandler {
|
|||
}
|
||||
|
||||
fn on_download_request(&self, request: Request) -> anyhow::Result<()> {
|
||||
if self.state.torrent().options.disable_upload {
|
||||
if self.state.torrent().options.disable_upload() {
|
||||
anyhow::bail!("upload disabled, but peer requested a piece")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,20 @@ pub(crate) struct ManagedTorrentOptions {
|
|||
pub allow_overwrite: bool,
|
||||
pub output_folder: PathBuf,
|
||||
pub disk_write_queue: Option<DiskWorkQueueSender>,
|
||||
pub disable_upload: bool,
|
||||
#[cfg(feature = "disable-upload")]
|
||||
pub _disable_upload: bool,
|
||||
}
|
||||
|
||||
impl ManagedTorrentOptions {
|
||||
#[cfg(feature = "disable-upload")]
|
||||
pub fn disable_upload(&self) -> bool {
|
||||
self._disable_upload
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "disable-upload"))]
|
||||
pub const fn disable_upload(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Common information about torrent shared among all possible states.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue