also set up peers if endpoint is not known
This commit is contained in:
parent
c2940724de
commit
298a01d710
1 changed files with 15 additions and 2 deletions
17
src/main.rs
17
src/main.rs
|
@ -379,8 +379,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endpoints.sort();
|
endpoints.sort();
|
||||||
if !endpoints.is_empty() {
|
if let Some(endpoint) = endpoints.get(i % endpoints.len()) {
|
||||||
let endpoint = endpoints[i % endpoints.len()];
|
|
||||||
info!("Configure {} with endpoint {}", peer.pubkey, endpoint.0);
|
info!("Configure {} with endpoint {}", peer.pubkey, endpoint.0);
|
||||||
Command::new("wg")
|
Command::new("wg")
|
||||||
.args([
|
.args([
|
||||||
|
@ -396,6 +395,20 @@ impl State {
|
||||||
&format!("{}/32", peer.address),
|
&format!("{}/32", peer.address),
|
||||||
])
|
])
|
||||||
.output()?;
|
.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(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue