From dde58c8f45c9a0c2a14ef9422872e072ffa5d949 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Sun, 11 Apr 2021 13:30:38 +0900 Subject: [PATCH] wgctrl-rs: create /var/run/wireguard if it's not there wireguard-go wasn't writing the name file if the directory didn't already exist. --- wgctrl-rs/src/backends/userspace.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wgctrl-rs/src/backends/userspace.rs b/wgctrl-rs/src/backends/userspace.rs index a1eb698..52491e4 100644 --- a/wgctrl-rs/src/backends/userspace.rs +++ b/wgctrl-rs/src/backends/userspace.rs @@ -267,7 +267,7 @@ pub fn apply(builder: DeviceConfigBuilder, iface: &InterfaceName) -> io::Result< // If we can't open a configuration socket to an existing interface, try starting it. let mut sock = match open_socket(iface) { Err(_) => { - // TODO(jake): allow other userspace wireguard implementations + fs::create_dir_all(VAR_RUN_PATH)?; let output = Command::new(&get_userspace_implementation()) .env( "WG_TUN_NAME_FILE", @@ -278,6 +278,7 @@ pub fn apply(builder: DeviceConfigBuilder, iface: &InterfaceName) -> io::Result< if !output.status.success() { return Err(io::ErrorKind::AddrNotAvailable.into()); } + std::thread::sleep(Duration::from_millis(100)); open_socket(iface)? }, Ok(sock) => sock,