mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-27 16:09:58 -07:00
add config and read files from binary
This commit is contained in:
@@ -7,6 +7,7 @@ struct ConfigFile {
|
||||
qmdl_store_path: Option<String>,
|
||||
port: Option<u16>,
|
||||
readonly_mode: Option<bool>,
|
||||
ui_level: Option<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -14,6 +15,7 @@ pub struct Config {
|
||||
pub qmdl_store_path: String,
|
||||
pub port: u16,
|
||||
pub readonly_mode: bool,
|
||||
pub ui_level: u8,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -22,6 +24,7 @@ impl Default for Config {
|
||||
qmdl_store_path: "/data/rayhunter/qmdl".to_string(),
|
||||
port: 8080,
|
||||
readonly_mode: false,
|
||||
ui_level: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +37,7 @@ pub fn parse_config<P>(path: P) -> Result<Config, RayhunterError> where P: AsRef
|
||||
if let Some(path) = parsed_config.qmdl_store_path { config.qmdl_store_path = path }
|
||||
if let Some(port) = parsed_config.port { config.port = port }
|
||||
if let Some(readonly_mode) = parsed_config.readonly_mode { config.readonly_mode = readonly_mode }
|
||||
if let Some(ui_level) = parsed_config.ui_level { config.ui_level = ui_level }
|
||||
}
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user