- Add functionality to query online sources (Keyservers, etc) for certificates. - Use introducers to determine which UserIDs should be fetched from online soources. Check certifications before importing certifiactes into the local cert store. - start docker image for local end-to-end testing.
67 lines
1.6 KiB
Rust
67 lines
1.6 KiB
Rust
//
|
|
// Parsing the config file
|
|
//
|
|
|
|
use anyhow;
|
|
use std::fs;
|
|
use std::sync::{Arc, Mutex};
|
|
use serde_derive::Deserialize;
|
|
|
|
use crate::types::errors::HuskError;
|
|
|
|
#[derive(Deserialize, Debug, Clone)]
|
|
pub struct HuskConfig {
|
|
pub connection: String,
|
|
pub sequoia_home: String,
|
|
logfile_config: Option<String>,
|
|
pub keyservers: Option<Vec<String>>,
|
|
}
|
|
|
|
impl HuskConfig {
|
|
|
|
pub fn load(path: &String) -> anyhow::Result<Self> {
|
|
match fs::read_to_string(path) {
|
|
Ok(data) => {
|
|
match toml::from_str(data.as_str()) {
|
|
Ok(configuration) => Ok(configuration),
|
|
Err(e) => {
|
|
Err(HuskError::ConfigFileParseError(e.to_string()).into())
|
|
}
|
|
}
|
|
},
|
|
Err(e) => {
|
|
Err(HuskError::ConfigFileOpenError(e.to_string()).into())
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn logfile_config(&self) -> String {
|
|
match &self.logfile_config {
|
|
Some(c) => c.clone(),
|
|
None => {
|
|
eprintln!("Using logging configuration from 'log4rs.yml'");
|
|
"log4rs.yml".to_string()
|
|
},
|
|
}
|
|
}
|
|
|
|
pub fn get_keyservers(&self) -> Vec<String> {
|
|
if let Some(kss) = &self.keyservers {
|
|
kss.clone()
|
|
} else {
|
|
Vec::new()
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
pub type HuskConfigContainer = Arc<Mutex<HuskConfig>>;
|
|
|
|
impl From<HuskConfigContainer> for HuskConfig {
|
|
fn from(container: HuskConfigContainer) -> Self {
|
|
let config = container.lock().unwrap();
|
|
config.clone()
|
|
}
|
|
}
|
|
|