From 57623876dea89cd19badc31c25683ef4fc3bf84e Mon Sep 17 00:00:00 2001 From: Andrey Golovizin Date: Wed, 14 Jul 2021 17:25:04 +0200 Subject: [PATCH] Add support for multiple endpoint IPs --- src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7185043..c929183 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,11 +169,6 @@ fn write_config( config: &WireguardConfig, keys: &WireguardKeyPair, ) -> Result<(), anyhow::Error> { - let mut endpoint_addrs = config.data.endpoint.to_socket_addrs()?; - let endpoint_addr = endpoint_addrs - .next() - .ok_or_else(|| anyhow::anyhow!("no endpoint address received"))?; - debug!("endpoint_addr = {:?}", &endpoint_addr); writeln!(output, "[Interface]")?; writeln!(output, "PrivateKey = {}", &keys.private_key)?; let addresses = config.data.addresses()?; @@ -192,7 +187,9 @@ fn write_config( writeln!(output, "[Peer]")?; writeln!(output, "PublicKey = {}", &config.data.public_key)?; - writeln!(output, "Endpoint = {}", &endpoint_addr)?; + + let endpoint_addrs = config.data.endpoint.to_socket_addrs()?; + write_list(output, "Endpoint = ", endpoint_addrs)?; let allowed_ips: &[&str] = if config_opts.no_ipv6 { &["0.0.0.0", "::0"] } else { &["0.0.0.0"] }; write_list(output, "AllowedIPs = ", allowed_ips)?;