mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 16:04:01 +00:00
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.
10 lines
524 B
Go
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
|