diff options
author | Hristo Venev <hristo@venev.name> | 2020-02-04 20:31:51 +0100 |
---|---|---|
committer | Hristo Venev <hristo@venev.name> | 2020-02-04 20:31:51 +0100 |
commit | c4f743e2a33ba39036f7e9919b7adc80415b1754 (patch) | |
tree | c708bbc6e089a1b66c61d189a010cb2a80aa0a34 /src/model.rs | |
parent | 3f5c00af303c1b706a74cafa58ff23b068f6d819 (diff) |
Reference preshared keys by path.
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>, |