Skip to content

Commit

Permalink
中心配置
Browse files Browse the repository at this point in the history
  • Loading branch information
w273732573 committed Oct 25, 2023
1 parent 3746254 commit 5fd0503
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions config/reverse.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 3 additions & 1 deletion src/control/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Proxy {
}
}
_ = receiver_close.recv() => {
log::info!("反向代理:接收到错误信号,来自配置的变更,退出当前线程");
log::info!("反向代理:接收到退出信号,来自配置的变更,退出当前线程");
return Ok(());
}
}
Expand Down

0 comments on commit 5fd0503

Please sign in to comment.