Files
Jason Xu 4438acb8e7 feat(egress): route free-model traffic through userspace WARP
Free-tier requests now optionally leave through a Cloudflare WARP tunnel that runs inside the gateway process: WireGuard over UDP plus a gVisor netstack, so no TUN device, root, NET_ADMIN, or route changes are needed. Adapted from github.com/sudogeeker/ai-route (MIT).

- warp.enabled/pool_size/stack in config, the WebUI, config.example.json and all READMEs; startup and hot reload fail closed when WARP cannot initialize.
- Anonymous lane, free-model Zen-key fallback, free-model probes and the anonymous catalog refresh send no proxy traffic while enabled; Go keys and paid models keep their proxies.
- Per-attempt leases feed 403/429 rotation and broken-tunnel failures back into the pool; /healthz and /api/monitor expose the pool state and readiness requires an active exit.
- errWARPUnavailable maps to a 503 warp_unavailable response.
2026-10-25 05:51:00 +08:00

10 lines
524 B
Go

// Package warp carries outbound TCP traffic through Cloudflare WARP using a
// userspace WireGuard device and a gVisor network stack. It needs no TUN
// device, root privileges, or system routes: UDP sockets carry WireGuard
// packets, and the netstack terminates TCP inside the process.
//
// The implementation is adapted from github.com/sudogeeker/ai-route
// (internal/warp), which is MIT licensed. Only the parts this gateway needs
// are kept: registration, exit verification, and a small rotating pool.
package warp