Add error messages when failed to start server
This commit is contained in:
parent
bff92738d5
commit
8fbc0c370a
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -108,7 +108,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fourth"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"byte_string",
|
||||
"bytes 1.1.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fourth"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
authors = ["LI Rui <lr_cn@outlook.com>"]
|
||||
license = "Apache-2.0"
|
||||
|
@ -55,6 +55,8 @@ upstream:
|
||||
|
||||
内置两个的upstream:ban(立即中断连接)、echo(返回读到的数据)。更详细的配置可以参考[示例配置](./example-config.yaml)。
|
||||
|
||||
注意:[::]会默认同时绑定IPv4和IPv6。
|
||||
|
||||
## 性能测试
|
||||
|
||||
在4C2G的服务器上测试:
|
||||
|
@ -198,7 +198,7 @@ fn verify_config(config: ParsedConfig) -> Result<ParsedConfig, ConfigError> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user