[pbs-devel] [PATCH proxmox-offline-mirror] actually include version in user-agent
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Mar 3 12:40:55 CET 2023
as originally intended.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
if desired, could use option_env + a fallback to some unknown version string
(that code path would only trigger if rustc is manually invoked, not via cargo)
src/mirror.rs | 5 ++++-
src/subscription.rs | 7 ++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/mirror.rs b/src/mirror.rs
index 787e223..cd98e3b 100644
--- a/src/mirror.rs
+++ b/src/mirror.rs
@@ -63,7 +63,10 @@ impl TryInto<ParsedMirrorConfig> for MirrorConfig {
let key = file_get_contents(Path::new(&self.key_path))?;
let options = HttpOptions {
- user_agent: Some("proxmox-offline-mirror 0.1".to_string()),
+ user_agent: Some(format!(
+ "proxmox-offline-mirror/{}",
+ env!("CARGO_PKG_VERSION")
+ )),
proxy_config: ProxyConfig::from_proxy_env()?,
..Default::default()
}; // TODO actually read version ;)
diff --git a/src/subscription.rs b/src/subscription.rs
index d186a95..8e3fa51 100644
--- a/src/subscription.rs
+++ b/src/subscription.rs
@@ -12,12 +12,13 @@ use crate::{config::SubscriptionKey, types::ProductType};
// TODO: Update with final, public URL
const PRODUCT_URL: &str = "-";
-// TODO add version?
-const USER_AGENT: &str = "proxmox-offline-mirror";
fn client() -> Result<Client, Error> {
let options = HttpOptions {
- user_agent: Some(USER_AGENT.to_string()),
+ user_agent: Some(format!(
+ "proxmox-offline-mirror/{}",
+ env!("CARGO_PKG_VERSION")
+ )),
proxy_config: ProxyConfig::from_proxy_env()?,
..Default::default()
};
--
2.30.2
More information about the pbs-devel
mailing list