fix IPv6 listeners

pull/19/head
Niko PLP 1 year ago
parent 149ddee013
commit d23e6a79aa
  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))
}
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_HOSTS: [&str; 3] = ["localhost", "127.0.0.1", "[::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";
impl Callback for SecurityCallback {
@ -743,7 +743,9 @@ pub async fn run_server_v0(
.map(SocketAddr::to_string)
.collect::<Vec<String>>()
.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!(
"cannot bind to {} with addresses {} : {}",
addrs.1,
@ -751,11 +753,12 @@ pub async fn run_server_v0(
e.to_string()
)
})?;
log_info!("Listening on {} {}", addrs.1, addrs_string);
listeners.push(tcp_listener);
}
log_info!("Listening on {} {}", addrs.1, addrs_string);
}
// select on all listeners
let mut incoming = futures::stream::select_all(
listeners

@ -459,7 +459,10 @@ impl IP {
impl fmt::Display for IP {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
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