mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-25 05:26:50 +00:00
fix
This commit is contained in:
@@ -70,23 +70,11 @@ impl UserAgent {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_windows_platform() -> String {
|
fn get_windows_platform() -> String {
|
||||||
// Priority to using sysinfo to get versions
|
// Priority to using sysinfo to get versions
|
||||||
if let Some(version) = System::os_version() {
|
let version = match System::os_version() {
|
||||||
format!("Windows NT {}", version)
|
Some(version) => version,
|
||||||
} else {
|
None => "Windows NT Unknown".to_string(),
|
||||||
// Fallback to cmd /c ver
|
};
|
||||||
let output = std::process::Command::new("cmd")
|
format!("Windows NT {}", version)
|
||||||
.args(&["/C", "ver"])
|
|
||||||
.output()
|
|
||||||
.unwrap_or_default();
|
|
||||||
let version = String::from_utf8_lossy(&output.stdout);
|
|
||||||
let version = version
|
|
||||||
.lines()
|
|
||||||
.next()
|
|
||||||
.unwrap_or("Windows NT 10.0")
|
|
||||||
.replace("Microsoft Windows [Version ", "")
|
|
||||||
.replace("]", "");
|
|
||||||
format!("Windows NT {}", version.trim())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@@ -131,11 +119,11 @@ impl UserAgent {
|
|||||||
impl fmt::Display for UserAgent {
|
impl fmt::Display for UserAgent {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if self.service == ServiceType::Basis {
|
if self.service == ServiceType::Basis {
|
||||||
return write!(f, "Mozilla/5.0 ({}; {}) Rustfs/{}", self.os_platform, self.arch, self.version);
|
return write!(f, "Mozilla/5.0 ({}; {}) RustFS/{}", self.os_platform, self.arch, self.version);
|
||||||
}
|
}
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Mozilla/5.0 ({}; {}) Rustfs/{} ({})",
|
"Mozilla/5.0 ({}; {}) RustFS/{} ({})",
|
||||||
self.os_platform,
|
self.os_platform,
|
||||||
self.arch,
|
self.arch,
|
||||||
self.version,
|
self.version,
|
||||||
@@ -157,7 +145,7 @@ mod tests {
|
|||||||
fn test_user_agent_format_basis() {
|
fn test_user_agent_format_basis() {
|
||||||
let ua = get_user_agent(ServiceType::Basis);
|
let ua = get_user_agent(ServiceType::Basis);
|
||||||
assert!(ua.starts_with("Mozilla/5.0"));
|
assert!(ua.starts_with("Mozilla/5.0"));
|
||||||
assert!(ua.contains("Rustfs/1.0.0"));
|
assert!(ua.contains("RustFS/1.0.0"));
|
||||||
println!("User-Agent: {}", ua);
|
println!("User-Agent: {}", ua);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +153,7 @@ mod tests {
|
|||||||
fn test_user_agent_format_core() {
|
fn test_user_agent_format_core() {
|
||||||
let ua = get_user_agent(ServiceType::Core);
|
let ua = get_user_agent(ServiceType::Core);
|
||||||
assert!(ua.starts_with("Mozilla/5.0"));
|
assert!(ua.starts_with("Mozilla/5.0"));
|
||||||
assert!(ua.contains("Rustfs/1.0.0 (core)"));
|
assert!(ua.contains("RustFS/1.0.0 (core)"));
|
||||||
println!("User-Agent: {}", ua);
|
println!("User-Agent: {}", ua);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +161,7 @@ mod tests {
|
|||||||
fn test_user_agent_format_event() {
|
fn test_user_agent_format_event() {
|
||||||
let ua = get_user_agent(ServiceType::Event);
|
let ua = get_user_agent(ServiceType::Event);
|
||||||
assert!(ua.starts_with("Mozilla/5.0"));
|
assert!(ua.starts_with("Mozilla/5.0"));
|
||||||
assert!(ua.contains("Rustfs/1.0.0 (event)"));
|
assert!(ua.contains("RustFS/1.0.0 (event)"));
|
||||||
println!("User-Agent: {}", ua);
|
println!("User-Agent: {}", ua);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +169,7 @@ mod tests {
|
|||||||
fn test_user_agent_format_logger() {
|
fn test_user_agent_format_logger() {
|
||||||
let ua = get_user_agent(ServiceType::Logger);
|
let ua = get_user_agent(ServiceType::Logger);
|
||||||
assert!(ua.starts_with("Mozilla/5.0"));
|
assert!(ua.starts_with("Mozilla/5.0"));
|
||||||
assert!(ua.contains("Rustfs/1.0.0 (logger)"));
|
assert!(ua.contains("RustFS/1.0.0 (logger)"));
|
||||||
println!("User-Agent: {}", ua);
|
println!("User-Agent: {}", ua);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +177,7 @@ mod tests {
|
|||||||
fn test_user_agent_format_custom() {
|
fn test_user_agent_format_custom() {
|
||||||
let ua = get_user_agent(ServiceType::Custom("monitor".to_string()));
|
let ua = get_user_agent(ServiceType::Custom("monitor".to_string()));
|
||||||
assert!(ua.starts_with("Mozilla/5.0"));
|
assert!(ua.starts_with("Mozilla/5.0"));
|
||||||
assert!(ua.contains("Rustfs/1.0.0 (monitor)"));
|
assert!(ua.contains("RustFS/1.0.0 (monitor)"));
|
||||||
println!("User-Agent: {}", ua);
|
println!("User-Agent: {}", ua);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use atomic_enum::atomic_enum;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
#[cfg(unix)]
|
||||||
use tokio::signal::unix::{SignalKind, signal};
|
use tokio::signal::unix::{SignalKind, signal};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user