aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6075f9b..74b9239 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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")
+ }
+ }
}