Skip to content

Commit

Permalink
shutdown issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Mar 4, 2024
1 parent 9d21ce7 commit 868a11f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/tun2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
//!
//! This example must be run as root or administrator privileges.
//! ```
//! sudo target/debug/examples/tun --server-addr 127.0.0.1:8080 # Linux or macOS
//! sudo target/debug/examples/tun2 --server-addr 127.0.0.1:8080 # Linux or macOS
//! ```
//! Then please run the `echo` example server, which listens on TCP & UDP ports 127.0.0.1:8080.
//! ```
//! target/debug/examples/echo 127.0.0.1:8080
//! cargo install socks5-impl --example echo-server
//! echo-server --listen-addr 127.0.0.1:8080 --tcp-timeout 600
//! ```
//! To route traffic to the tun interface, run the following command with root or administrator privileges:
//! ```
Expand Down
4 changes: 4 additions & 0 deletions src/stream/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,19 @@ impl AsyncWrite for IpStackTcpStream {
std::task::Poll::Ready(Ok(()))
}

#[allow(unused_mut, unused_variables)]
fn poll_shutdown(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Result<(), std::io::Error>> {
/*
let notified = self.shutdown.get_or_insert(Notify::new()).notified();
match Pin::new(&mut Box::pin(notified)).poll(cx) {
std::task::Poll::Ready(_) => std::task::Poll::Ready(Ok(())),
std::task::Poll::Pending => std::task::Poll::Pending,
}
// */
std::task::Poll::Ready(Ok(()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/stream/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl AsyncRead for IpStackUdpStream {
return std::task::Poll::Ready(Ok(()));
}
if matches!(self.timeout.as_mut().poll(cx), std::task::Poll::Ready(_)) {
return std::task::Poll::Ready(Ok(())); // todo: return timeout error
return std::task::Poll::Ready(Err(std::io::Error::from(std::io::ErrorKind::TimedOut)));
}

self.reset_timeout();
Expand Down

0 comments on commit 868a11f

Please sign in to comment.