mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
Add RESP protocol detection to the sniffing framework so plaintext Redis traffic on a port-reuse listener can be identified and routed by protocol. Sniff() now peeks 1 byte first to match RESP type bytes (*+-:$) without blocking, then falls through to the existing 5-byte TLS/HTTP/SSH detection. ParseRedisMetadata consumes exactly one RESP message via io.TeeReader and records command/key in HandlerRecorderObject.Redis. HandleRedis in both the sniffing (injected-dial) and forwarder (hop-selected) packages replays the captured first message and pipes the rest, so pipelined commands beyond the first are forwarded transparently. Wired into all 5 dispatch sites: sni, forward/local, forward/remote, http CONNECT, and relay tunnel handlers. forwarder paths route via resolveRedisNode using ProtocolSelectOption(ProtoRedis), enabling `protocol: redis` hop selection. Part of two-phase plan (2026-07-29-sniffing-redis-postgres.md); PostgreSQL deferred to phase 2.