public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-offline-mirror] actually include version in user-agent
@ 2023-03-03 11:40 Fabian Grünbichler
  2023-03-07  8:43 ` Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Grünbichler @ 2023-03-03 11:40 UTC (permalink / raw)
  To: pbs-devel

as originally intended.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-07  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 11:40 [pbs-devel] [PATCH proxmox-offline-mirror] actually include version in user-agent Fabian Grünbichler
2023-03-07  8:43 ` Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal