server_security/
config.rs1use crate::proxy::SocketConfig;
2use serde::Deserialize;
3use simple_log::LogConfig;
4use std::fs;
5
6#[derive(Deserialize)]
7pub struct ServerConfig {
8 pub proxy: SocketConfig,
9 log: LogConfig,
10}
11
12pub fn init_conf(path: String) -> anyhow::Result<ServerConfig> {
13 let s = fs::read_to_string(path)?;
14 let conf: ServerConfig = toml::from_str(&s)?;
15
16 if shadow_rs::is_debug() {
17 simple_log::quick().map_err(|err| anyhow::anyhow!("{}", err))?;
18 } else {
19 simple_log::new(conf.log.clone()).map_err(|err| anyhow::anyhow!("{}", err))?;
20 }
21 Ok(conf)
22}