mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-15 10:25:40 +00:00
fix bugs (#1138)
1. avoid dns query hangs the thread 2. avoid deadloop when stun query failed because of no ipv4 addr. 3. make quic input error non-fatal. 4. remove ring tunnel from connection map to avoid mem leak. 5. limit listener retry count.
This commit is contained in:
@@ -526,6 +526,19 @@ impl Instance {
|
||||
});
|
||||
}
|
||||
|
||||
async fn run_quic_dst(&mut self) -> Result<(), Error> {
|
||||
if !self.global_ctx.get_flags().enable_quic_proxy {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let quic_dst = QUICProxyDst::new(self.global_ctx.clone())?;
|
||||
quic_dst.start().await?;
|
||||
self.global_ctx
|
||||
.set_quic_proxy_port(Some(quic_dst.local_addr()?.port()));
|
||||
self.quic_proxy_dst = Some(quic_dst);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) -> Result<(), Error> {
|
||||
self.listener_manager
|
||||
.lock()
|
||||
@@ -588,11 +601,12 @@ impl Instance {
|
||||
}
|
||||
|
||||
if !self.global_ctx.get_flags().disable_quic_input {
|
||||
let quic_dst = QUICProxyDst::new(self.global_ctx.clone())?;
|
||||
quic_dst.start().await?;
|
||||
self.global_ctx
|
||||
.set_quic_proxy_port(Some(quic_dst.local_addr()?.port()));
|
||||
self.quic_proxy_dst = Some(quic_dst);
|
||||
if let Err(e) = self.run_quic_dst().await {
|
||||
eprintln!(
|
||||
"quic input start failed: {:?} (some platforms may not support)",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// run after tun device created, so listener can bind to tun device, which may be required by win 10
|
||||
|
||||
@@ -179,11 +179,13 @@ impl<H: TunnelHandlerForListener + Send + Sync + 'static + Debug> ListenerManage
|
||||
peer_manager: Weak<H>,
|
||||
global_ctx: ArcGlobalCtx,
|
||||
) {
|
||||
let mut err_count = 0;
|
||||
loop {
|
||||
let mut l = (creator)();
|
||||
let _g = global_ctx.net_ns.guard();
|
||||
match l.listen().await {
|
||||
Ok(_) => {
|
||||
err_count = 0;
|
||||
global_ctx.add_running_listener(l.local_url());
|
||||
global_ctx.issue_event(GlobalCtxEvent::ListenerAdded(l.local_url()));
|
||||
}
|
||||
@@ -193,8 +195,11 @@ impl<H: TunnelHandlerForListener + Send + Sync + 'static + Debug> ListenerManage
|
||||
l.local_url(),
|
||||
format!("error: {:?}, retry listen later...", e),
|
||||
));
|
||||
err_count += 1;
|
||||
if err_count > 5 {
|
||||
return;
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user