Repository navigation
fix: close stream/resource leaks and races from full code review - #29
Merged
Merged
Conversation
Prevent HTTP/TCP openStream timeout from leaking late streams, roll back TCP registration when Get fails, serialize connQueueListener Enqueue with Close, close WebSocket dial response bodies, keep heartbeat ping in-flight until completion, and avoid active-connection metric underflow. Co-authored-by: Gouryella <Gouryella@users.noreply.github.com>
Add scripts/test/e2e-full.sh covering HTTP/TCP over TLS and WSS, SSE streaming, password/bearer proxy auth, concurrency, health/metrics, and invalid token rejection. Wire it as `make e2e`. Co-authored-by: Gouryella <Gouryella@users.noreply.github.com>
Upgrade toolchain and CI/Docker images so govulncheck no longer flags the crypto/tls Encrypted Client Hello privacy leak fixed in go1.26.5. Co-authored-by: Gouryella <Gouryella@users.noreply.github.com>
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.
Summary
Full code review of the drip tunneling codebase found several correctness bugs around timeouts, registration rollback, and concurrent cleanup. This PR fixes them, adds regression tests, adds a full end-to-end functional suite, and clears the CI
govulncheckfailure.Fixes
HTTP
openStreamtimeout leak (internal/server/proxy/handler.go) — Unbuffered result channel caused lateOpenStreamcompletions after timeout to block forever and leak streams/goroutines. Use a buffered channel and drain/close late results on timeout.TCP proxy late-stream leak (
internal/server/tcp/proxy.go) — Same pattern on timeout / stop / context cancel. Always send to a buffered channel and drain late results.Registration Get failure leak (
internal/server/tcp/registration_handler.go) — IfRegisterWithIPsucceeded butGetfailed, the port and tunnel slot were never released. Roll back withUnregister+Release(port).connQueueListenerEnqueue/Close race (internal/server/tcp/http_conn_listener.go) — Enqueue could succeed after Close started, leaving connections stuck in the queue. Serialize Enqueue with Close under a mutex.WebSocket dial response body leak (
internal/client/tcp/connection_dialer.go) — Closeresp.Bodyon both success and failure paths.Heartbeat ping timeout pile-up (
internal/server/tcp/connection_group.go) — ClearingpingInFlighton timeout while Ping was still running allowed overlapping Ping goroutines. Track pending completions until the real Ping finishes; late success clears the failure streak.Active connection metric underflow (
internal/server/tunnel/connection.go) — Use a CAS loop soDecActiveConnectionscannot go negative.CI govulncheck GO-2026-5856 — Bump Go toolchain from 1.26.4 to 1.26.5 (CI, release, Dockerfile,
go.mod) to pick up thecrypto/tlsECH privacy fix.Tests
open_stream_test.go,http_conn_listener_test.go,registration_handler_test.goscripts/test/e2e-full.sh(make e2e) — 17/17 passedGOTOOLCHAIN=go1.26.5 go run golang.org/x/vuln/cmd/govulncheck@latest ./...— no vulnerabilities found