diff --git a/tunnel-obfuscation/src/shadowsocks.rs b/tunnel-obfuscation/src/shadowsocks.rs index eb56a3a63cf9..79e0df4380b2 100644 --- a/tunnel-obfuscation/src/shadowsocks.rs +++ b/tunnel-obfuscation/src/shadowsocks.rs @@ -228,10 +228,11 @@ impl Obfuscator for Shadowsocks { } async fn run(self: Box) -> crate::Result<()> { - self.server - .await - .expect("server handle panicked") - .map_err(crate::Error::RunShadowsocksObfuscator) + match self.server.await { + Ok(result) => result.map_err(crate::Error::RunShadowsocksObfuscator), + Err(_err) if _err.is_cancelled() => Ok(()), + Err(_err) => panic!("server handle panicked"), + } } #[cfg(target_os = "android")]