mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-15 06:07:23 +08:00
fix listener stop accept after failure
This commit is contained in:
@@ -29,6 +29,7 @@ pub enum GlobalCtxEvent {
|
|||||||
|
|
||||||
ListenerAdded(url::Url),
|
ListenerAdded(url::Url),
|
||||||
ListenerAddFailed(url::Url, String), // (url, error message)
|
ListenerAddFailed(url::Url, String), // (url, error message)
|
||||||
|
ListenerAcceptFailed(url::Url, String), // (url, error message)
|
||||||
ConnectionAccepted(String, String), // (local url, remote url)
|
ConnectionAccepted(String, String), // (local url, remote url)
|
||||||
ConnectionError(String, String, String), // (local url, remote url, error message)
|
ConnectionError(String, String, String), // (local url, remote url, error message)
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ and the vpn client is in network of 10.14.14.0/24"
|
|||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "path to the log file, if not set, will print to stdout",
|
help = "latency first mode, will try to relay traffic with lowest latency path, default is using shortest path",
|
||||||
default_value = "false"
|
default_value = "false"
|
||||||
)]
|
)]
|
||||||
latency_first: bool,
|
latency_first: bool,
|
||||||
@@ -528,6 +528,13 @@ pub async fn async_main(cli: Cli) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalCtxEvent::ListenerAcceptFailed(p, msg) => {
|
||||||
|
print_event(format!(
|
||||||
|
"listener accept failed. listener: {}, msg: {}",
|
||||||
|
p, msg
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
GlobalCtxEvent::ListenerAdded(p) => {
|
GlobalCtxEvent::ListenerAdded(p) => {
|
||||||
if p.scheme() == "ring" {
|
if p.scheme() == "ring" {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -143,7 +143,20 @@ impl<H: TunnelHandlerForListener + Send + Sync + 'static + Debug> ListenerManage
|
|||||||
let mut l = listener.lock().await;
|
let mut l = listener.lock().await;
|
||||||
global_ctx.add_running_listener(l.local_url());
|
global_ctx.add_running_listener(l.local_url());
|
||||||
global_ctx.issue_event(GlobalCtxEvent::ListenerAdded(l.local_url()));
|
global_ctx.issue_event(GlobalCtxEvent::ListenerAdded(l.local_url()));
|
||||||
while let Ok(ret) = l.accept().await {
|
loop {
|
||||||
|
let ret = match l.accept().await {
|
||||||
|
Ok(ret) => ret,
|
||||||
|
Err(e) => {
|
||||||
|
global_ctx.issue_event(GlobalCtxEvent::ListenerAcceptFailed(
|
||||||
|
l.local_url(),
|
||||||
|
e.to_string(),
|
||||||
|
));
|
||||||
|
tracing::error!(?e, ?l, "listener accept error");
|
||||||
|
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let tunnel_info = ret.info().unwrap();
|
let tunnel_info = ret.info().unwrap();
|
||||||
global_ctx.issue_event(GlobalCtxEvent::ConnectionAccepted(
|
global_ctx.issue_event(GlobalCtxEvent::ConnectionAccepted(
|
||||||
tunnel_info.local_addr.clone(),
|
tunnel_info.local_addr.clone(),
|
||||||
@@ -164,7 +177,6 @@ impl<H: TunnelHandlerForListener + Send + Sync + 'static + Debug> ListenerManage
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
tracing::warn!("listener exit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run(&mut self) -> Result<(), Error> {
|
pub async fn run(&mut self) -> Result<(), Error> {
|
||||||
|
|||||||
Reference in New Issue
Block a user