bzip2 = "0.4"
flate2 = "1.0.22"
hex = "0.4.3"
-hyper = "0.14"
lazy_static = "1.4"
nix = "0.24"
openssl = "0.10"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sequoia-openpgp = { version = "1.7" }
-ureq = { version = "2.4.0", features = ["native-certs"] }
walkdir = "2.3.1"
xz2 = "0.1"
proxmox-apt = { version = "0.9.1" }
proxmox-async = "0.4"
-proxmox-http = { version = "0.6.3", features = [ "client", "client-trait", "proxmox-async" ]}
-proxmox-router = { version = "1.1", features = [ "cli" ] }
+proxmox-http = { version = "0.7", features = [ "client-sync", "client-trait" ]}
+proxmox-router = { version = "1.3", features = [ "cli" ], default_features = false }
proxmox-schema = { version = "1.1", features = [ "api-macro" ] }
proxmox-section-config = "1"
proxmox-serde = "0.1"
-proxmox-subscription = { version = "0.2", features = [ "api-types" ] }
+proxmox-subscription = { version = "0.3", features = [ "api-types" ] }
proxmox-sys = { version = "0.4", features = [ "timer" ] }
proxmox-time = { version = "1.1.3" }
librust-bzip2-0.4+default-dev,
librust-flate2-1+default-dev (>= 1.0.22-~~),
librust-hex-0.4+default-dev (>= 0.4.3-~~),
- librust-hyper-0.14+default-dev,
librust-lazy-static-1+default-dev (>= 1.4-~~),
librust-nix-0.24+default-dev,
librust-openssl-0.10+default-dev,
librust-proxmox-apt-0.9+default-dev (>= 0.9.1-~~),
librust-proxmox-async-0.4+default-dev,
- librust-proxmox-http-0.6+client-dev (>= 0.6.3-~~),
- librust-proxmox-http-0.6+client-trait-dev (>= 0.6.3-~~),
- librust-proxmox-http-0.6+default-dev (>= 0.6.3-~~),
- librust-proxmox-http-0.6+proxmox-async-dev (>= 0.6.3-~~),
- librust-proxmox-router-1+cli-dev (>= 1.1-~~),
- librust-proxmox-router-1+default-dev (>= 1.1-~~),
+ librust-proxmox-http-0.7+client-sync-dev,
+ librust-proxmox-http-0.7+client-trait-dev,
+ librust-proxmox-http-0.7+default-dev,
+ librust-proxmox-router-1+cli-dev (>= 1.3-~~),
librust-proxmox-schema-1+api-macro-dev (>= 1.1-~~),
librust-proxmox-schema-1+default-dev (>= 1.1-~~),
librust-proxmox-section-config-1+default-dev,
librust-proxmox-serde-0.1+default-dev,
- librust-proxmox-subscription-0.2+api-types-dev,
- librust-proxmox-subscription-0.2+default-dev,
+ librust-proxmox-subscription-0.3+api-types-dev,
+ librust-proxmox-subscription-0.3+default-dev,
librust-proxmox-sys-0.4+default-dev,
librust-proxmox-sys-0.4+timer-dev,
librust-proxmox-time-1+default-dev (>= 1.1.3-~~),
librust-serde-1+default-dev,
librust-serde-1+derive-dev,
librust-serde-json-1+default-dev,
- librust-ureq-2+default-dev (>= 2.4.0-~~),
- librust-ureq-2+native-certs-dev (>= 2.4.0-~~),
librust-walkdir-2+default-dev (>= 2.3.1-~~),
librust-xz2-0.1+default-dev
Maintainer: Proxmox Support Team <support@proxmox.com>
librust-bzip2-0.4+default-dev,
librust-flate2-1+default-dev (>= 1.0.22-~~),
librust-hex-0.4+default-dev (>= 0.4.3-~~),
- librust-hyper-0.14+default-dev,
librust-lazy-static-1+default-dev (>= 1.4-~~),
librust-nix-0.24+default-dev,
librust-openssl-0.10+default-dev,
librust-proxmox-apt-0.9+default-dev (>= 0.9.1-~~),
librust-proxmox-async-0.4+default-dev,
- librust-proxmox-http-0.6+client-dev (>= 0.6.3-~~),
- librust-proxmox-http-0.6+client-trait-dev (>= 0.6.3-~~),
- librust-proxmox-http-0.6+default-dev (>= 0.6.3-~~),
- librust-proxmox-http-0.6+proxmox-async-dev (>= 0.6.3-~~),
- librust-proxmox-router-1+cli-dev (>= 1.1-~~),
- librust-proxmox-router-1+default-dev (>= 1.1-~~),
+ librust-proxmox-http-0.7+client-sync-dev,
+ librust-proxmox-http-0.7+client-trait-dev,
+ librust-proxmox-http-0.7+default-dev,
+ librust-proxmox-router-1+cli-dev (>= 1.3-~~),
librust-proxmox-schema-1+api-macro-dev (>= 1.1-~~),
librust-proxmox-schema-1+default-dev (>= 1.1-~~),
librust-proxmox-section-config-1+default-dev,
librust-proxmox-serde-0.1+default-dev,
- librust-proxmox-subscription-0.2+api-types-dev,
- librust-proxmox-subscription-0.2+default-dev,
+ librust-proxmox-subscription-0.3+api-types-dev,
+ librust-proxmox-subscription-0.3+default-dev,
librust-proxmox-sys-0.4+default-dev,
librust-proxmox-sys-0.4+timer-dev,
librust-proxmox-time-1+default-dev (>= 1.1.3-~~),
librust-serde-1+default-dev,
librust-serde-1+derive-dev,
librust-serde-json-1+default-dev,
- librust-ureq-2+default-dev (>= 2.4.0-~~),
- librust-ureq-2+native-certs-dev (>= 2.4.0-~~),
librust-walkdir-2+default-dev (>= 2.3.1-~~),
librust-xz2-0.1+default-dev
Provides:
use anyhow::{bail, format_err, Error};
use flate2::bufread::GzDecoder;
use nix::libc;
+use proxmox_http::{client::sync::Client, HttpClient, HttpOptions};
use proxmox_sys::fs::file_get_contents;
-use ureq::Agent;
use crate::{
config::{MirrorConfig, SubscriptionKey},
pub verify: bool,
pub sync: bool,
pub auth: Option<String>,
- pub agent: Agent,
+ pub client: Client,
}
impl TryInto<ParsedMirrorConfig> for MirrorConfig {
let key = file_get_contents(Path::new(&self.key_path))?;
- let agent = ureq::builder()
- .user_agent("proxmox-offline-mirror 0.1") // TODO actually read version ;)
- .build();
+ let options = HttpOptions {
+ user_agent: Some("proxmox-offline-mirror 0.1".to_string()),
+ ..Default::default()
+ }; // TODO actually read version ;)
+
+ let client = Client::new(options);
Ok(ParsedMirrorConfig {
repository,
verify: self.verify,
sync: self.sync,
auth: None,
- agent,
+ client,
})
}
}
///
/// Only fetches and returns data, doesn't store anything anywhere.
fn fetch_repo_file(
- agent: &Agent,
+ client: &Client,
uri: &str,
max_size: Option<u64>,
checksums: Option<&CheckSums>,
) -> Result<FetchResult, Error> {
println!("-> GET '{}'..", uri);
- let request = if let Some(auth) = auth {
- agent.get(uri).set("Authorization", auth)
+ let headers = if let Some(auth) = auth {
+ let mut map = HashMap::new();
+ map.insert("Authorization".to_string(), auth.to_string());
+ Some(map)
} else {
- agent.get(uri)
+ None
};
- let response = request.call()?.into_reader();
+ let response = client.get(uri, headers.as_ref())?;
+ let reader: Box<dyn Read> = response.into_body();
+ let mut reader = reader.take(max_size.unwrap_or(u64::MAX));
let mut data = Vec::new();
- let bytes = response
- .take(max_size.unwrap_or(10_000_000))
- .read_to_end(&mut data)?;
+ reader.read_to_end(&mut data)?;
if let Some(checksums) = checksums {
checksums.verify(&data)?;
}
Ok(FetchResult {
+ fetched: data.len(),
data,
- fetched: bytes,
})
}
let (name, fetched, sig) = if detached {
println!("Fetching Release/Release.gpg files");
let sig = fetch_repo_file(
- &config.agent,
+ &config.client,
&get_dist_url(&config.repository, "Release.gpg"),
None,
None,
config.auth.as_deref(),
)?;
let mut fetched = fetch_repo_file(
- &config.agent,
+ &config.client,
&get_dist_url(&config.repository, "Release"),
Some(32_000_000),
None,
} else {
println!("Fetching InRelease file");
let fetched = fetch_repo_file(
- &config.agent,
+ &config.client,
&get_dist_url(&config.repository, "InRelease"),
Some(32_000_000),
None,
}
} else {
let fetched = fetch_repo_file(
- &config.agent,
+ &config.client,
url,
Some(5_000_000_000),
Some(checksums),
use anyhow::{bail, format_err, Error};
-use hyper::body::Buf;
-use proxmox_http::client::{SimpleHttp, SimpleHttpOptions};
+
+use proxmox_http::client::sync::Client;
+use proxmox_http::{HttpClient, HttpOptions};
use proxmox_subscription::{
sign::{SignRequest, SignedResponse},
SubscriptionInfo,
// TODO add version?
const USER_AGENT: &str = "proxmox-offline-mirror";
-fn simple_http() -> SimpleHttp {
- let options = SimpleHttpOptions {
- proxy_config: None,
+fn client() -> Client {
+ let options = HttpOptions {
user_agent: Some(USER_AGENT.to_string()),
- tcp_keepalive: Some(30),
+ ..Default::default()
};
-
- SimpleHttp::with_options(options)
+ Client::new(options)
}
pub fn extract_mirror_key(keys: &[SubscriptionKey]) -> Result<SubscriptionKey, Error> {
mirror_key.key.clone(),
mirror_key.server_id.clone(),
PRODUCT_URL.to_string(),
- simple_http(),
+ client(),
)?;
offline_keys.retain(|k| k.product() != ProductType::Pom);
if offline_keys.is_empty() {
key.key.clone(),
key.server_id.clone(),
PRODUCT_URL.to_string(),
- simple_http(),
+ client(),
) {
errors = true;
eprintln!("Failed to refresh subscription key {} - {}", key.key, err);
mirror_key: mirror_key.into(),
blobs: offline_keys.into_iter().map(|k| k.into()).collect(),
};
- let res = simple_http()
- .post(
- "https://shop.proxmox.com/proxmox-subscription/sign",
- Some(serde_json::to_string(&request)?),
- Some("text/json"),
- )
- .await?;
+ let res = client().post(
+ "https://shop.proxmox.com/proxmox-subscription/sign",
+ Some(serde_json::to_vec(&request)?.as_slice()),
+ Some("text/json"),
+ None,
+ )?;
if res.status().is_success() {
- let body = res.into_body();
- let res: SignedResponse =
- serde_json::from_reader(hyper::body::aggregate(body).await?.reader())?;
+ let body: Vec<u8> = res.into_body();
+ let res: SignedResponse = serde_json::from_slice(&body)?;
res.verify(&public_key)
} else {
bail!("Refresh failed - {}", res.status());