fix exit switching
@@ -42,26 +42,26 @@ impl KernelInterface {
let prev_ip = self.get_global_device_ip("wg_exit");
+ match prev_ip {
+ Ok(prev_ip) => {
+ if prev_ip != local_ip {
self.run_command(
"ip",
&[
"address",
- "add",
- &format!("{}/{}", local_ip, netmask),
+ "delete",
+ &format!("{}/{}", prev_ip, netmask),
"dev",
"wg_exit",
],
)?;
- match prev_ip {
- Ok(prev_ip) => {
- if prev_ip != local_ip {
self.run_command(
"ip",
&[
"address",
- "delete",
- &format!("{}/{}", prev_ip, netmask),
+ "add",
+ &format!("{}/{}", local_ip, netmask),
"dev",
"wg_exit",
],
@@ -70,6 +70,16 @@ impl KernelInterface {
}
Err(e) => {
warn!("Finding wg exit's current IP returned {}", e);
+ self.run_command(
+ "ip",
+ &[
+ "address",
+ "add",
+ &format!("{}/{}", local_ip, netmask),
+ "dev",
+ "wg_exit",
+ ],
+ )?;
}
}
