proxy/docs/proxy-files.md
This document provides an overview of the Go codebase organization.
/
├── cmd/proxy-go/
│ └── main.go # Application entry point
└── internal/
├── debug/ # Go profiling support
├── env/ # Configuration management
├── errors/ # Error handling with stack traces
├── lb/ # Load balancer (memory/Redis)
├── logger/ # Logging and request tracing
├── protocol/ # Protocol servers (RTMP, HTTP, WebRTC, SRT, API)
├── rtmp/ # RTMP protocol implementation
├── signal/ # Graceful shutdown handling
├── sync/ # Concurrency utilities
├── utils/ # Common utilities
└── version/ # Version information
Go profiling support via pprof, controlled by GO_PPROF environment variable.
Configuration management using environment variables. Loads .env file and provides defaults for all server settings.
Enhanced error handling with stack traces. Provides error wrapping and root cause extraction.
Load balancer system supporting both single-proxy (memory-based) and multi-proxy (Redis-based) deployments.
lb.go - Core interfaces and typesmem.go - Memory-based load balancerredis.go - Redis-based load balancerdebug.go - Default backend for testingStructured logging with context-based request tracing. Provides log levels: Verbose, Debug, Warning, Error.
Protocol server implementations for all supported streaming protocols:
rtmp.go - RTMP protocol stackhttp.go - HTTP streaming (HLS, HTTP-FLV, HTTP-TS)rtc.go - WebRTC server (WHIP/WHEP)srt.go - SRT serverapi.go - HTTP API serverLow-level RTMP protocol implementation including handshake and AMF0 serialization.
Graceful shutdown coordination. Catches SIGINT/SIGTERM and implements timeout-based shutdown.
Thread-safe generic Map wrapper around sync.Map for connection tracking and caching.
Common utility functions for HTTP responses, JSON marshaling, and parsing.
Version information and server identification.