connection close on tunnel shutdown#18
Open
hvardhan-msft wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves QUIC tunnel shutdown behavior by explicitly closing connections on shutdown (so peers learn quickly), adds a constructor for wrapping an existing Quinn endpoint, and bumps the crate versions to the next alpha release.
Changes:
- Add
QuinnListenEndpoint::from_endpointto wrap an already-createdquinn::Endpoint. - On
QuinnTunnel::close, emit a QUICCONNECTION_CLOSEframe to notify the peer promptly. - Bump
snocat/snocat-cliversions to0.8.0-alpha.10(and update lockfile).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
snocat/src/common/tunnel_source/mod.rs |
Adds a new constructor for wrapping an existing Quinn endpoint. |
snocat/src/common/protocol/tunnel/quinn_tunnel.rs |
Sends an explicit QUIC close frame when the tunnel is closed. |
snocat/Cargo.toml |
Version bump to 0.8.0-alpha.10. |
snocat-cli/Cargo.toml |
Updates snocat dependency version to match the new alpha. |
Cargo.lock |
Lockfile update reflecting the version bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+57
to
+65
| /// Wrap an already-created quinn endpoint. | ||
| pub fn from_endpoint(bind_addr: SocketAddr, endpoint: quinn::Endpoint) -> Self { | ||
| Self { | ||
| bind_addr, | ||
| endpoint: Box::pin(endpoint), | ||
| accepting: None, | ||
| is_terminated: false, | ||
| } | ||
| } |
Comment on lines
+305
to
+316
| // Emit CONNECTION_CLOSE frame on the wire so the peer learns immediately | ||
| // rather than waiting for its own idle timeout to fire. | ||
| let error_code = match &reason { | ||
| TunnelCloseReason::Unspecified => quinn::VarInt::from_u32(0), | ||
| TunnelCloseReason::GracefulExit { .. } => quinn::VarInt::from_u32(0), | ||
| TunnelCloseReason::ApplicationErrorMessage(_) => quinn::VarInt::from_u32(1), | ||
| TunnelCloseReason::AuthenticationFailure { .. } => quinn::VarInt::from_u32(2), | ||
| _ => quinn::VarInt::from_u32(3), | ||
| }; | ||
| let reason_str = format!("{}", reason); | ||
| let reason_bytes = &reason_str.as_bytes()[..reason_str.len().min(1024)]; | ||
| self.connection.close(error_code, reason_bytes); |
QuinnTunnel::close() now calls self.connection.close() to send a CONNECTION_CLOSE frame on the wire before cancelling internal state. Previously, the peer only learned about the closure via its own idle timeout. With this change, the peer receives an immediate notification and can reconnect to a different server within seconds. Also adds QuinnListenEndpoint::from_endpoint() constructor so callers can create the quinn::Endpoint externally, clone it for shutdown coordination, and then wrap it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8290baf to
c24b0ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.