fix IPv6 listeners

Niko PLP 2 years ago
parent 18122fb880
commit 5b1c778a25
  1. 13
      p2p-broker/src/server_ws.rs
  2. 5
      p2p-net/src/types.rs

@ -256,8 +256,8 @@ fn upgrade_ws_or_serve_app(
Err(make_error(StatusCode::FORBIDDEN)) Err(make_error(StatusCode::FORBIDDEN))
} }
const LOCAL_HOSTS: [&str; 3] = ["localhost", "127.0.0.1", "::1"]; const LOCAL_HOSTS: [&str; 3] = ["localhost", "127.0.0.1", "[::1]"];
const LOCAL_URLS: [&str; 3] = ["http://localhost", "http://127.0.0.1", "http://::1"]; const LOCAL_URLS: [&str; 3] = ["http://localhost", "http://127.0.0.1", "http://[::1]"];
const APP_NG_ONE_URL: &str = "https://app.nextgraph.one"; const APP_NG_ONE_URL: &str = "https://app.nextgraph.one";
impl Callback for SecurityCallback { impl Callback for SecurityCallback {
@ -743,7 +743,9 @@ pub async fn run_server_v0(
.map(SocketAddr::to_string) .map(SocketAddr::to_string)
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(", "); .join(", ");
let tcp_listener = TcpListener::bind(addrs.0.as_slice()).await.map_err(|e| {
for addr in addrs.0 {
let tcp_listener = TcpListener::bind(addr).await.map_err(|e| {
log_err!( log_err!(
"cannot bind to {} with addresses {} : {}", "cannot bind to {} with addresses {} : {}",
addrs.1, addrs.1,
@ -751,11 +753,12 @@ pub async fn run_server_v0(
e.to_string() e.to_string()
) )
})?; })?;
log_info!("Listening on {} {}", addrs.1, addrs_string);
listeners.push(tcp_listener); listeners.push(tcp_listener);
} }
log_info!("Listening on {} {}", addrs.1, addrs_string);
}
// select on all listeners // select on all listeners
let mut incoming = futures::stream::select_all( let mut incoming = futures::stream::select_all(
listeners listeners

@ -459,7 +459,10 @@ impl IP {
impl fmt::Display for IP { impl fmt::Display for IP {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let t: IpAddr = self.try_into().unwrap(); let t: IpAddr = self.try_into().unwrap();
write!(f, "{}", t) match self {
IP::IPv4(_) => write!(f, "{}", t),
IP::IPv6(_) => write!(f, "[{}]", t),
}
} }
} }

Loading…
Cancel
Save