Skip to content

Commit

Permalink
Merge pull request #7 from kixelated/debug-logging
Browse files Browse the repository at this point in the history
Add some debug logging.
  • Loading branch information
kixelated authored Nov 7, 2023
2 parents 9bfeebd + 77e9992 commit e96fad3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webtransport-quinn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Luke Curley"]
repository = "https://github.com/kixelated/webtransport-rs"
license = "MIT"

version = "0.6.0"
version = "0.6.1"
edition = "2021"

keywords = ["quic", "http3", "webtransport"]
Expand All @@ -25,6 +25,7 @@ thiserror = "1"
futures = "0.3"
async-std = "1"
url = "2"
log = "0.4"

# This is just for AsyncRead/AsyncWrite and does NOT pull in anything else
tokio = "1"
Expand All @@ -37,4 +38,3 @@ tokio = { version = "1", features = ["full"] }
rustls = { version = "0.21", features = ["dangerous_configuration", "quic"] }
env_logger = "0.10"
clap = { version = "4", features = ["derive"] }
log = "0.4"
18 changes: 16 additions & 2 deletions webtransport-quinn/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ impl Connect {
Ok(req) => req,

// We didn't have enough data in the buffer, so we'll read more and try again.
Err(webtransport_proto::ConnectError::UnexpectedEnd) => continue,
Err(webtransport_proto::ConnectError::UnexpectedEnd) => {
log::debug!("buffering CONNECT request");
continue;
}

// Some other fatal error.
Err(e) => return Err(e.into()),
};

log::debug!("received CONNECT request: {:?}", request);

// The request was successfully decoded, so we can send a response.
return Ok(Self {
request,
Expand All @@ -80,6 +85,8 @@ impl Connect {
pub async fn respond(&mut self, status: http::StatusCode) -> Result<(), quinn::WriteError> {
let resp = ConnectResponse { status };

log::debug!("sending CONNECT response: {:?}", resp);

let mut buf = Vec::new();
resp.encode(&mut buf);

Expand All @@ -95,6 +102,8 @@ impl Connect {
// Create a new CONNECT request that we'll send using HTTP/3
let request = ConnectRequest { url: url.clone() };

log::debug!("sending CONNECT request: {:?}", request);

// Encode our connect request into a buffer and write it to the stream.
let mut buf = Vec::new();
request.encode(&mut buf);
Expand All @@ -119,12 +128,17 @@ impl Connect {
Ok(res) => res,

// We didn't have enough data in the buffer, so we'll read more and try again.
Err(webtransport_proto::ConnectError::UnexpectedEnd) => continue,
Err(webtransport_proto::ConnectError::UnexpectedEnd) => {
log::debug!("buffering CONNECT response");
continue;
}

// Some other fatal error.
Err(e) => return Err(e.into()),
};

log::debug!("received CONNECT response: {:?}", res);

// Throw an error if we didn't get a 200 OK.
if res.status != http::StatusCode::OK {
return Err(ConnectError::ErrorStatus(res.status));
Expand Down
6 changes: 5 additions & 1 deletion webtransport-quinn/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ impl SessionAccept {
StreamUni::QPACK_ENCODER => {
self.qpack_encoder = Some(recv);
}
_ => {} // ignore unknown streams
_ => {
// ignore unknown streams
log::debug!("ignoring unknown unidirectional stream: {:?}", typ);
}
}
}
}
Expand Down Expand Up @@ -314,6 +317,7 @@ impl SessionAccept {
) -> Result<Option<(quinn::SendStream, quinn::RecvStream)>, SessionError> {
let typ = Self::read_varint(&mut recv).await?;
if Frame(typ) != Frame::WEBTRANSPORT {
log::debug!("ignoring unknown bidirectional stream: {:?}", typ);
return Ok(None);
}

Expand Down
4 changes: 4 additions & 0 deletions webtransport-quinn/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ impl Settings {
Err(e) => return Err(e.into()),
};

log::debug!("received SETTINGS frame: {:?}", settings);

if settings.supports_webtransport() == 0 {
return Err(SettingsError::WebTransportUnsupported);
}
Expand All @@ -75,6 +77,8 @@ impl Settings {
let mut settings = webtransport_proto::Settings::default();
settings.enable_webtransport(1);

log::debug!("sending SETTINGS frame: {:?}", settings);

let mut buf = Vec::new();
settings.encode(&mut buf);

Expand Down

0 comments on commit e96fad3

Please sign in to comment.