First pass to implement socks5 support

This commit is contained in:
Igor Katson 2024-08-08 00:35:32 +01:00
parent 8c16239a0e
commit 70dcb2e6cb
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
11 changed files with 195 additions and 23 deletions

View file

@ -115,6 +115,13 @@ struct Opts {
/// If you use it, you know what you are doing.
#[arg(long)]
experimental_mmap_storage: bool,
/// Provide a socks5 URL.
/// The format is socks5://[username:password]@host:port
///
/// Alternatively, set this as an environment variable RQBIT_SOCKS_PROXY_URL
#[arg(long)]
socks_url: Option<String>,
}
#[derive(Parser)]
@ -281,6 +288,10 @@ async fn async_main(opts: Opts) -> anyhow::Result<()> {
Err(e) => warn!("failed increasing open file limit: {:#}", e),
};
let socks_url = opts
.socks_url
.or_else(|| std::env::var("RQBIT_SOCKS_PROXY_URL").ok());
let mut sopts = SessionOptions {
disable_dht: opts.disable_dht,
disable_dht_persistence: opts.disable_dht_persistence,
@ -320,7 +331,7 @@ async fn async_main(opts: Opts) -> anyhow::Result<()> {
wrap(FilesystemStorageFactory::default()).boxed()
}
}),
socks_proxy: None,
socks_proxy_url: socks_url,
};
let stats_printer = |session: Arc<Session>| async move {