Documentation
¶
Overview ¶
Package exit implements the VPS-side HTTP handler. Apps Script POSTs AES-encrypted frame batches here; we decrypt, demux by session_id, dial real upstream targets on SYN, pump bytes between net.Conn and session, and long-poll the response so downstream bytes get delivered with low latency.
Index ¶
Constants ¶
const ( // ActiveDrainWindow caps how long a batch that just performed real work // (SYN/connect or non-empty uplink data) waits for downstream bytes. // Kept short so the client's single poll loop can quickly cycle back // and send SYN frames for other sessions that queued up while this poll // was in-flight. A long value here (e.g. 2s) causes head-of-line // blocking: when YouTube opens 4-6 parallel connections, later SYNs // are delayed by ActiveDrainWindow × (position in queue), easily // pushing total setup time past the player's ~7s abort threshold. ActiveDrainWindow = 350 * time.Millisecond // LongPollWindow is how long the handler holds open a request waiting for // downstream bytes. UrlFetchApp has a practical read timeout of ~10s, so // keep this comfortably below that. LongPollWindow = 8 * time.Second // MaxFramePayload caps the bytes per downstream frame (matches carrier). // Raised from 128KB: single-seal means no per-frame crypto cost, so fewer // larger frames are strictly better (less length-prefix overhead, fewer // Unmarshal calls). Must match the value in internal/carrier/client.go. MaxFramePayload = 256 * 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ListenAddr string // "0.0.0.0:8443"
AESKeyHex string // 64-char hex
DebugTiming bool // when true, log per-session dial breakdown and first-read latency
UpstreamProxy string // optional "host:port" of a local SOCKS5 proxy (e.g. WARP on 127.0.0.1:40000)
}
Config is the VPS server's configuration.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the per-process session state.
func (*Server) ListenAndServe ¶
ListenAndServe blocks. It binds an HTTP listener on cfg.ListenAddr with one route, POST /tunnel, that handles batched encrypted frames. Listens for SIGINT/SIGTERM and triggers graceful shutdown so in-flight long-polls drain.
func (*Server) ServeTunnel ¶
func (s *Server) ServeTunnel(w http.ResponseWriter, r *http.Request)
ServeTunnel exposes the /tunnel handler so callers (e.g. integration test harnesses or alternative front-ends) can mount it on their own mux.
func (*Server) StartBackground ¶
func (s *Server) StartBackground()
StartBackground starts the long-running maintenance goroutines (idle GC, stats loop, dialFail GC). It is intended for embed-style use where the caller drives an http.Server itself instead of calling ListenAndServe. Safe to call once per Server.