diff options
Diffstat (limited to 'src/model.rs')
-rw-r--r-- | src/model.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/model.rs b/src/model.rs index f0e1a7a..1f537bc 100644 --- a/src/model.rs +++ b/src/model.rs @@ -8,6 +8,7 @@ use base64; use std::collections::HashMap; use std::fmt; +use std::path::{Path, PathBuf}; use std::str::FromStr; mod ip; @@ -29,6 +30,21 @@ impl Key { } } +#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] +pub struct Secret(PathBuf); + +impl Secret { + #[inline] + pub fn new(path: PathBuf) -> Self { + Self(path) + } + + #[inline] + pub fn path(&self) -> &Path { + &self.0 + } +} + impl fmt::Display for Key { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -184,7 +200,7 @@ impl<'de> serde::Deserialize<'de> for Endpoint { #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] pub struct Peer { pub endpoint: Option<Endpoint>, - pub psk: Option<Key>, + pub psk: Option<Secret>, pub keepalive: u32, pub ipv4: Vec<Ipv4Net>, pub ipv6: Vec<Ipv6Net>, |