Expose ratelimits in CLI
This commit is contained in:
parent
1168307189
commit
2a7c632b2b
2 changed files with 15 additions and 3 deletions
|
|
@ -51,7 +51,7 @@ mod file_ops;
|
|||
pub mod http_api;
|
||||
#[cfg(feature = "http-api")]
|
||||
pub mod http_api_client;
|
||||
mod limits;
|
||||
pub mod limits;
|
||||
mod merge_streams;
|
||||
mod peer_connection;
|
||||
mod peer_info_reader;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::{
|
||||
io,
|
||||
net::SocketAddr,
|
||||
num::NonZeroU32,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
thread,
|
||||
|
|
@ -14,6 +15,7 @@ use librqbit::{
|
|||
api::ApiAddTorrentResponse,
|
||||
http_api::{HttpApi, HttpApiOptions},
|
||||
http_api_client, librqbit_spawn,
|
||||
limits::LimitsConfig,
|
||||
storage::{
|
||||
filesystem::{FilesystemStorageFactory, MmapFilesystemStorageFactory},
|
||||
StorageFactory, StorageFactoryExt,
|
||||
|
|
@ -218,6 +220,14 @@ struct Opts {
|
|||
#[cfg(feature = "disable-upload")]
|
||||
#[arg(long, env = "RQBIT_DISABLE_UPLOAD")]
|
||||
disable_upload: bool,
|
||||
|
||||
/// Limit download to bytes-per-second.
|
||||
#[arg(long = "ratelimit-download", env = "RQBIT_RATELIMIT_DOWNLOAD")]
|
||||
ratelimit_download_bps: Option<NonZeroU32>,
|
||||
|
||||
/// Limit upload to bytes-per-second.
|
||||
#[arg(long = "ratelimit-upload", env = "RQBIT_RATELIMIT_UPLOAD")]
|
||||
ratelimit_upload_bps: Option<NonZeroU32>,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
@ -480,8 +490,10 @@ async fn async_main(opts: Opts, cancel: CancellationToken) -> anyhow::Result<()>
|
|||
cancellation_token: Some(cancel.clone()),
|
||||
#[cfg(feature = "disable-upload")]
|
||||
disable_upload: opts.disable_upload,
|
||||
// TODO: expose
|
||||
ratelimits: Default::default(),
|
||||
ratelimits: LimitsConfig {
|
||||
upload_bps: opts.ratelimit_upload_bps,
|
||||
download_bps: opts.ratelimit_download_bps,
|
||||
},
|
||||
};
|
||||
|
||||
let stats_printer = |session: Arc<Session>| async move {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue