TIVRA VPN client-side Xray patches — 2026-10-08 Modified covered source is available under the Mozilla Public License 2.0. Full license: Source/LICENSE. Exact ECH changed files are under Source/common/protocol/tls/. The Darwin TUN ownership patch and regression test are under Source/proxy/tun/. Upstream core: https://github.com/XTLS/Xray-core/tree/b26a91de4f32 Go module: github.com/xtls/xray-core v1.260327.1-0.20260930074004-b26a91de4f32 Unchanged wrapper: https://github.com/XTLS/libXray/tree/3c694b23290f9849fe52284a345ebd4343bc90cd Compiler: Go 1.27.1. Integration: build-xray.sh, also distributed in the iOS source project. Reason: a TLS ClientHello with Encrypted ClientHello (ECH) can expose an outer SNI unrelated to the private website name. When local exact-host website exclusions are enabled, TIVRA sets TIVRA_XRAY_DISABLE_ECH_SNI=1. The patched shared TLS/QUIC ClientHello reader prescans all extensions and declines to expose a routing domain whenever extension 0xfe0d is present, including GREASE. Unknown or hidden hosts remain on the default VPN route. No TLS certificate verification or cryptography is changed. With no exclusions the environment flag is disabled and upstream behavior is preserved. This is a client-only patch; server Xray source is unchanged. Tests: ordinary TLS 1.2/1.3; ECH before/after SNI; conservative GREASE handling; every incomplete ClientHello prefix; shared reader used by QUIC; existing upstream TLS and QUIC package tests. These tests establish parser behavior, not operation on a physical iPhone or any mobile operator. Build integration copies the pinned core module into an adjacent scratch Xray-core directory, checks the patch SHA-256, applies it, runs targeted Go tests, and uses the pinned upstream libXray apple go local builder. Generated device/simulator static archives were built successfully. Rebuild instructions need the iOS project's Scripts/build-xray.sh at its normal relative path (Patches alongside Scripts); the published script is the exact integration source. Source availability: https://tivravpn.com/open-source/ Reconnections: the provider resets the opt-in through Xray JSON env=0 after a previous exclusion-enabled session. Go maintains an environment cache separate from Darwin unsetenv; resetting only the C environment would not restore the parser. Fresh installations with empty exclusions retain their original JSON. Darwin/iOS TUN descriptor ownership — 2026-10-08 Patch: xray-darwin-fd-ownership.patch SHA-256: eb7ddd850dcd66329fb3ef00daf2111aae5e971875af562e71de455c727f0a09 Covered files: Source/proxy/tun/tun_darwin.go and Source/proxy/tun/tivra_darwin_fd_test.go. The provider passes a descriptor it owns to Xray. Upstream DarwinTun wrapped that borrowed descriptor in os.NewFile, but its Close skipped os.File.Close on iOS. os.NewFile installs a closing Go finalizer. After the provider closed its descriptor and its number was reused, a later garbage collection could close the new socket. This was reproduced locally with the original behavior; it is not established as the cause of the historical iPhone DNS timeout. The core now duplicates the input descriptor and owns only that new copy. Its Close calls os.File.Close on both platforms, releasing the copy and removing the finalizer. The caller continues to own its input descriptor. The previous ownsFd flag is renamed managesInterface: only macOS performs interface/route setup. iOS NetworkExtension configuration, AF packet framing, TLS and encryption are unchanged. No library API change: CGoInvoke API remains version 3. Verification on macOS with Go 1.27.1: all proxy/tun tests pass; the three new tests cover caller descriptor preservation, invalid descriptor rejection, and 20 stop/reuse/forced-GC cycles. A Go overlay restoring the original implementation (only adapting the field name for test compilation) fails both positive ownership tests, including EBADF on the reused descriptor. This establishes the native lifecycle fix; it does not establish physical iPhone reconnect or historical DNS causality. Scripts/build-xray.sh verifies and applies both patches, tests the affected packages and invokes the unchanged pinned upstream build/main.py apple go local builder. The official native builder completed on 8 October 2026 for device and simulator, with go.mod/go.sum restored. The iOS project Vendor/README.md and build evidence identify the packaged archive hashes. This does not by itself establish physical-iPhone connectivity.