use flate2::bufread::GzDecoder;
use globset::{Glob, GlobSet, GlobSetBuilder};
use nix::libc;
-use proxmox_http::{client::sync::Client, HttpClient, HttpOptions};
+use proxmox_http::{client::sync::Client, HttpClient, HttpOptions, ProxyConfig};
use proxmox_sys::fs::file_get_contents;
use crate::{
let options = HttpOptions {
user_agent: Some("proxmox-offline-mirror 0.1".to_string()),
+ proxy_config: ProxyConfig::from_proxy_env()?,
..Default::default()
}; // TODO actually read version ;)
use anyhow::{bail, format_err, Error};
use proxmox_http::client::sync::Client;
-use proxmox_http::{HttpClient, HttpOptions};
+use proxmox_http::{HttpClient, HttpOptions, ProxyConfig};
use proxmox_subscription::SubscriptionStatus;
use proxmox_subscription::{
sign::{SignRequest, SignedResponse},
// TODO add version?
const USER_AGENT: &str = "proxmox-offline-mirror";
-fn client() -> Client {
+fn client() -> Result<Client, Error> {
let options = HttpOptions {
user_agent: Some(USER_AGENT.to_string()),
+ proxy_config: ProxyConfig::from_proxy_env()?,
..Default::default()
};
- Client::new(options)
+ Ok(Client::new(options))
}
pub fn extract_mirror_key(keys: &[SubscriptionKey]) -> Result<SubscriptionKey, Error> {
key.key.clone(),
key.server_id.clone(),
PRODUCT_URL.to_string(),
- client(),
+ 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 = client().post(
+ let res = client()?.post(
"https://shop.proxmox.com/proxmox-subscription/sign",
Some(serde_json::to_vec(&request)?.as_slice()),
Some("text/json"),
mirror_key.key,
mirror_key.server_id,
PRODUCT_URL.to_string(),
- client(),
+ client()?,
)
}