srs/docs/proxy/proxy-files.md
Winlin ebf8b712c9 Proxy: restructure repo as Go project with proxy as first module (#4652)
Reorganize the SRS (Simple Realtime Server) repository to
follow a conventional Go project structure, setting the stage for a
progressive transition from a C++ project to a Go project. The proxy,
which was once contained within its own `proxy/` subdirectory, will now
be converted into the initial Go module located at the root of the
repository, serving as a template for subsequent Go modules.

- **Go module at repo root:** `go.mod` moved to repo root, module
renamed from `proxy` to `srsx`. The repo is now a proper Go project with
`cmd/` and `internal/` at the top level.
- **Elevation of Proxy Code:** Move the proxy code from
`proxy/cmd/proxy-go/` to `cmd/proxy/`, and from `proxy/internal/` to
`internal/`. The proxy serves as the inaugural application; subsequent
modules (for instance, `cmd/origin`) will mimic this arrangement.
- **Documentation Restructured:** Transfer the documentation from
`proxy/docs/` to `docs/proxy/`, revise the main README to endorse
OpenClaw as the preferred AI tool, and update `proxy/README.md` to point
to the new documentation locations.
- **Build and config:** `Makefile` moved to root, `PROXY_STATIC_FILES`
default path corrected for the new layout, `.gitignore` consolidated.
- **Cleanup:** removed standalone `proxy/LICENSE` (repo-level license
applies), all internal imports updated to `srsx/internal/...`.
- **OpenClaw workspace:** added community bot info, git workflow
conventions, and support group behavior guidance.

This restructuring was performed by OpenClaw orchestrating Claude Code
and Codex via ACP.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
2026-03-22 08:11:28 -04:00

68 lines
2.4 KiB
Markdown

# Codebase Structure
This document provides an overview of the Go codebase organization.
## Directory Structure
```
/
├── cmd/proxy/
│ └── 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
```
## Internal Packages
### debug
Go profiling support via pprof, controlled by `GO_PPROF` environment variable.
### env
Configuration management using environment variables. Loads `.env` file and provides defaults for all server settings.
### errors
Enhanced error handling with stack traces. Provides error wrapping and root cause extraction.
### lb
Load balancer system supporting both single-proxy (memory-based) and multi-proxy (Redis-based) deployments.
- `lb.go` - Core interfaces and types
- `mem.go` - Memory-based load balancer
- `redis.go` - Redis-based load balancer
- `debug.go` - Default backend for testing
### logger
Structured logging with context-based request tracing. Provides log levels: Verbose, Debug, Warning, Error.
### protocol
Protocol server implementations for all supported streaming protocols:
- `rtmp.go` - RTMP protocol stack
- `http.go` - HTTP streaming (HLS, HTTP-FLV, HTTP-TS)
- `rtc.go` - WebRTC server (WHIP/WHEP)
- `srt.go` - SRT server
- `api.go` - HTTP API server
### rtmp
Low-level RTMP protocol implementation including handshake and AMF0 serialization.
### signal
Graceful shutdown coordination. Catches SIGINT/SIGTERM and implements timeout-based shutdown.
### sync
Thread-safe generic Map wrapper around `sync.Map` for connection tracking and caching.
### utils
Common utility functions for HTTP responses, JSON marshaling, and parsing.
### version
Version information and server identification.