aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 15896a4..855cb39 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -379,8 +379,7 @@ impl State {
}
}
endpoints.sort();
- if !endpoints.is_empty() {
- let endpoint = endpoints[i % endpoints.len()];
+ if let Some(endpoint) = endpoints.get(i % endpoints.len()) {
info!("Configure {} with endpoint {}", peer.pubkey, endpoint.0);
Command::new("wg")
.args([
@@ -396,6 +395,20 @@ impl State {
&format!("{}/32", peer.address),
])
.output()?;
+ } else {
+ info!("Configure {} with no known endpoint", peer.pubkey);
+ Command::new("wg")
+ .args([
+ "set",
+ &daemon.config.interface,
+ "peer",
+ &peer.pubkey,
+ "persistent-keepalive",
+ "20",
+ "allowed-ips",
+ &format!("{}/32", peer.address),
+ ])
+ .output()?;
}
}
Ok(())