mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
v0.26.2
waterutil.IsIPv4 and IsIPv6 index packet[0] with no length check, and a tun device can legally return zero bytes with no error — an Android VpnService fd does exactly that. routing such a read into a classifier panics with "index out of range [0] with length 0", and in the c-shared library the phone loads the runtime cannot unwind past the cgo boundary, so the panic took the app: the spoke died on 2026-10-12 with three such lines in crash.log, no stack, and a 17-minute gap before Android restarted it. The knowledge was already in the tree — sourceOf and destinationOf in handler/tun/p2p.go carry the guard, with a comment naming this exact panic — but the eight reads in the client and server loops and the association classifier in handler/router did not. The asymmetry was the bug. The guard now lives once, in internal/util/tun, as IPv4Packet and IPv6Packet, and every classifier goes through it. Tested at the real entry point: a fake device that returns (0, nil) before handing over a real IPv4 packet, asserted to be survived and forwarded.
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%