From 5fd05037c17fc412a6ca0af6f36be6e4f3ba9c78 Mon Sep 17 00:00:00 2001 From: ticbh Date: Wed, 25 Oct 2023 19:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E5=BF=83=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/reverse.toml | 6 +++--- src/control/server.rs | 4 +++- src/helper.rs | 7 ++++--- src/proxy.rs | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/reverse.toml b/config/reverse.toml index c758d92..0299775 100644 --- a/config/reverse.toml +++ b/config/reverse.toml @@ -15,9 +15,9 @@ server = [ [[http.server]] bind_addr = "0.0.0.0:81" server_name = "soft.wm-proxy.com" -root="E:/" -cert="key/soft.wm-proxy.com.pem" -key="key/soft.wm-proxy.com.key" +root="" +#cert="key/soft.wm-proxy.com.pem" +#key="key/soft.wm-proxy.com.key" headers = [ ["proxy", "x-forward-for", "$client_ip"], ["+", "last-modified", "from proxy"] diff --git a/src/control/server.rs b/src/control/server.rs index d9dc4b2..0de1c80 100644 --- a/src/control/server.rs +++ b/src/control/server.rs @@ -42,7 +42,9 @@ impl ControlServer { let sender_close = self.sender_close.take(); tokio::spawn(async move { let mut proxy = Proxy::new(option); - let _ = proxy.start_serve(receiver_no_listen, sender_close).await; + if let Err(e) = proxy.start_serve(receiver_no_listen, sender_close).await { + log::info!("处理失败服务进程失败: {:?}", e); + } let _ = sender.send(()).await; }); self.sender_close = Some(sender_no_listen); diff --git a/src/helper.rs b/src/helper.rs index 151721b..5ed8a76 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -68,18 +68,19 @@ impl Helper { let addrs = addr.to_socket_addrs()?; let mut last_err = None; for addr in addrs { - println!("addr = {:?}", addr); let socket = Socket::new(Domain::IPV4, Type::STREAM, None)?; socket.set_nonblocking(true)?; - socket.set_only_v6(false)?; - socket.bind(&addr.into())?; + let _ = socket.set_only_v6(false); socket.set_reuse_address(true)?; + socket.set_reuse_port(true)?; + socket.bind(&addr.into())?; match socket.listen(128) { Ok(_) => { let listener: std::net::TcpListener = socket.into(); return TcpListener::from_std(listener); } Err(e) => { + log::info!("绑定端口地址失败,原因: {:?}", addr); last_err = Some(e); } } diff --git a/src/proxy.rs b/src/proxy.rs index a598d31..6f46b62 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -270,7 +270,7 @@ impl Proxy { } } _ = receiver_close.recv() => { - log::info!("反向代理:接收到错误信号,来自配置的变更,退出当前线程"); + log::info!("反向代理:接收到退出信号,来自配置的变更,退出当前线程"); return Ok(()); } }