This commit is contained in:
open-trade
2020-09-20 20:02:42 +08:00
parent ea85fa0bb7
commit a5b4d8027f
3 changed files with 15 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ use hbb_common::{
allow_err,
bytes::{Bytes, BytesMut},
bytes_codec::BytesCodec,
config::Config,
futures_util::{
sink::SinkExt,
stream::{SplitSink, StreamExt},
@@ -296,14 +297,7 @@ impl RendezvousServer {
self.rendezvous_servers = cu
.rendezvous_servers
.drain(..)
.map(|x| {
if !x.contains(":") {
format!("{}:21116", x)
} else {
x
}
})
.filter(|x| x.parse::<std::net::SocketAddr>().is_ok())
.filter(|x| test_if_valid_server(x).is_ok())
.collect();
log::info!(
"configure updated: serial={} rendezvous-servers={:?}",
@@ -564,3 +558,11 @@ impl RendezvousServer {
Ok(())
}
}
pub fn test_if_valid_server(host: &str) -> ResultType<SocketAddr> {
if host.contains(":") {
Config::to_socket_addr(host)
} else {
Config::to_socket_addr(&format!("{}:{}", host, 0))
}
}