fix bugs and improve user experiance (#86)

* correctly set mtu, and allow set mtu manually

* communicate between enc and non-enc should not panic

* allow loading cfg from file

* allow change file log level dynamically
This commit is contained in:
Sijie.Sun
2024-05-07 00:38:05 +08:00
committed by GitHub
parent e5b537267e
commit 8440eb842b
8 changed files with 211 additions and 76 deletions
+5 -2
View File
@@ -1,5 +1,6 @@
use std::{
net::SocketAddr,
path::PathBuf,
sync::{Arc, Mutex},
};
@@ -144,6 +145,8 @@ pub struct Flags {
pub enable_encryption: bool,
#[derivative(Default(value = "true"))]
pub enable_ipv6: bool,
#[derivative(Default(value = "1420"))]
pub mtu: u16,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
@@ -192,9 +195,9 @@ impl TomlConfigLoader {
})
}
pub fn new(config_path: &str) -> Result<Self, anyhow::Error> {
pub fn new(config_path: &PathBuf) -> Result<Self, anyhow::Error> {
let config_str = std::fs::read_to_string(config_path)
.with_context(|| format!("failed to read config file: {}", config_path))?;
.with_context(|| format!("failed to read config file: {:?}", config_path))?;
Self::new_from_str(&config_str)
}
}