init xhost

This commit is contained in:
weisd
2024-12-03 10:10:25 +08:00
parent 43a0a35f22
commit 190a674581
2 changed files with 28 additions and 4 deletions
+24
View File
@@ -105,6 +105,30 @@ pub(crate) fn must_get_local_ips() -> Result<Vec<IpAddr>> {
} }
} }
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)] #[cfg(test)]
mod test { mod test {
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
+4 -4
View File
@@ -208,10 +208,10 @@ async fn run(opt: config::Opt) -> Result<()> {
})?; })?;
warn!(" init store success!"); warn!(" init store success!");
new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| { // new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| {
error!("new_global_notification_sys faild {:?}", &err); // error!("new_global_notification_sys faild {:?}", &err);
Error::from_string(err.to_string()) // Error::from_string(err.to_string())
})?; // })?;
// init scanner // init scanner
init_data_scanner().await; init_data_scanner().await;