mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
Replace the 5 duplicated switch statements that dispatch sniffed connections (forward/local, forward/remote, http CONNECT, sni, relay) with per-package registries keyed by proto string. Protocol handlers self-register via init(), following the house registration pattern, so adding a protocol no longer requires touching every dispatch site. Unify the two HandleOptions types (forwarder lacked dialTLS; sniffing lacked hop/node/httpKeepalive) into one exported struct in sniffing; forwarder aliases it. Unknown protocols fall through to raw forwarding exactly as before; SSH remains detection-only. redirect/tcp's special fallback-replay dispatch is intentionally left untouched. Adds Dispatch helpers and 8 registry tests (register/get/duplicate/ unknown/known) in both packages. Net -151 lines.