|
|
@ -40,11 +40,34 @@ pub struct DDNSConfig { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct UserSubdomainConfig {
|
|
|
|
subdomain: String,
|
|
|
|
targets: Vec<String>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct UserDomainConfig {
|
|
|
|
pub domain: String,
|
|
|
|
pub subdomains: Vec<UserSubdomainConfig>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct UserConfig {
|
|
|
|
pub username: String,
|
|
|
|
pub token: String,
|
|
|
|
pub domains: Vec<UserDomainConfig>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct Config {
|
|
|
|
pub server: ServerConfig,
|
|
|
|
pub cloudflare: CloudflareConfig,
|
|
|
|
pub ddns: DDNSConfig
|
|
|
|
pub ddns: DDNSConfig,
|
|
|
|
pub users: Vec<UserConfig>
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_default_config() -> Config {
|
|
|
@ -73,7 +96,26 @@ fn get_default_config() -> Config { |
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
users: vec![
|
|
|
|
UserConfig {
|
|
|
|
username: String::from("userOne"),
|
|
|
|
token: String::from("6d37d7a9-6b6b-4db2-99f2-c261e4f4b922"),
|
|
|
|
domains: vec![
|
|
|
|
UserDomainConfig {
|
|
|
|
domain: String::from("IAmNotADomain.com"),
|
|
|
|
subdomains: vec![
|
|
|
|
UserSubdomainConfig {
|
|
|
|
subdomain: String::from("ddns"),
|
|
|
|
targets: vec![
|
|
|
|
String::from("home")
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
@ -127,6 +169,6 @@ pub fn load_config(path: &str) -> Result<Config, ConfigError> { |
|
|
|
Err(e) => Result::Err(ConfigError::new("Cannot Read Configuration File", Option::Some(Box::from(e))))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Err(e) => Result::Err(ConfigError::new(&format!("Configuration File Doesn't Exist \"{}\"", path), Option::None))
|
|
|
|
Err(_e) => Result::Err(ConfigError::new(&format!("Configuration File Doesn't Exist \"{}\"", path), Option::None))
|
|
|
|
}
|
|
|
|
}
|