Skip to content

Commit

Permalink
Filter out IPv6 addresses when determining local address
Browse files Browse the repository at this point in the history
Closes #34
  • Loading branch information
mbr committed Jan 8, 2024
1 parent 08aeb4c commit cd5814b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ async fn main() -> anyhow::Result<()> {
)
.to_socket_addrs()
.ok()
.and_then(|addrs| addrs.into_iter().next())
.ok_or_else(|| anyhow::anyhow!("failed to resolve local hostname"))?;
.and_then(|addrs| addrs.into_iter().find(SocketAddr::is_ipv4))
.ok_or_else(|| anyhow::anyhow!("failed to resolve local hostname to ipv4"))?;
dummy_addr.ip()
} else {
[127, 0, 0, 1].into()
};

let local_addr = SocketAddr::from((local_ip, cfg.reverse_proxy.http_bind.port()));
// TODO: Fix (see #34).
let local_addr = SocketAddr::from(([127, 0, 0, 1], cfg.reverse_proxy.http_bind.port()));

info!(%local_addr, "guessing local registry address");

let reverse_proxy = ReverseProxy::new(auth_provider.clone());
Expand Down

0 comments on commit cd5814b

Please sign in to comment.