mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-12 20:57:26 +08:00
correctly handle listener add fail
This commit is contained in:
@@ -27,7 +27,8 @@ pub enum GlobalCtxEvent {
|
|||||||
PeerConnRemoved(PeerConnInfo),
|
PeerConnRemoved(PeerConnInfo),
|
||||||
|
|
||||||
ListenerAdded(url::Url),
|
ListenerAdded(url::Url),
|
||||||
ConnectionAccepted(String, String), // (local url, remote url)
|
ListenerAddFailed(url::Url, String), // (url, error message)
|
||||||
|
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)
|
||||||
|
|
||||||
Connecting(url::Url),
|
Connecting(url::Url),
|
||||||
|
|||||||
@@ -374,6 +374,13 @@ pub async fn async_main(cli: Cli) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalCtxEvent::ListenerAddFailed(p, msg) => {
|
||||||
|
print_event(format!(
|
||||||
|
"listener add failed. listener: {}, msg: {}",
|
||||||
|
p, msg
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
GlobalCtxEvent::ListenerAdded(p) => {
|
GlobalCtxEvent::ListenerAdded(p) => {
|
||||||
if p.scheme() == "ring" {
|
if p.scheme() == "ring" {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub fn get_listener_by_url(
|
|||||||
Box::new(WSTunnelListener::new(l.clone()))
|
Box::new(WSTunnelListener::new(l.clone()))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("unsupported listener uri");
|
return Err(Error::InvalidUrl(l.to_string()));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,12 @@ impl<H: TunnelHandlerForListener + Send + Sync + 'static + Debug> ListenerManage
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
for l in self.global_ctx.config.get_listener_uris().iter() {
|
for l in self.global_ctx.config.get_listener_uris().iter() {
|
||||||
let lis = get_listener_by_url(l, self.global_ctx.clone())?;
|
let Ok(lis) = get_listener_by_url(l, self.global_ctx.clone()) else {
|
||||||
|
let msg = format!("failed to get listener by url: {}, maybe not supported", l);
|
||||||
|
self.global_ctx
|
||||||
|
.issue_event(GlobalCtxEvent::ListenerAddFailed(l.clone(), msg));
|
||||||
|
continue;
|
||||||
|
};
|
||||||
self.add_listener(lis, true).await?;
|
self.add_listener(lis, true).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user