Skip to content

Commit

Permalink
fix(endpoint): return from 127.0.0.1 from our_endpoint api if no loca…
Browse files Browse the repository at this point in the history
…l addr was specified
  • Loading branch information
bochaco committed Sep 14, 2020
1 parent c5c13f5 commit bae08fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use super::{
};
use futures::lock::Mutex;
use log::trace;
use std::{net::SocketAddr, sync::Arc};
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
sync::Arc,
};

/// Host name of the Quic communication certificate used by peers
// FIXME: make it configurable
Expand All @@ -34,7 +37,10 @@ impl Endpoint {
quic_incoming: quinn::Incoming,
client_cfg: quinn::ClientConfig,
) -> Result<Self> {
let local_addr = quic_endpoint.local_addr()?;
let mut local_addr = quic_endpoint.local_addr()?;
if local_addr.ip().is_unspecified() {
local_addr.set_ip(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
}

Ok(Self {
local_addr,
Expand Down

0 comments on commit bae08fb

Please sign in to comment.