Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/downloader/trauma_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ impl TraumaDownloader {
/// * `timeout_seconds` - Timeout for each download in seconds
pub fn new(max_concurrent: usize, retries: usize, timeout_seconds: u64) -> Self {
let client = reqwest::Client::builder()
.tls_backend_preconfigured(
crate::utils::http::tls_client_config().expect("Failed to configure download TLS"),
)
.timeout(std::time::Duration::from_secs(timeout_seconds))
.build()
.expect("Failed to create HTTP client");
Expand Down
10 changes: 7 additions & 3 deletions src/utils/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static PROVIDER: Lazy<std::sync::Arc<rustls::crypto::CryptoProvider>> =
Lazy::new(|| std::sync::Arc::new(rustls::crypto::ring::default_provider()));

// Https config error wrapper error
struct HttpsConfigError {
pub(crate) struct HttpsConfigError {
error: Box<dyn std::error::Error + Send + Sync>,
}
impl fmt::Display for HttpsConfigError {
Expand All @@ -143,7 +143,7 @@ impl std::error::Error for HttpsConfigError {
}
}

fn https_config() -> Result<hyper_rustls::HttpsConnector<HttpConnector>, HttpsConfigError> {
pub(crate) fn tls_client_config() -> Result<ClientConfig, HttpsConfigError> {
let provider = PROVIDER.clone();
let tls: rustls::ClientConfig;
#[cfg(feature = "rustls-platform-verifier")]
Expand Down Expand Up @@ -184,8 +184,12 @@ fn https_config() -> Result<hyper_rustls::HttpsConnector<HttpConnector>, HttpsCo
{
compile_error!("No TLS backend enabled");
}
Ok(tls)
}

fn https_config() -> Result<hyper_rustls::HttpsConnector<HttpConnector>, HttpsConfigError> {
Ok(hyper_rustls::HttpsConnectorBuilder::new()
.with_tls_config(tls)
.with_tls_config(tls_client_config()?)
.https_or_http()
.enable_http1()
.enable_http2()
Expand Down
16 changes: 6 additions & 10 deletions src/websdk/repo/provider/fdroid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,12 @@ impl FDroidProvider {
match reader.read_event() {
Err(e) => return Err(Box::new(e)),
Ok(Event::Eof) => return Ok((package_id, Vec::new())),
Ok(Event::Start(e)) => {
if e.name().as_ref() == b"application" {
for attr in e.attributes().filter_map(|id| id.ok()) {
if attr.key.as_ref() == b"id" {
package_id =
String::from_utf8_lossy(attr.value.as_ref()).to_string();
let releases =
FDroidProvider::decode_release_xml(reader, url).await?;
return Ok((package_id, releases));
}
Ok(Event::Start(e)) if e.name().as_ref() == b"application" => {
for attr in e.attributes().filter_map(|id| id.ok()) {
if attr.key.as_ref() == b"id" {
package_id = String::from_utf8_lossy(attr.value.as_ref()).to_string();
let releases = FDroidProvider::decode_release_xml(reader, url).await?;
return Ok((package_id, releases));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/websdk/repo/provider/lsposed_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ mod tests {
.await;

let id_map = AppDataMap::from([(ANDROID_APP_TYPE, "com.agoines.relaxhelp")]);
let proxy_url = format!("{} -> {}", LSPOSED_REPO_API_URL, server.url());
let hub_data = HubDataMap::from([("proxy_url", proxy_url.as_str())]);
let proxy_url = format!("{} -> {}/modules.json", LSPOSED_REPO_API_URL, server.url());
let hub_data = HubDataMap::from([(REVERSE_PROXY, proxy_url.as_str())]);

let lsposed_provider = LsposedRepoProvider::new();
assert!(lsposed_provider
Expand All @@ -206,8 +206,8 @@ mod tests {
.await;

let id_map = AppDataMap::from([(ANDROID_APP_TYPE, "com.agoines.relaxhelp")]);
let proxy_url = format!("{} -> {}", LSPOSED_REPO_API_URL, server.url());
let hub_data = HubDataMap::from([("proxy_url", proxy_url.as_str())]);
let proxy_url = format!("{} -> {}/modules.json", LSPOSED_REPO_API_URL, server.url());
let hub_data = HubDataMap::from([(REVERSE_PROXY, proxy_url.as_str())]);

let lsposed_provider = LsposedRepoProvider::new();
let releases = lsposed_provider
Expand Down