diff --git a/tunnel-obfuscation/src/shadowsocks.rs b/tunnel-obfuscation/src/shadowsocks.rs index 0f7492a3cac9..6f08da2f0882 100644 --- a/tunnel-obfuscation/src/shadowsocks.rs +++ b/tunnel-obfuscation/src/shadowsocks.rs @@ -227,10 +227,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")]