-mod client {
- use anyhow::{format_err, Error};
- use http::Response;
-
- pub(crate) struct UreqClient {
- pub user_agent: String,
- pub proxy: Option<String>,
- }
-
- impl UreqClient {
- fn agent(&self) -> Result<ureq::Agent, Error> {
- let mut builder = ureq::AgentBuilder::new();
- if let Some(proxy) = &self.proxy {
- builder = builder.proxy(ureq::Proxy::new(proxy)?);
- }
-
- Ok(builder.build())
- }
-
- fn exec_request(
- &self,
- req: ureq::Request,
- body: Option<&str>,
- ) -> Result<Response<String>, Error> {
- let req = req.set("User-Agent", &self.user_agent);
- let res = match body {
- Some(body) => req.send_string(body),
- None => req.call(),
- }?;
-
- let mut builder = http::response::Builder::new()
- .status(http::status::StatusCode::from_u16(res.status())?);
-
- for header in res.headers_names() {
- if let Some(value) = res.header(&header) {
- builder = builder.header(header, value);
- }
- }
- builder
- .body(res.into_string()?)
- .map_err(|err| format_err!("Failed to convert HTTP response - {err}"))
- }
- }
-
- impl proxmox_http::HttpClient<String> for UreqClient {
- fn get(&self, uri: &str) -> Result<Response<String>, Error> {
- let req = self.agent()?.get(uri);
-
- self.exec_request(req, None)
- }
-
- fn post(
- &self,
- uri: &str,
- body: Option<&str>,
- content_type: Option<&str>,
- ) -> Result<Response<String>, Error> {
- let mut req = self.agent()?.post(uri);
- if let Some(content_type) = content_type {
- req = req.set("Content-Type", content_type);
- }
-
- self.exec_request(req, body)
- }
- }
-}
-
#[perlmod::package(name = "Proxmox::RS::Subscription")]
mod export {
use anyhow::{bail, format_err, Error};
use proxmox_subscription::SubscriptionInfo;
use proxmox_sys::fs::CreateOptions;
- use super::client::UreqClient;
+ use proxmox_http::ProxyConfig;
+ use proxmox_http::HttpOptions;
+ use proxmox_http::client::sync::Client;
#[export]
fn read_subscription(path: String) -> Result<Option<SubscriptionInfo>, Error> {
user_agent: String,
proxy: Option<String>,
) -> Result<SubscriptionInfo, Error> {
- let client = UreqClient { user_agent, proxy };
+ let proxy_config = match proxy {
+ Some(url) => Some(ProxyConfig::parse_proxy_url(&url)?),
+ None => None,
+ };
+ let options = HttpOptions { proxy_config, user_agent: Some(user_agent) , ..Default::default() };
+ let client = Client::new(options);
proxmox_subscription::check::check_subscription(key, server_id, product_url, client)
}
serde = "1.0"
serde_bytes = "0.11.3"
serde_json = "1.0"
-ureq = { version = "2.4", features = ["native-certs"] }
url = "2"
perlmod = { version = "0.13", features = [ "exporter" ] }
proxmox-acme-rs = { version = "0.4", features = ["client"] }
proxmox-apt = "0.9"
-proxmox-http = { version = "0.6.4", features = ["client-trait"] }
+proxmox-http = { version = "0.7", features = ["client-sync", "client-trait"] }
proxmox-subscription = "0.2"
proxmox-sys = "0.4"
proxmox-tfa = { version = "2.1", features = ["api"] }
librust-proxmox-acme-rs-0.4+client-dev,
librust-proxmox-acme-rs-0.4+default-dev,
librust-proxmox-apt-0.9+default-dev,
- librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~),
- librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~),
+ 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-subscription-0.2+default-dev,
librust-proxmox-sys-0.4+default-dev,
librust-proxmox-tfa-2+api-dev (>= 2.1-~~),
librust-serde-1+default-dev,
librust-serde-bytes-0.11+default-dev (>= 0.11.3-~~),
librust-serde-json-1+default-dev,
- librust-ureq-2+default-dev (>= 2.4-~~),
- librust-ureq-2+native-certs-dev (>= 2.4-~~),
librust-url-2+default-dev,
Standards-Version: 4.3.0
Homepage: https://www.proxmox.com
serde = "1.0"
serde_bytes = "0.11"
serde_json = "1.0"
-ureq = { version = "2.4", features = ["native-certs"] }
url = "2"
perlmod = { version = "0.13", features = [ "exporter" ] }
proxmox-apt = "0.9"
-proxmox-http = { version = "0.6.4", features = ["client-trait"] }
+proxmox-http = { version = "0.7", features = ["client-sync", "client-trait"] }
proxmox-openid = "0.9.5"
proxmox-subscription = "0.2"
proxmox-sys = "0.4"
librust-perlmod-0.13+default-dev,
librust-perlmod-0.13+exporter-dev,
librust-proxmox-apt-0.9+default-dev,
- librust-proxmox-http-0.6+client-trait-dev (>= 0.6.4-~~),
- librust-proxmox-http-0.6+default-dev (>= 0.6.4-~~),
+ 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-openid-0.9+default-dev (>= 0.9.5-~~),
librust-proxmox-subscription-0.2+default-dev,
librust-proxmox-sys-0.4+default-dev,
librust-serde-1+default-dev,
librust-serde-bytes-0.11+default-dev,
librust-serde-json-1+default-dev,
- librust-ureq-2+default-dev (>= 2.4-~~),
- librust-ureq-2+native-certs-dev (>= 2.4-~~),
librust-url-2+default-dev,
Maintainer: Proxmox Support Team <support@proxmox.com>
Standards-Version: 4.5.1