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();
|
||||
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(())
|
||||
|
|
Loading…
Reference in a new issue