snigateway: pooled tunnel transport with PROXY protocol, session-scoped registration and failover #612
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 260 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.333
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #612"
general
weight: 0.35
justinsb
This PR implements a pooled reverse tunnel transport with PROXY protocol v2, session-scoped registrations, and failover for
snigateway.Summary of Changes
1. Transport Interface & Refactor:
- Introduced
TransportandPoolTransportabstractions inpkg/frontendseparating data-plane connections from the control plane.2. Warm Pool of Pre-Dialed Reverse Tunnels & Session Registration:
- Replaced per-connection dial-back with a pool of $N$ pre-dialed reverse tunnels (configured via
--tunnel-pool-size, default 4).- Backend controllers establish long-lived sessions (
GET /v1/session) and register hostnames (PUT /v1/registrationwithX-Session-ID). Multiple replicas sharing a certificate now register independent sessions without overwriting each other.- Pool workers replenish connections immediately as idle tunnels are activated.
3. PROXY Protocol v2 Header:
- Implemented
pkg/proxyprotofor PROXY protocol v2 encoding and decoding withPP2_TYPE_AUTHORITY(0x02) TLV support for SNI hostnames.- Frontend writes PROXY v2 header upon activating a pooled connection. Backend listener parses the header and wraps connections to expose real client IP addresses in
RemoteAddr(), ensuringX-Forwarded-Forpropagation.4. Health Checking, Failover, and Testing:
- Implemented replay-until-first-byte failover on the frontend. If a dead or unresponsive pooled connection fails before backend response bytes are received, the frontend drops the tunnel and replays the PROXY header + ClientHello to another healthy pooled connection.
- Enabled TCP keepalives on pooled connections.
- Added unit tests for PROXY v2 encoding/decoding, pool management, session registration, dead pooled connections, and unresponsive backend failover.
- Extended
TestSNIGatewayinsnigateway/tests/e2eto run two controller replicas for the same hostname, kill one replica, and verify continuous request handling and real client IP forwarding.- Updated
docs/sni-reverse-tunnel.mdandsnigateway/README.md.Fixes #607