message: set timeout for protect() of Android's VpnService
  ref shadowsocks/shadowsocks-android#2667
diff: @@ -77,8 +77,17 @@ pub async fn tcp_stream_connect(saddr: &SocketAddr, config: &ConnectOpts) -> io:
  // This is a workaround for VPNService
  #[cfg(target_os = "android")]
  if !saddr.ip().is_loopback() {
  + use std::time::Duration;
  + use tokio::time;
  +
  if let Some(ref path) = config.vpn_protect_path {
  - protect(path, socket.as_raw_fd()).await?;
  + // RPC calls to `VpnService.protect()`
  + // Timeout in 3 seconds like shadowsocks-libev
  + match time::timeout(Duration::from_secs(3), protect(path, socket.as_raw_fd())).await {
  + Ok(Ok(..)) => {}
  + Ok(Err(err)) => return Err(err),
  + Err(..) => return Err(ErrorKind::TimedOut.into()),
  + }
  }
  }
  