diff --git a/Cargo.lock b/Cargo.lock index ebfc972..1874909 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,7 +108,7 @@ dependencies = [ [[package]] name = "fourth" -version = "0.1.4" +version = "0.1.5" dependencies = [ "byte_string", "bytes 1.1.0", diff --git a/Cargo.toml b/Cargo.toml index 83920ae..2a1f0ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fourth" -version = "0.1.4" +version = "0.1.5" edition = "2021" authors = ["LI Rui "] license = "Apache-2.0" diff --git a/README.md b/README.md index 1fbc301..c2434f2 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ upstream: 内置两个的upstream:ban(立即中断连接)、echo(返回读到的数据)。更详细的配置可以参考[示例配置](./example-config.yaml)。 +注意:[::]会默认同时绑定IPv4和IPv6。 + ## 性能测试 在4C2G的服务器上测试: diff --git a/src/config.rs b/src/config.rs index 007f745..d0a82c2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -198,7 +198,7 @@ fn verify_config(config: ParsedConfig) -> Result { } for key in &upstream_names { - if !used_upstreams.contains(key) { + if !used_upstreams.contains(key) && !key.eq("echo") && !key.eq("ban") { warn!("Upstream {} not used", key); } } diff --git a/src/main.rs b/src/main.rs index 05c0f4f..7d4d9b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,11 +5,12 @@ mod servers; use crate::config::Config; use crate::servers::Server; -use std::env; use log::{debug, error}; +use std::env; fn main() { - let config_path = env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string()); + let config_path = + env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string()); let config = match Config::new(&config_path) { Ok(config) => config, @@ -23,6 +24,6 @@ fn main() { let mut server = Server::new(config.base); debug!("{:?}", server); - let res = server.run(); - error!("Server returned an error: {:?}", res); + let _ = server.run(); + error!("Server ended with errors"); } diff --git a/src/servers/mod.rs b/src/servers/mod.rs index 49c8cfe..eafe736 100644 --- a/src/servers/mod.rs +++ b/src/servers/mod.rs @@ -83,10 +83,16 @@ impl Server { let handle = tokio::spawn(async move { match config.protocol.as_ref() { "tcp" => { - let _ = tcp::proxy(config).await; + let res = tcp::proxy(config.clone()).await; + if res.is_err() { + error!("Failed to start {}: {}", config.name, res.err().unwrap()); + } } "kcp" => { - let _ = kcp::proxy(config).await; + let res = kcp::proxy(config.clone()).await; + if res.is_err() { + error!("Failed to start {}: {}", config.name, res.err().unwrap()); + } } _ => { error!("Invalid protocol: {}", config.protocol)