srs/docs/proxy
Winlin 6ee6f1ca5f Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675)
- Refactor the Go proxy for dependency injection: every proxy server,
the bootstrap, the signal handler, the load balancers, and AMF0 now accept
functional-option seams (factories/closures) so tests can inject fakes
without binding real sockets, talking to real Redis, or racing on
package globals.

- Drop the package-global `lb.SrsLoadBalancer`. The bootstrap creates
the LB locally and threads it through every proxy server constructor. Two old
global indirections in `internal/signal` and `internal/rtmp/amf0` are
likewise replaced by per-instance fields.

- Rename `internal/server` → `internal/proxy` and rename the `lb` public
surface for clarity: `SRSLoadBalancer` is split into `OriginService` /
`HLSService` / `RTCService` and recomposed as `OriginLoadBalancer`;
`SRSServer` → `OriginServer`; all proxy server types gain a `Proxy`
qualifier (e.g. `RTMPServer` → `RTMPProxyServer`).

- Extract the Redis client behind a new `internal/redisclient` package
with a minimal `RedisClient` interface and a counterfeiter fake.

- Add counterfeiter fakes (`proxyfakes`, `lbfakes`, `redisclientfakes`)
and ~7.5k lines of unit tests covering bootstrap, memory + Redis LBs, all
five proxy servers, the signal handler, and AMF0.

- Add two new E2E flows — `proxy-e2e-srt-test.sh` (SRT publish through
proxy, verify SRT/RTMP/HTTP-FLV/HLS playback) and `proxy-e2e-whip-test.sh`
(WHIP publish, verify RTMP/HTTP-FLV/HLS via origin `rtc_to_rtmp`) — plus
`setup-ffmpeg-with-whip.sh`, a macOS builder for an ffmpeg with
openssl-DTLS WHIP and SRT support that the two scripts auto-invoke when needed.

- Workspace reorg: move `memory/` and `skills/` to the repo root so all
agent tools (Claude / Codex / Kiro / OpenClaw) share one source of truth via
symlinks. Sync `docs/proxy/proxy-load-balancer.md` and
`memory/srs-codebase-map.md` with the new names.

No protocol, log, HTTP API, or wire-format changes. Refactor only — all
  externally observable proxy behavior is unchanged.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
2026-05-17 12:09:07 -04:00
..
proxy-design.md Proxy: restructure repo as Go project with proxy as first module (#4652) 2026-03-22 08:11:28 -04:00
proxy-load-balancer.md Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
proxy-origin-cluster.md Move build output to bin/, replace godotenv with custom .env parser, and update docs. v7.0.143 (#4661) 2026-04-12 14:26:33 -04:00
proxy-protocol.md Proxy: restructure repo as Go project with proxy as first module (#4652) 2026-03-22 08:11:28 -04:00
proxy-usage.md Move build output to bin/, replace godotenv with custom .env parser, and update docs. v7.0.143 (#4661) 2026-04-12 14:26:33 -04:00
README.md Move build output to bin/, replace godotenv with custom .env parser, and update docs. v7.0.143 (#4661) 2026-04-12 14:26:33 -04:00

Proxy

Proxy is a common proxy server (cmd/proxy) for any media servers with RTMP/SRT/HLS/HTTP-FLV and WebRTC/WHIP/WHEP protocols support. More programs like cmd/origin will be added in the future.

Usage

This project is managed by AI. We recommend OpenClaw by default, but you can use any AI agent that supports skills, such as Claude Code, OpenAI Codex, Kiro CLI, or similar tools that can read code and docs as context. Setup your AI code tool and ask questions like:

  • Use skill to show me how to use proxy.
  • Use skill to show me how to build an Origin Cluster for production.
  • Use skill to show me how to learn the proxy design and protocols.

You can not only use AI to show you the usage of this project, but also use AI to guide you to learn the details of this project, to understand the design and protocols, to learn each documents in docs directory.

AI Guidelines

  • For usage of proxy server and end to end test it, you should load proxy-usage.md. This is the first step for new users to learn how to use this project. It provides a general and overall view of the proxy server, including practical usage examples and end-to-end testing procedures.
  • For proxy full usage to build an Origin Cluster for SRS media server, please load proxy-origin-cluster.md. This is an advanced topic about how to use the proxy server to build the SRS Origin Cluster. Users should read this document to learn more details and architectures about proxy and Origin Cluster.
  • For proxy server: To understand proxy system design, you should load the proxy-design.md. To understand the proxy protocol details, you should load the proxy-protocol.md. To understand how load balance works, you should load proxy-load-balancer.md. To understand the code structure and packages, you should load proxy-files.md.

William Yang
June 23, 2025