Repository navigation
feat: automatic fake TTL and TTL-range candidates - #7
Merged
Merged
Conversation
FakeOptions.AutoTTL (delta/min/max, zapret's --dpi-desync-autottl) sets the fake's TTL from the hop count estimated from the server's SYN-ACK, with Fake.TTL as an optional fallback. Linux/Android IPv6 records the hop limit with IPV6_RECVHOPLIMIT (enabled before connect by ControlAutoTTL) and returns it through IPV6_2292PKTOPTIONS. Linux IPv4, Windows and macOS keep no received TTL for TCP sockets and are reported in PlatformCapabilities().AutoTTL and Unsupported with the reason.
FakeTTLCandidates and UDPTTLCandidates return one option set per TTL with a stable Key, so discovery can probe the TTL where the path cannot be observed. UDPOptions gains Key.
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.
Automatic TTL for the fake prefix, where an OS lets an unprivileged TCP socket see the server's hop limit, and TTL-range candidates for discovery everywhere else.
IPV6_RECVHOPLIMITbefore connect, thengetsockopt(IPV6_2292PKTOPTIONS)returns the SYN-ACK's hop limit (net/ipv6/tcp_ipv6.c,ipv6_sockglue.c)IP_PKTOPTIONSis filled only on accepted sockets (tcp_v4_syn_recv_sock);IP_RECVTTLis datagram-onlyIPV6_2292PKTOPTIONSreturns nothing (source reading only)IP_RECVTTL/WSARecvMsgare datagram/raw only;TCP_INFO_v1has no TTLAutoTTL{Delta, Min, Max}(defaults 1, 3, 20): fake TTL = hops − Delta, clamped, never ≥ hops. Hops from the observed TTL against the initial values 64/128/255 (EstimateHops; ambiguous values are reported). This is zapret's--dpi-desync-autottllogic (MIT, credited inthird_party/); ByeDPI has no auto TTL.TTL == 0auto is mandatory (ErrAutoTTLUnsupported/ErrAutoTTLUnobserved); withTTL > 0that value is the fallback.ObserveHops(conn)reads without changing anything;(*Conn).FakeTTL()tells which TTL was used and whether it was derived.Capabilities.AutoTTLplus reasons inUnsupported.FakeTTLCandidates/UDPTTLCandidates: stable, distinct keys (at most 64) for the controller to probe.UDPOptions.Key()is new. The UDP burst has no auto TTL: it is sent before the peer's first reply.Key()adds,auto:D:min-maxonly when set; the existing fixed-TTL key is pinned in a test.Tests:
EstimateHopstable, validation, keys; on Linux (Docker, IPv6) server hop limits 120/61/250/64 read as 8/3/5/0 hops, 80 reported ambiguous, updates on later data, unobserved withoutControlAutoTTL, unsupported on IPv4; end to end the fake goes out with the derived TTL 7, the low-hop BPF filter drops it and the stream arrives through retransmission. Checks: gofmt; vet windows/linux/darwin on Go 1.26.10 and 1.20.14 (also linux/386, s390x, arm); tests on Windows (both Go) and Linux in Docker as root (1.26.9-race, 1.20, GOARCH=386). Not verified: real networks (asymmetric routes and CDNs can skew the estimate), macOS runtime, Android devices. No desync-socks flags yet.