Checkpoint

This commit is contained in:
Aram 🍐 2021-10-20 19:04:56 -04:00
parent fb50ee7113
commit 282d4f48eb
4 changed files with 81 additions and 7 deletions

View file

@ -90,7 +90,7 @@ impl WireGuardTunnel {
virtual_port: VirtualPort,
sender: tokio::sync::mpsc::Sender<Vec<u8>>,
) -> anyhow::Result<()> {
let existing = self.virtual_port_ip_tx.contains_key(&virtual_port);
let existing = self.is_registered(virtual_port);
if existing {
Err(anyhow::anyhow!("Cannot register virtual interface with virtual port {} because it is already registered", virtual_port))
} else {
@ -99,6 +99,10 @@ impl WireGuardTunnel {
}
}
pub fn is_registered(&self, virtual_port: VirtualPort) -> bool {
self.virtual_port_ip_tx.contains_key(&virtual_port)
}
/// Register a virtual interface (using its assigned virtual port) with the given IP packet `Sender`.
pub async fn register_sink_interface(
&self,