Repository navigation
feat: platform capabilities and an ACK-observed split wait - #5
Merged
Merged
Conversation
syscall.GetsockoptInt is a stub returning EWINDOWS on Windows before Go 1.21, so the native fake TCP and UDP backends failed on the module's minimum Go with "read fake TTL: not supported by windows". Read integer options through syscall.Getsockopt (ws2_32 getsockopt), which exists on every supported Go version, and cover it with a round-trip test.
PlatformCapabilities reports fake TCP/UDP, TTL control and send-queue observation for the current OS; ProbeConn checks an actual socket. Options.SplitWait waits before each further Split piece until the kernel reports the previous bytes as sent or acknowledged: - Linux/Android: SIOCOUTQ and SIOCOUTQNSD byte counts (reliable) - macOS: SO_NWRITE send-buffer bytes, acknowledged mode only (reliable) - Windows: SIO_TCP_INFO counters, reported as not reliable Unsupported modes fail Validate or the first Write with an explicit error before anything is sent; no delay is substituted. Waits are bounded by Close, write deadline changes and SplitWaitTimeout. Options without SplitWait keep their Key(). desync-socks gains -split-wait flags.
On BSD kernels getsockopt(IPV6_UNICAST_HOPS) returns -1 while a socket uses the system default, so ProbeConn reported TTL -1 without an error for IPv6 connections on macOS. -1 is now resolved through sysctl net.inet6.ip6.hlim, the value the kernel applies.
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.
Milestone 1 of
docs/vnext.md: honest platform capabilities and a split wait that observes the socket instead of guessing with a sleep. Plus the Go 1.20 Windows fix.What each OS observes on the socket:
ioctl SIOCOUTQ/SIOCOUTQNSD(tcp(7))SO_NWRITE=so_snd.sb_cc(xnu), same value asTCP_CONNECTION_INFO.tcpi_snd_sbbytesSIO_TCP_INFO→TCP_INFO_v0(BytesOut,BytesRetrans,BytesInFlight)BytesOutovercounts (measured), so the wait can end earlyValidateor before the first byte (ErrSplitWaitUnsupported,ErrSplitWaitRequiresTCP); a wait that times out is terminal (ErrSplitWaitTimeout). No sleep is ever substituted;SplitDelaystays a separate option and runs after the wait.Key()gains;wait=...only when set, so existing keys and golden tests are unchanged.desync-socks:-split-wait,-split-wait-timeout.syscall.GetsockoptIntis a stub there, so the native fake failed with "read fake TTL: not supported by windows". AgetsockoptInthelper oversyscall.Getsockopt(ws2_32) fixes it; 7 fake tests that failed on 1.20.14 pass, plus a round-trip test.CIaggregate); the test matrix prints the native capability report on Linux, macOS and Windows.Measured on loopback (517-byte hello, 4 pieces, 1,000 connections), first Write p50: none 40 µs → acked 49 µs on Windows, 18 → 21 µs on Linux; the query costs about 3–10 µs per write. Tables in
docs/validation.md(DESYNC_MEASURE=1re-runs them).Checks: gofmt,
go mod tidy -diff, vet for windows/linux/darwin on Go 1.26.10 and 1.20.14; tests on Windows (1.26.10 and 1.20.14) and Linux in Docker (1.26.9 with-race, 1.20.14); cross builds for freebsd, android, linux/arm and 386, windows/386 and arm64, darwin/arm64, js/wasm. Not verified: macOS at runtime (first run is this PR's CI), Android, Windows before 1703, real networks, Windows retransmission accounting.