From 190a6745813e1bc5a6d7e866e9740a5433a33b0f Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 3 Dec 2024 10:10:25 +0800 Subject: [PATCH] init xhost --- ecstore/src/utils/net.rs | 24 ++++++++++++++++++++++++ rustfs/src/main.rs | 8 ++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ecstore/src/utils/net.rs b/ecstore/src/utils/net.rs index a1ebcf428..52d6d0151 100644 --- a/ecstore/src/utils/net.rs +++ b/ecstore/src/utils/net.rs @@ -105,6 +105,30 @@ pub(crate) fn must_get_local_ips() -> Result> { } } +pub struct XHost { + pub name: String, + pub port: u16, + pub is_port_set: bool, +} + +impl ToString for XHost { + fn to_string(&self) -> String { + if !self.is_port_set { + self.name.clone() + } else { + join_host_port(&self.name, self.port) + } + } +} + +fn join_host_port(host: &str, port: u16) -> String { + if host.contains(':') { + format!("[{}]:{}", host, port) + } else { + format!("{}:{}", host, port) + } +} + #[cfg(test)] mod test { use std::net::Ipv4Addr; diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index fd741c2c0..0c2f6bc17 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -208,10 +208,10 @@ async fn run(opt: config::Opt) -> Result<()> { })?; warn!(" init store success!"); - new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| { - error!("new_global_notification_sys faild {:?}", &err); - Error::from_string(err.to_string()) - })?; + // new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| { + // error!("new_global_notification_sys faild {:?}", &err); + // Error::from_string(err.to_string()) + // })?; // init scanner init_data_scanner().await;