pull/34/head
Frank Denis 4 years ago
parent d5b06a6653
commit 5ebd393981

@ -2,8 +2,7 @@ use crate::crypto::*;
use crate::dnscrypt_certs::*;
use crate::errors::*;
use std::fs::File;
use std::io::prelude::*;
use std::fs;
use std::mem;
use std::net::{IpAddr, SocketAddr};
use std::path::{Path, PathBuf};
@ -98,9 +97,7 @@ impl Config {
}
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Config, Error> {
let mut fd = File::open(path)?;
let mut toml = String::new();
fd.read_to_string(&mut toml)?;
let toml = fs::read_to_string(path)?;
Config::from_string(&toml)
}
}
@ -142,9 +139,7 @@ impl State {
}
pub fn from_file<P: AsRef<Path>>(path: P, key_cache_capacity: usize) -> Result<Self, Error> {
let mut fp = File::open(path.as_ref())?;
let mut state_bin = vec![];
fp.read_to_end(&mut state_bin)?;
let state_bin = fs::read(path)?;
let mut state: State = toml::from_slice(&state_bin)?;
for params_set in &mut state.dnscrypt_encryption_params_set {
params_set.add_key_cache(key_cache_capacity);

@ -659,11 +659,8 @@ fn main() -> Result<(), Error> {
),
};
let access_control_tokens = match config.access_control {
None => None,
Some(access_control) => match access_control.enabled {
false => None,
true => Some(access_control.tokens),
},
Some(access_control) if access_control.enabled => Some(access_control.tokens),
_ => None,
};
let runtime_handle = runtime.handle();
let globals = Arc::new(Globals {

Loading…
Cancel
Save