diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -74,12 +74,7 @@ impl WireGuard { debug!("Created local socket."); // Create the socket directory if not existing - let mut socket_path = if Path::new("/run").exists() { - PathBuf::from("/run") - } else { - PathBuf::from("/var").join("run") - }; - socket_path = socket_path.join("wireguard"); + let mut socket_path = Self::get_run_path().join("wireguard"); if !socket_path.exists() { debug!("Creating socket path: {}", socket_path.display()); @@ -235,4 +230,13 @@ impl WireGuard { fn chmod(_path: &Path, _perms: u32) -> Result<()> { Ok(()) } + + /// Returns the path where the socket and pid file will be stored + pub fn get_run_path() -> PathBuf { + if Path::new("/run").exists() { + PathBuf::from("/run") + } else { + PathBuf::from("/var").join("run") + } + } } |