Repository navigation
TUN inbound: Add system stack with DNS hijacking and ICMP unreachable - #6399
Closed
youugiuhiuh wants to merge 12 commits into
Closed
youugiuhiuh wants to merge 12 commits into
youugiuhiuh wants to merge 12 commits into
Conversation
- Wire DNSHijacker into SystemStack data path (Process called in handleUDPPacket) - Fix TCP NAT: add Delete after connection ends in handleAcceptedTCP - Fix UDP NAT: wire LookupOrAllocate into handleUDPPacket - Fix ICMP unreachable: generate on NAT exhaustion with strict_route - Fix allocatePort: full-range scan instead of 3-attempt limit - Fix IPv4 IHL handling: read header length, pass to TCP/UDP/ICMP handlers - Randomize NAT initial port for off-path attack resistance - Remove unused PrepareConnection from StackHandler interface - Close/Start synchronization via mu lock - StartTunLoop called after TUN interface is fully configured - acceptTCP retries on temporary errors - writeUDPResponse parameter rename for clarity - Integration test: verify NewSystem result - ICMP test: remove unused variables
Contributor
Author
Code review fixes appliedBased on code review feedback, the following critical and important issues have been fixed: Critical fixes
Important fixes
Minor fixes
|
Contributor
Author
Before / After FlowchartBefore (broken)After (fixed)Critical issues addressed
|
- gofmt alignment fixes in handler.go and stack_system_nat.go - Match protoc version header in config.pb.go to core/config.pb.go (v6.33.5)
Member
|
这vibe pr步子太大了 |
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.
Add a system network stack implementation for the TUN inbound, enabling proper TCP/UDP handling through a lightweight userspace TCP/IP stack.
Changes
proxy/tun/stack.go) — abstraction for pluggable TUN stack implementationsproxy/tun/stack_system.go) — full TCP listener + tun-to-socket bridge with accept loopproxy/tun/stack_system_nat.go) — UDP and TCP NAT session tracking tablesproxy/tun/stack_system_icmp.go) — generates ICMP Destination Unreachable for unmatched packetsproxy/tun/dns_hijack.go) — three modes: hijack (intercept DNS locally), native (let system handle), disabledstack,dns_mode,dns_address,strict_route,addressfields on TUN configtun_android.go,tun_darwin.go,tun_default.go,tun_freebsd.go,tun_linux.go,tun_windows.gofor per-platform stack selectionConfig example
Behavior
stack: "system"— uses the userspace TCP/IP stack instead of the default gVisor/netstackdns_mode: "hijack"— intercepts all UDP:53 traffic and forwards to the configured DNS addressdns_mode: "native"— passes DNS through without interceptiondns_mode: "disabled"— blocks DNS traffic entirelystrict_route— when enabled, sends ICMP unreachable for non-TUN-destined packetsTesting
Related: #5594