diff --git a/rsddns-example.yml b/rsddns-example.yml index dcbf2a7..c742e2d 100644 --- a/rsddns-example.yml +++ b/rsddns-example.yml @@ -13,4 +13,13 @@ ddns: domains: - domain: something.com subdomains: - - ddns \ No newline at end of file + - ddns +users: + - username: userOne + token: 6d37d7a9-6b6b-4db2-99f2-c261e4f4b922 + domains: + - domain: IAmNotADomain.com + subdomains: + - subdomain: ddns + targets: + - home \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 1468bf5..0605075 100644 --- a/src/config.rs +++ b/src/config.rs @@ -40,11 +40,34 @@ pub struct DDNSConfig { } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct UserSubdomainConfig { + subdomain: String, + targets: Vec +} + + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct UserDomainConfig { + pub domain: String, + pub subdomains: Vec +} + + +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct UserConfig { + pub username: String, + pub token: String, + pub domains: Vec +} + + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Config { pub server: ServerConfig, pub cloudflare: CloudflareConfig, - pub ddns: DDNSConfig + pub ddns: DDNSConfig, + pub users: Vec } 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 { 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)) } } \ No newline at end of file