mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
v0.13.9
perf(pht): eliminate /authorize HTTP round-trip by self-generating CID Client now uses xid to generate connection IDs, removing one RTT per tunnel setup. Server lazily creates pipe pairs in handlePush/handlePull via getOrCreateConn helper, keeping backward compat for old clients that still call /authorize. fix: send close notification before canceling context Close() was canceling c.ctx before calling write(nil). With a canceled context, http.Client.Do returns immediately without network I/O, so the close notification POST never reached the server. Swap the order. fix: add Flush() after heartbeat write in handlePull w.Write() on http.ResponseWriter goes to a 2k bufio.Writer. Without a Flush(), the keepalive newline never reaches the wire, causing the client long-poll GET to time out. fix: use LoadOrStore in createPipe to prevent concurrent push/pull race When push and pull HTTP requests arrive concurrently for a new CID, both saw !ok from Load() and both called createPipe(), overwriting the first conns entry. The losing pipe pair leaked and the listener accepted a phantom connection. LoadOrStore makes the first Store win; the second caller gets the existing pipe. fix: close conn and delete entry on empty-data POST in handlePush A POST body of "\n" produced empty data after TrimSuffix, leaking the pipe pair and conns entry. Now always cleans up before returning. fix: use caller ctx instead of context.Background() in Dial Dial(ctx, addr) was discarding the caller context, so deadlines and cancellation did not propagate to the HTTP long-poll requests. fix: detect ListenAndServe failure in Init() and clean up goroutine Non-blocking select on errChan after starting the server goroutine surfaces immediate failures (port conflict, TLS error) instead of leaking a goroutine blocked on server.Accept(). chore: remove dead AuthorizePath from Client struct and dialer wiring Client no longer calls /authorize; the field and its metadata parsing in dialer/pht, dialer/http3 are dead code. test: add unit tests for createPipe race, close notification, empty-data cleanup, and queue-full fallback
x
The implementation layer for the GOST proxy framework. Every interface defined in core/ is implemented here — handlers, listeners, dialers, connectors, plus config parsing, registries, and all cross-cutting concerns.
Package layout
| Directory | Purpose |
|---|---|
handler/ |
Protocol handlers (http, socks4/5, ss, ssh, tunnel, tun, dns, redirect, etc.) |
listener/ |
Protocol listeners (tcp, tls, ws, http2/3, quic, kcp, icmp, tun, udp, etc.) |
dialer/ |
Outbound dialers (tcp, tls, ws, http2/3, quic, grpc, ssh, wg, kcp, icmp, etc.) |
connector/ |
Destination connectors (http, socks4/5, ss, ssh, relay, tunnel, direct, etc.) |
config/ |
Config struct, YAML/JSON parsing, and service construction |
registry/ |
Typed global registries for all component types |
service/ |
Accept loop wiring listener + handler |
chain/ |
Multi-hop forwarding chain and route implementation |
router/ |
Route table router (destination-based routing) |
hop/ |
Node group with load-balanced selection |
selector/ |
Load-balancing strategies (round-robin, random, weighted, hash) |
auth/, bypass/, admission/ |
Authentication, bypass rules, admission control |
resolver/, hosts/ |
DNS resolution and host mapping |
limiter/ |
Traffic, connection, and rate limiters |
recorder/, observer/ |
Traffic recording and observability |
ingress/, sd/, routing/ |
Ingress control, service discovery, routing rules |
logger/, metrics/, api/ |
Logging, Prometheus metrics, Web API |
metadata/, ctx/ |
Metadata key-value system and context propagation |
internal/ |
Shared internals — not importable externally |
Component pattern
Every handler, listener, dialer, and connector follows the same pattern: init() registers a constructor into a global registry, the constructor takes functional options, and Init(metadata.Metadata) extracts typed configuration from the metadata key-value map.
See CLAUDE.md for detailed architecture and conventions.
Languages
Go
100%