Skip to content

Commit

Permalink
Merge pull request #116 from ngrok/bob/proxy-write
Browse files Browse the repository at this point in the history
Make sure Ready is returned on proxy_proto remainder polling
  • Loading branch information
bobzilladev authored Oct 12, 2023
2 parents 44f6f1d + 33545e1 commit 56e18cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ngrok/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ngrok"
version = "0.14.0-pre.7"
version = "0.14.0-pre.8"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "The ngrok agent SDK"
Expand Down
5 changes: 2 additions & 3 deletions ngrok/src/proxy_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,8 @@ where
if !remainder.is_empty() {
let available = std::cmp::min(remainder.len(), buf.remaining());
buf.put_slice(&remainder.split_to(available));
if buf.remaining() == 0 {
return Poll::Ready(Ok(()));
}
// Make sure Ready is returned regardless of inner's state
return Poll::Ready(Ok(()));
}
}
ReadState::None => {}
Expand Down
15 changes: 9 additions & 6 deletions ngrok/src/tunnel_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,29 @@ use hyper::{
};
use once_cell::sync::Lazy;
use proxy_protocol::ProxyHeader;
#[cfg(feature = "hyper")]
use tokio::io::{
AsyncRead,
AsyncWrite,
};
#[cfg(target_os = "windows")]
use tokio::net::windows::named_pipe::ClientOptions;
#[cfg(not(target_os = "windows"))]
use tokio::net::UnixStream;
#[cfg(target_os = "windows")]
use tokio::time;
use tokio::{
io::{
copy_bidirectional,
AsyncRead,
AsyncWrite,
},
io::copy_bidirectional,
net::TcpStream,
task::JoinHandle,
};
use tokio_util::compat::{
FuturesAsyncReadCompatExt,
TokioAsyncReadCompatExt,
};
#[cfg(feature = "hyper")]
use tracing::debug;
use tracing::{
debug,
field,
warn,
Instrument,
Expand Down Expand Up @@ -160,6 +162,7 @@ impl ConnExt for EndpointConn {
tokio::spawn(async move {
let proxy_proto = self.inner.info.proxy_proto;
let proto_tls = self.proto() == "tls";
#[cfg(feature = "hyper")]
let proto_http = matches!(self.proto(), "http" | "https");
let passthrough_tls = self.inner.info.passthrough_tls();

Expand Down

0 comments on commit 56e18cc

Please sign in to comment.