Repository navigation
fix: do not cache zero-byte closed connections in sniffer skipList - #3550
Merged
wwqgtxx merged 1 commit intoNov 30, 2026
Merged
Conversation
In Dispatcher.TCPSniff, any error returned by sniffDomain incremented skipList[dstIP:port], including connections that closed or were canceled before sending a single application byte (such as speculative browser pre-connects or Happy Eyeballs races). Six such zero-byte closures disabled SNI sniffing for all domains sharing that IP:port for the full 600 s TTL. Skip caching the failure when conn.Buffered() == 0 and the error is a connection-closed or cancellation error (io.EOF, io.ErrUnexpectedEOF, net.ErrClosed, syscall.ECONNRESET, context.Canceled, etc.), while still counting server-first read timeouts (os.ErrDeadlineExceeded) and unrecognized or truncated payloads. Fixes MetaCubeX#3527 Co-Authored-By: Claude Code <noreply@anthropic.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
Prevents connections that close or are canceled before sending any application bytes (such as speculative browser pre-connects or Happy Eyeballs races) from poisoning
Dispatcher.skipListfor a shareddstIP:port.Root Cause
In
component/sniffer/dispatcher.go,Dispatcher.TCPSniffincrementedskipList[dstIP:port]on every error returned bysniffDomain. When a client opens a TCP connection and closes it immediately without sending any bytes, the initialconn.Peek(1)fails withio.EOF(or another closed/canceled error) whileconn.Buffered() == 0. Six such empty connections exceeded the threshold (count > 5) and disabled SNI sniffing for all domains sharing thatIP:portfor the full 600 s TTL.Changes
component/sniffer/dispatcher.go: AddshouldCacheSniffFailure(conn, err)soTCPSniffskipscacheSniffFailedwhenconn.Buffered() == 0and the error is a closed or canceled connection (E.IsClosed(err),io.ErrUnexpectedEOF, orcontext.Canceled). Server-first read timeouts (os.ErrDeadlineExceeded), unrecognized payloads, and truncated non-empty payloads continue to be cached as before.component/sniffer/dispatcher_test.go: AddTestDispatcherSkipListcovering zero-byteEOF/ErrUnexpectedEOF/net.ErrClosed/ECONNRESET/context.Canceled, unrecognized payloads, server-first read timeouts, truncated payload followed byEOF, and partial failure recovery.Verification
go test -race -count=1 ./component/sniffer/...go test -race -count=1 -tags "with_gvisor" ./component/sniffer/...go vet ./component/sniffer/...(darwin, linux, windows)Fixes #3527
🤖 Generated with Claude Code