diff --git a/src/config.rs b/src/config.rs index bca1da7..3adf962 100644 --- a/src/config.rs +++ b/src/config.rs @@ -25,6 +25,7 @@ pub struct ServerConfig { pub address: Option, pub port: Option, pub password_file: Option, + pub password: Option, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -154,9 +155,10 @@ impl Config { Ok(xdg_dirs.get_config_home().join("config.yml")) } - /// Read password from password_file if configured + /// Read password from password_file or directly from config if configured pub fn get_server_password(&self) -> Result> { if let Some(server) = &self.server { + // First check for password_file if let Some(password_file) = &server.password_file { debug!("CONFIG: Reading password from file: {:?}", password_file); let password = fs::read_to_string(password_file) @@ -165,6 +167,12 @@ impl Config { .to_string(); return Ok(Some(password)); } + + // Fall back to direct password field + if let Some(password) = &server.password { + debug!("CONFIG: Using password from config"); + return Ok(Some(password.clone())); + } } Ok(None) }