mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
transparentType=tun no longer starts the TinyTun process. The template emits a tun-mips inbound tagged transparent — device name, address, MTU, the DNS module's address as the relay target, the user's exclusion list plus v2rayA and the core by name and v2rayA by PID — and the service does what the operating system needs once the core has the device up. On Linux that is one table and four policy rules: table 2020 holds the default route into tun0; marked packets (0x80: the core's sockets, the direct outbound, the DNS module's upstreams) look up main in full and leave through the physical interface, or fail with ENETUNREACH when main has no route for their family rather than fall into the TUN; unmarked packets take main with its default route suppressed, so LAN and static routes stay physical, and everything else goes to table 2020. The main table is never edited, so stopping restores egress by itself. A rule in our preference range or a route in our table that is not ours is reported and left alone; our own leftovers from a crash are removed first. Every command that succeeded is recorded and undone in reverse on stop. Three things the TinyTun path never hit are now on tun's path, so they are fixed here: the DNS module is generated in tun mode (TinyTun did DNS itself); its 127.2.0.17:53 listener is only added when port 53 is free, instead of making the core exit on a host running another resolver; its primary listener stays on loopback unless port sharing is on or the user chose an address, and the DNS REDIRECT rules and their cleanup follow the module's port instead of a hard-coded 52353, and a ::1 listener is added when IPv6 is supported, because ip6tables REDIRECT delivers an application's IPv6 query to ::1 which the IPv4 listener never saw. The tun branch no longer skips those rules: they are what catches queries to a LAN resolver, which the routing keeps off the TUN. The connectivity monitor probes the core's API port; the TinyTun socks loop-back port it used is gone. Removed with TinyTun: --tinytun-bin, the tunProcessBackend (eBPF) and tunBypassInterfaces settings (connected and static routes bypass the TUN unconditionally now), the /networkInterfaces endpoint that only served the latter, and the build tag. The version endpoint reports tunSupported instead of tinytunSupported. Tests cover the generated inbound and DNS module, the listen-address rules, the redirect port, and — with V2RAYA_CORE_BIN set — that the generated document loads in the real core. Windows and macOS route handling follows in a separate commit; until then those builds report the TUN as unsupported.