zapret-kvn/xray_fluent/network/entry_hop.py
loop-uh 9330eaf25d Add Cloudflare WARP as an optional entry hop to the server (off by default)
Device -> WARP -> our server -> internet: the provider sees only Cloudflare.
Everything stays in sing-box, the gasket: WARP is the core's `warp` endpoint.

- Core patches (same code as Android 0022-0024): `mtu`, a private account file
  (`profile.cache_path`) and the account's assigned address as the default peer;
  start-up recovery (one 4 s probe, then up to 4 literal-IP candidates with a
  fresh socket each); forwarding of network changes to the inner WireGuard.
- `warp_entry.py`: native outbounds get a `detour`; the Hysteria process rule and
  the Xray protect-inbound rule lead into the hop; the hop is checked to be an
  entry only (never an exit, a selector member or `route.final`); WireGuard/AWG
  nodes and slots are refused; registration goes through its own direct outbound.
- Setting `warp_entry_hop` (settings page), `[warp-entry]` log line, pings and
  speed tests are not made while it is on (they would show the server address).
- Verified: 31 new tests, the real core build script with all patches, and a
  Windows build of the core on win10: 8 of 8 starts through WARP.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 13:39:43 -05:00

26 lines
1 KiB
Python

"""WARP entry hop switch for the probes (owner decision 2026-11-25).
With the hop on, every connection to our server must enter through WARP so the provider never sees the server address
(owner rule, also "probes must not expose servers"). Pings and speed tests start their own temporary cores that dial
the server directly, outside the live tunnel, so they would show that address. Until they get a way in through the hop
they are not made, and the reason is shown instead. The probe of the ACTIVE proxy runs inside the live core and enters
through the hop by itself, so it is unaffected.
"""
from __future__ import annotations
REFUSAL = (
"Замер сервера идёт мимо входа через WARP и показал бы адрес сервера провайдеру. "
"Выключите вход через WARP, чтобы замерить"
)
_active = False
def configure(enabled: bool) -> None:
global _active
_active = bool(enabled)
def active() -> bool:
return _active