From c4f743e2a33ba39036f7e9919b7adc80415b1754 Mon Sep 17 00:00:00 2001 From: Hristo Venev Date: Tue, 4 Feb 2020 20:31:51 +0100 Subject: Reference preshared keys by path. --- src/model.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/model.rs') 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, - pub psk: Option, + pub psk: Option, pub keepalive: u32, pub ipv4: Vec, pub ipv6: Vec, -- cgit