aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/interface/config.rs17
-rwxr-xr-xtools/wg-quick.bash2
2 files changed, 8 insertions, 11 deletions
diff --git a/src/interface/config.rs b/src/interface/config.rs
index 4836862..3dda7a9 100644
--- a/src/interface/config.rs
+++ b/src/interface/config.rs
@@ -250,7 +250,6 @@ impl ConfigurationService {
let _ = state.pubkey_map.insert(info.pub_key, peer_ref.clone());
state.router.add_allowed_ips(&info.allowed_ips, &peer_ref);
};
-
},
UpdateEvent::RemoveAllPeers => {
state.pubkey_map.clear();
@@ -258,17 +257,15 @@ impl ConfigurationService {
state.router.clear();
},
UpdateEvent::RemovePeer(pub_key) => {
- if let Some(peer_ref) = state.pubkey_map.remove(&pub_key) {
- let peer = peer_ref.borrow();
- let indices = peer.get_mapped_indices();
+ let peer_ref = state.pubkey_map.remove(&pub_key)
+ .ok_or_else(|| err_msg("trying to remove nonexistent peer"))?;
+ let peer = peer_ref.borrow();
+ let indices = peer.get_mapped_indices();
- for index in indices {
- let _ = state.index_map.remove(&index);
- }
- state.router.remove_allowed_ips(&peer.info.allowed_ips);
- } else {
- info!("RemovePeer request for nonexistent peer.");
+ for index in indices {
+ let _ = state.index_map.remove(&index);
}
+ state.router.remove_allowed_ips(&peer.info.allowed_ips);
},
}
Ok(())
diff --git a/tools/wg-quick.bash b/tools/wg-quick.bash
index 562b138..a55bdf1 100755
--- a/tools/wg-quick.bash
+++ b/tools/wg-quick.bash
@@ -133,7 +133,7 @@ add_route() {
if [[ -n $TABLE && $TABLE != auto ]]; then
echo "add to table not supported"
- elif [[ $1 == */0 ]]; then
+ elif [[ $1 == */0 ]]; then # TODO add default routes for ipv4/ipv6 separately. right now it overlaps and causes 'splosions.
add_default "$1"
else
cmd route add "$1" "$ip"