Fix ipv6 endpoints

This commit is contained in:
Tilo Spannagel 2021-12-20 17:37:57 +00:00 committed by GitHub
parent 81264916e5
commit ce9cfce8fc

View file

@ -37,10 +37,13 @@ impl WireGuardTunnel {
pub async fn new(config: &Config) -> anyhow::Result<Self> { pub async fn new(config: &Config) -> anyhow::Result<Self> {
let source_peer_ip = config.source_peer_ip; let source_peer_ip = config.source_peer_ip;
let peer = Self::create_tunnel(config)?; let peer = Self::create_tunnel(config)?;
let udp = UdpSocket::bind("0.0.0.0:0")
.await
.with_context(|| "Failed to create UDP socket for WireGuard connection")?;
let endpoint = config.endpoint_addr; let endpoint = config.endpoint_addr;
let udp = UdpSocket::bind(match endpoint {
SocketAddr::V4(_) => "0.0.0.0:0",
SocketAddr::V6(_) => "[::]:0",
})
.await
.with_context(|| "Failed to create UDP socket for WireGuard connection")?;
let virtual_port_ip_tx = Default::default(); let virtual_port_ip_tx = Default::default();
Ok(Self { Ok(Self {