aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-03-09 14:35:59 +0100
committerAlex Auvolat <alex@adnab.me>2023-03-09 14:35:59 +0100
commit3acf041d00a20b6c139e2a0202dafb29a1deecd4 (patch)
tree1d46489810e9c7943cf88181eab067ee0598494f
parent326fd2dada42221601bce87bc97afc2d948bece8 (diff)
downloadwgautomesh-3acf041d00a20b6c139e2a0202dafb29a1deecd4.tar.gz
wgautomesh-3acf041d00a20b6c139e2a0202dafb29a1deecd4.zip
less useless actions
-rw-r--r--src/main.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 192dd91..091335f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -588,8 +588,14 @@ impl State {
};
if !endpoints.is_empty() {
- let endpoint = endpoints[i % endpoints.len()];
- info!("Configure {} with endpoint {}", peer_cfg.pubkey, endpoint.0);
+ let endpoint = endpoints[i % endpoints.len()].0;
+
+ if self.peers.get(&peer_cfg.pubkey).map(|x| x.endpoint == Some(endpoint)).unwrap_or(false) {
+ // Skip if we are already using that endpoint
+ continue;
+ }
+
+ info!("Configure {} with endpoint {}", peer_cfg.pubkey, endpoint);
Command::new("wg")
.args([
"set",
@@ -597,7 +603,7 @@ impl State {
"peer",
&peer_cfg.pubkey,
"endpoint",
- &endpoint.0.to_string(),
+ &endpoint.to_string(),
"persistent-keepalive",
"10",
"allowed-ips",