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;
|
pub mod http_api;
|
||||||
#[cfg(feature = "http-api")]
|
#[cfg(feature = "http-api")]
|
||||||
pub mod http_api_client;
|
pub mod http_api_client;
|
||||||
mod limits;
|
pub mod limits;
|
||||||
mod merge_streams;
|
mod merge_streams;
|
||||||
mod peer_connection;
|
mod peer_connection;
|
||||||
mod peer_info_reader;
|
mod peer_info_reader;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
io,
|
io,
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
|
num::NonZeroU32,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
thread,
|
thread,
|
||||||
|
|
@ -14,6 +15,7 @@ use librqbit::{
|
||||||
api::ApiAddTorrentResponse,
|
api::ApiAddTorrentResponse,
|
||||||
http_api::{HttpApi, HttpApiOptions},
|
http_api::{HttpApi, HttpApiOptions},
|
||||||
http_api_client, librqbit_spawn,
|
http_api_client, librqbit_spawn,
|
||||||
|
limits::LimitsConfig,
|
||||||
storage::{
|
storage::{
|
||||||
filesystem::{FilesystemStorageFactory, MmapFilesystemStorageFactory},
|
filesystem::{FilesystemStorageFactory, MmapFilesystemStorageFactory},
|
||||||
StorageFactory, StorageFactoryExt,
|
StorageFactory, StorageFactoryExt,
|
||||||
|
|
@ -218,6 +220,14 @@ struct Opts {
|
||||||
#[cfg(feature = "disable-upload")]
|
#[cfg(feature = "disable-upload")]
|
||||||
#[arg(long, env = "RQBIT_DISABLE_UPLOAD")]
|
#[arg(long, env = "RQBIT_DISABLE_UPLOAD")]
|
||||||
disable_upload: bool,
|
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)]
|
#[derive(Parser)]
|
||||||
|
|
@ -480,8 +490,10 @@ async fn async_main(opts: Opts, cancel: CancellationToken) -> anyhow::Result<()>
|
||||||
cancellation_token: Some(cancel.clone()),
|
cancellation_token: Some(cancel.clone()),
|
||||||
#[cfg(feature = "disable-upload")]
|
#[cfg(feature = "disable-upload")]
|
||||||
disable_upload: opts.disable_upload,
|
disable_upload: opts.disable_upload,
|
||||||
// TODO: expose
|
ratelimits: LimitsConfig {
|
||||||
ratelimits: Default::default(),
|
upload_bps: opts.ratelimit_upload_bps,
|
||||||
|
download_bps: opts.ratelimit_download_bps,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let stats_printer = |session: Arc<Session>| async move {
|
let stats_printer = |session: Arc<Session>| async move {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue