aboutsummaryrefslogtreecommitdiff
path: root/src/configuration.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/configuration.rs')
-rw-r--r--src/configuration.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/configuration.rs b/src/configuration.rs
index 173b8ff..839db24 100644
--- a/src/configuration.rs
+++ b/src/configuration.rs
@@ -5,24 +5,24 @@ use std::fs::read_to_string;
5#[derive(Deserialize)] 5#[derive(Deserialize)]
6pub struct Configuration { 6pub struct Configuration {
7 pub endpoint: String, 7 pub endpoint: String,
8 pub wgconf: String,
8 pub port: Option<u32>, 9 pub port: Option<u32>,
9 pub dns: Option<String>, 10 pub dns: Option<String>,
10 pub wgconf: Option<String>,
11} 11}
12 12
13pub fn find_configuration_file(argument: Option<&String>) -> Result<String> { 13pub fn find_configuration_file(argument: Option<&String>) -> Result<Configuration> {
14 match argument { 14 match argument {
15 Some(p) => { 15 Some(p) => {
16 if let Ok(t) = read_to_string(p) { 16 if let Ok(t) = read_to_string(p) {
17 let _: Configuration = toml::from_str(&t).context("parsing configuration file")?; 17 let c: Configuration = toml::from_str(&t).context("parsing configuration file")?;
18 return Ok(p.clone()) 18 return Ok(c)
19 } 19 }
20 }, 20 },
21 None => { 21 None => {
22 // Try /etc/wgmgr.toml 22 // Try /etc/wgmgr.toml
23 if let Ok(t) = read_to_string("/etc/wgmgr.toml") { 23 if let Ok(t) = read_to_string("/etc/wgmgr.toml") {
24 let _: Configuration = toml::from_str(&t).context("parsing /etc/wgmgr.toml")?; 24 let c: Configuration = toml::from_str(&t).context("parsing /etc/wgmgr.toml")?;
25 return Ok(String::from("/etc/wgmgr.toml")) 25 return Ok(c)
26 } 26 }
27 }, 27 },
28 }; 28 };