TIVRA VPN client-side Xray patches — 2026-11-09 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 Wrapper base: 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. Managed outbound HTTPS probe — 2026-10-09 Patch: libxray-managed-probe.patch SHA-256: dbe23133d4807b54fca97e813f69c94127d720dcf73296fa80073124283e9b23 This separate wrapper patch is under libXray's MIT license, not the Xray-core MPL license. No additional core or cryptographic changes are included. API version 3 gains probeManagedConnectivity: bounded HTTPS through a named outbound in the existing running core. It never creates another core or listener and never falls back to another outbound or an OS-direct request. TLS uses system trust and hostname validation, redirects are rejected, and response headers/body and elapsed time are bounded. The application fixes its health endpoint allowlist and verifies exact response bytes. A transport response is not proof of OS TUN capture or the system DNS path. Stopping the managed core cancels its pending probes without holding the lifecycle mutex across network I/O. Completions from an old core generation are unavailable. The native provider uses this transport signal because includeAllNetworks can prevent provider-originated Network framework connections to its own virtualInterface while captured application traffic still works. Verification: full libXray Go suite and focused managed-probe race suite passed. Local HTTPS fixtures cover forced outbound selection against a blocking default, certificate rejection, no fallback for missing tags, redirect rejection, bounded responses, stream closure on timeout, and immediate stop/restart cancellation. Scripts/build-xray.sh checks/applies this wrapper patch after the pinned checkout, runs the full wrapper suite, and retains both preceding core patches. Native TUN reader state and fixed-destination UDP isolation — 2026-11-09 Patch: xray-tun-reader-and-udp.patch SHA-256: c35c8789e21b54cf80855a7f7e3a5d5194afd32ae494106fd6db9997d8ae8cd1 Covered source: Source/proxy/tun/{udp_fullcone.go,stack_gvisor_endpoint.go,stack_gvisor.go,handler.go,tivra_reader_state_test.go,tivra_udp_association_test.go}. The native TUN previously reused a source-only UDP association across different destinations. Plain VLESS UDP for DNS/QUIC ports 53/443 does not transmit per-packet destinations, so a second destination could be sent to the first target. These two ports now include destination in the association key. Other UDP retains the existing FullCone behavior. Exact-source tests exercise actual native association handling and the VLESS encoder for IPv4/IPv6, source/destination identity, concurrent closure and delayed double-close. The native reader still stops on a terminal read failure; it never blindly retries a bad descriptor. A synchronized lifecycle snapshot reports running/failed/stopped/unavailable with sanitized errno/eof/other only. Each attachment has a generation, so a late old-reader failure cannot overwrite a replacement or an intentional stop. No packet content, addresses or raw error strings are retained by this diagnostic. Tests inject read failures, verify no blind retry, verify explicit replacement, and race concurrent lifecycle/snapshot operations. Wrapper patch: libxray-tun-state.patch (libXray MIT) SHA-256: a1a2d0398684084b7526831fcf0b7af88f8e99b0b3f574bdb6982ae7b22a21d1 API version remains 3. Existing getXrayState retains running and may add tunReaders keyed by managed inbound tag. Wrapper snapshots share the core lifecycle lock; absent/stopped/unsupported readers are not failure evidence. App consumers must reject obsolete generations and retain recovery budgets. Reader liveness is not proof of end-to-end connectivity or DNS health. No resolver, TLS validation, cryptography or server configuration is changed. These tests prove local failure modes and corrections, not attribution of the user's intermittent incident or complete physical-device reliability. Full wrapper tests, native affected-package regression tests and focused race tests passed. An actual Darwin pipe-backed TUN integration test also confirms failure publication through Invoke, stop cleanup and clean replacement, with a race-detector run. The official builder completed successfully and restored go.mod/go.sum exactly. Both iOS device and simulator archives are packaged; their hashes and physical-device validation status are recorded in Vendor/README.md and the release evidence.