How bothrachhavi/secure-gateway works
Secure Gateway is a small Go forward proxy. A client request enters the proxy handler, increments telemetry, passes per-IP rate limiting and domain filtering, then routes to HTTP forwarding or HTTPS CONNECT tunneling. A separate management listener serves JSON metrics. The blocklist is loaded once at startup. The sampled source is the complete runtime implementation; relationships below are based on its calls and the README’s documented behavior.
Main entry points: main.go Gateway handler · blocked_domains.txt Domain blocklist
Components 12
Proxy runtime
- Gateway handler
main.go - HTTP forwarding
main.go - CONNECT tunnel
main.go
Traffic controls
- Client IP extraction
main.go - Per-IP limiter
main.go - Domain filter
main.go - Domain blocklist
blocked_domains.txt
Metrics service
- Metrics counters
main.go - Metrics listener
main.go
Other components
- Proxy client
- Upstream host
- Metrics client
Connections 12
- Proxy client → Gateway handler: sends request
README.md - Gateway handler → Metrics counters: increments counters
main.go - Gateway handler → Client IP extraction: extracts address
main.go - Gateway handler → Per-IP limiter: checks rate
main.go - Gateway handler → Domain filter: checks host
main.go - Domain filter → Domain blocklist: loads entries
main.go - Gateway handler → HTTP forwarding: routes HTTP
main.go - Gateway handler → CONNECT tunnel: routes CONNECT
main.go - HTTP forwarding → Upstream host: forwards request
main.go - CONNECT tunnel → Upstream host: opens TCP tunnel
main.go - Metrics client → Metrics listener: requests stats
README.md - Metrics listener → Metrics counters: reads counters
main.go