Proxy: Refine logger and environment APIs. v7.0.146 (#4670)

This PR refines the next-generation proxy internals and workspace
documentation:

  - Reworks internal/logger to expose clearer slog-style APIs:
      - Replaces Vf/Df/Wf/Ef with Info/Debug/Warn/Error.
      - Adds structured key/value log arguments.
      - Adds version to every log record.
      - Uses standard slog level labels (DEBUG, INFO, WARN, ERROR).
      - Keeps compatibility for existing printf-style messages.
  - Renames proxy configuration abstractions:
      - Environment → ProxyEnvironment.
      - NewEnvironment → NewProxyEnvironment.
- Regenerates/renames the counterfeiter fake to FakeProxyEnvironment.
- Updates all proxy bootstrap, load balancer, protocol, signal, debug,
and utility call sites for the new logger and
    environment APIs.
  - Consolidates proxy codebase navigation:
      - Deletes docs/proxy/proxy-files.md.
- Moves the useful file/module map details into
.openclaw/memory/srs-codebase-map.md.
- Replaces agent instruction symlinks with explicit workspace
instruction files for Claude, Codex, and Kiro.
  - Updates OpenClaw tool notes with Codex commit-prefix guidance.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Winlin 2026-04-28 07:18:45 -04:00 committed by GitHub
parent 30fc7775a5
commit d8696434cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 415 additions and 474 deletions

View File

@ -1 +0,0 @@
../.openclaw/AGENTS.md

18
.claude/CLAUDE.md Normal file
View File

@ -0,0 +1,18 @@
# Workspace Instructions
Keep the current working directory unchanged. For workspace instructions and workspace-owned files, look for files and folders under `.claude/`.
Before doing any work in this repository, read these files in full from `.claude/`:
- `.claude/IDENTITY.md`
- `.claude/MEMORY.md`
- `.claude/SOUL.md`
- `.claude/TOOLS.md`
- `.claude/USER.md`
Use them as the workspace context for identity, user preferences, memory, local tools, and operating conventions.
Additional `.claude/` workspace folders:
- `.claude/skills/` — skills available for tasks in this repository.
- `.claude/memory/` — persisted notes and references for this workspace.

View File

@ -1,16 +0,0 @@
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "content=\"\"; for f in .claude/SOUL.md .claude/USER.md .claude/MEMORY.md .claude/IDENTITY.md .claude/TOOLS.md; do if [ -f \"$f\" ]; then content=\"$content\\n--- $f ---\\n$(cat \"$f\")\"; fi; done; jq -n --arg ctx \"$content\" '{hookSpecificOutput: {hookEventName: \"SessionStart\", additionalContext: $ctx}}'",
"timeout": 10,
"statusMessage": "Loading SOUL.md, USER.md, MEMORY.md, IDENTITY.md, TOOLS.md..."
}
]
}
]
}
}

View File

@ -1 +0,0 @@
../.openclaw/AGENTS.md

18
.codex/CODEX.md Normal file
View File

@ -0,0 +1,18 @@
# Workspace Instructions
Keep the current working directory unchanged. For workspace instructions and workspace-owned files, look for files and folders under `.codex/`.
Before doing any work in this repository, read these files in full from `.codex/`:
- `.codex/IDENTITY.md`
- `.codex/MEMORY.md`
- `.codex/SOUL.md`
- `.codex/TOOLS.md`
- `.codex/USER.md`
Use them as the workspace context for identity, user preferences, memory, local tools, and operating conventions.
Additional `.codex/` workspace folders:
- `.codex/skills/` — skills available for tasks in this repository.
- `.codex/memory/` — persisted notes and references for this workspace.

View File

@ -3,5 +3,3 @@
# Codex currently supports one explicit instruction entrypoint file.
# That file can then instruct Codex to read additional local files at session start.
model_instructions_file = "CODEX.md"
project_doc_fallback_filenames = ["AGENTS.md", "IDENTITY.md", "MEMORY.md", "SOUL.md", "TOOLS.md", "USER.md"]
project_doc_max_bytes = 131072

View File

@ -1 +0,0 @@
../../.openclaw/AGENTS.md

18
.kiro/steering/KIRO.md Normal file
View File

@ -0,0 +1,18 @@
# Workspace Instructions
Keep the current working directory unchanged. For workspace instructions and workspace-owned files, look for files and folders under `.kiro/steering/`.
Before doing any work in this repository, read these files in full from `.kiro/steering/`:
- `.kiro/steering/IDENTITY.md`
- `.kiro/steering/MEMORY.md`
- `.kiro/steering/SOUL.md`
- `.kiro/steering/TOOLS.md`
- `.kiro/steering/USER.md`
Use them as the workspace context for identity, user preferences, memory, local tools, and operating conventions.
Additional `.kiro/` workspace folders:
- `.kiro/skills/` — skills available for tasks in this repository.
- `.kiro/memory/` — persisted notes and references for this workspace.

View File

@ -58,8 +58,11 @@ Skills are shared. Your setup is yours. Keeping them apart means you can update
- **Never `git add`** — William stages files himself
- **Never `git push`** — William pushes himself
- **Commit workflow:** `git diff --cached` → understand the changes → write title/description → `git commit -m "OpenClaw: ..."` or `"Claude: ..."`
- Title prefix: `OpenClaw:` or `Claude:`
- **Commit workflow:** `git diff --cached` → understand the changes → write title/description → choose the title prefix based on the tool used → `git commit -m "OpenClaw: ..."`, `"Claude: ..."`, or `"Codex: ..."`
- Title prefix:
- Use `OpenClaw:` if OpenClaw made the changes.
- Use `Claude:` if Claude made the changes.
- Use `Codex:` if Codex made the changes.
- **Co-author for ACP Claude Code:** If Claude Code (ACP) was used to make the changes, add:
`Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>`
- **Co-author for ACP Codex:** If Codex (ACP) was used to make the changes, add:

View File

@ -211,19 +211,19 @@ State Threads (`trunk/3rdparty/st-srs/`) is the coroutine library used by the C+
The next-generation server (`cmd/` + `internal/`) is written in Go and maintained by AI. It is the future of SRS. Currently it only supports proxy, but work is ongoing to support the full feature set including origin, edge, and proxy servers.
`cmd/proxy` — A stateless reverse proxy that sits in front of one or more SRS C++ origin servers. Accepts client connections (RTMP, HTTP-FLV/HLS, WebRTC WHIP/WHEP, SRT), resolves a backend origin via the load balancer, and transparently proxies traffic. Does not cache streams or process media — only forwards bytes. Configuration entirely via environment variables (or `.env` file), no config file. Supports two deployment modes: single-proxy (in-memory LB) and multi-proxy (Redis-based shared LB for horizontal scaling behind a network load balancer).
`cmd/proxy` — A stateless reverse proxy that sits in front of one or more SRS C++ origin servers. Accepts client connections (RTMP, HTTP-FLV/HLS, WebRTC WHIP/WHEP, SRT), resolves a backend origin via the load balancer, and transparently proxies traffic. Does not cache streams or process media — only forwards bytes. Configuration entirely via environment variables (or `.env` file), no config file. Supports two deployment modes: single-proxy (in-memory LB) and multi-proxy (Redis-based shared LB for horizontal scaling behind a network load balancer). Entry point: `cmd/proxy/main.go`.
`internal/bootstrap` — Server startup and lifecycle orchestration. Sets up logging context, signal handlers, loads environment, installs force-quit timer, optionally starts pprof, initializes the load balancer (memory or Redis based on `PROXY_LOAD_BALANCER_TYPE`), then starts all six servers sequentially (RTMP, WebRTC, HTTP API, SRT, System API, HTTP Stream) and blocks until context is cancelled. Deferred `Close()` on each server ensures graceful shutdown.
`internal/protocol` — Protocol proxy servers. Each server accepts client connections, parses just enough of the protocol to extract the stream URL, picks a backend via the load balancer, and proxies traffic bidirectionally. Contains five proxy servers: (1) **RTMP proxy** — TCP listener, simple handshake, parses connect/publish/play to get stream URL, bidirectional RTMP message copying, stateless. (2) **HTTP stream proxy** — serves static files, proxies HTTP-FLV/TS via reverse-proxy, proxies HLS m3u8 with `spbhid` rewriting so TS segment requests route to the same backend. (3) **WebRTC proxy** — two-phase: WHIP/WHEP signaling (SDP rewrite to replace backend UDP port with proxy's) + UDP media transport (identifies connections by STUN ufrag, supports address migration), stateful. (4) **SRT proxy** — intercepts SRT 4-step handshake locally, parses stream ID on handshake 2, replays full handshake with backend, then proxies UDP bidirectionally, stateful per-connection. (5) **HTTP API + System API** — HTTP API delegates WHIP/WHEP to WebRTC server; System API provides `/api/v1/srs/register` where backend SRS C++ servers register themselves so the load balancer knows about them.
`internal/protocol` — Protocol proxy servers. Each server accepts client connections, parses just enough of the protocol to extract the stream URL, picks a backend via the load balancer, and proxies traffic bidirectionally. Contains five proxy servers: (1) **RTMP proxy** (`rtmp.go`) — TCP listener, simple handshake, parses connect/publish/play to get stream URL, bidirectional RTMP message copying, stateless. (2) **HTTP stream proxy** (`http.go`) — serves static files, proxies HTTP-FLV/TS via reverse-proxy, proxies HLS m3u8 with `spbhid` rewriting so TS segment requests route to the same backend. (3) **WebRTC proxy** (`rtc.go`) — two-phase: WHIP/WHEP signaling (SDP rewrite to replace backend UDP port with proxy's) + UDP media transport (identifies connections by STUN ufrag, supports address migration), stateful. (4) **SRT proxy** (`srt.go`) — intercepts SRT 4-step handshake locally, parses stream ID on handshake 2, replays full handshake with backend, then proxies UDP bidirectionally, stateful per-connection. (5) **HTTP API + System API** (`api.go`) — HTTP API delegates WHIP/WHEP to WebRTC server; System API provides `/api/v1/srs/register` where backend SRS C++ servers register themselves so the load balancer knows about them.
`internal/rtmp` — RTMP protocol implementation (parsing, not proxying). Full RTMP chunk stream and message protocol: simple handshake (C0/C1/C2), chunk stream reader/writer with all four format types, extended timestamp, message reassembly from chunks. Defines all RTMP message types, chunk stream IDs, and command names. Packet types include ConnectApp, CreateStream, Publish, Play, Call, SetChunkSize, WindowAcknowledgementSize, SetPeerBandwidth, UserControl. Uses Go generics (`ExpectPacket[T]`) to read until a specific packet type arrives. Also includes full AMF0 encoder/decoder supporting Number, Boolean, String, Object, Null, Undefined, EcmaArray, StrictArray, Date, LongString — with ordered key-value maps, auto-type-discovery, and safe type converters.
`internal/lb` — Load balancer abstraction and two implementations. Defines `SRSLoadBalancer` interface (Initialize, Update, Pick, HLS/WebRTC state management) and `SRSServer` struct representing a backend origin (IP, listen endpoints for RTMP/HTTP/API/SRT/RTC, heartbeat tracking). **Memory LB** — in-memory using `sync.Map`, sticky random pick per stream URL, single-proxy deployment. **Redis LB** — Redis-backed shared state with TTL-based expiration, enables multi-proxy horizontal scaling behind a network load balancer. Also includes a debug helper that creates a fake backend from env vars when `PROXY_DEFAULT_BACKEND_ENABLED=on` for development without real SRS registration.
`internal/lb` — Load balancer abstraction and two implementations. Defines `SRSLoadBalancer` interface and core types in `lb.go` (Initialize, Update, Pick, HLS/WebRTC state management) and `SRSServer` struct representing a backend origin (IP, listen endpoints for RTMP/HTTP/API/SRT/RTC, heartbeat tracking). **Memory LB** (`mem.go`) — in-memory using `sync.Map`, sticky random pick per stream URL, single-proxy deployment. **Redis LB** (`redis.go`) — Redis-backed shared state with TTL-based expiration, enables multi-proxy horizontal scaling behind a network load balancer. Also includes a debug helper (`debug.go`) that creates a fake backend from env vars when `PROXY_DEFAULT_BACKEND_ENABLED=on` for development without real SRS registration.
`internal/logger` — Structured logging with context IDs. Four log levels: Verbose (discarded), Debug (stdout), Warn (stderr), Error (stderr). Emits JSON via `log/slog` with `pid` and `cid` attributes. Each connection/request gets a unique 7-char hex context ID for log correlation, stored in `context.Context`.
`internal/logger` — Structured logging with context IDs. Four log levels: Debug/Info (stdout), Warn/Error (stderr). Emits JSON via `log/slog` with `pid` and `cid` attributes. Each connection/request gets a unique 7-char hex context ID for log correlation, stored in `context.Context`.
`internal/env` — Environment-based configuration. All settings via env vars (or `.env` file parsed by an in-tree custom parser — no third-party dep; supports comments, `export` prefix, quoted values, escape sequences, and inline comments). Exposes an `Environment` interface (with a counterfeiter-generated fake in `envfakes/` for downstream tests) with methods for each config value. Default ports: RTMP=11935, HTTP API=11985, HTTP Stream=18080, WebRTC=18000, SRT=20080, System API=12025. Timeouts: grace=20s, force=30s. Supports Redis config and default backend config for debugging.
`internal/env` — Environment-based configuration. All settings via env vars (or `.env` file parsed by an in-tree custom parser — no third-party dep; supports comments, `export` prefix, quoted values, escape sequences, and inline comments). Exposes a `ProxyEnvironment` interface (with a counterfeiter-generated fake in `envfakes/` for downstream tests) with methods for each config value. Default ports: RTMP=11935, HTTP API=11985, HTTP Stream=18080, WebRTC=18000, SRT=20080, System API=12025. Timeouts: grace=20s, force=30s. Supports Redis config and default backend config for debugging.
`internal/version` — Version constants. Signature `SRSX`, version tracks the SRS project version (currently 7.0.x). Used in HTTP API responses and startup logging.
@ -298,7 +298,6 @@ The knowledge base (`memory/srs-*.md`) captures William's knowledge about SRS
- `proxy-design.md` — Architecture: stateless proxy with built-in load balancing, single-proxy vs multi-proxy (Redis) deployment modes, horizontal scaling behind NLB
- `proxy-protocol.md` — Backend registration protocol: default backend for debugging, automatic registration via SRS system API, heartbeat mechanism, env vars
- `proxy-usage.md` — Step-by-step guide: build proxy, start SRS origin, verify registration, publish with FFmpeg, verify playback with ffprobe
- `proxy-files.md` — Go codebase layout: cmd/proxy entry point, internal packages (debug, env, errors, lb, logger, protocol, rtmp, signal, sync, utils, version)
- `proxy-load-balancer.md` — Load balancer design: memory vs Redis implementations, stream-to-server mapping, server health via heartbeats, protocol-specific state
- `proxy-origin-cluster.md` — Origin cluster tutorial: build proxy + SRS, configure multi-origin with proxy, stream publishing and playback verification

View File

@ -1,67 +0,0 @@
# 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.

View File

@ -29,7 +29,7 @@ type proxyBootstrap struct{}
// Returns any error encountered during startup.
func (b *proxyBootstrap) Start(ctx context.Context) error {
ctx = logger.WithContext(ctx)
logger.Df(ctx, "%v-Proxy/%v started", version.Signature(), version.Version())
logger.Debug(ctx, "%v-Proxy/%v started", version.Signature(), version.Version())
// Install signals.
ctx, cancel := context.WithCancel(ctx)
@ -38,11 +38,11 @@ func (b *proxyBootstrap) Start(ctx context.Context) error {
// Run the main loop, ignore the user cancel error.
err := b.run(ctx)
if err != nil && ctx.Err() != context.Canceled {
logger.Ef(ctx, "main: %+v", err)
logger.Error(ctx, "main: %+v", err)
return err
}
logger.Df(ctx, "%v done", version.Signature())
logger.Debug(ctx, "%v done", version.Signature())
return nil
}
@ -50,7 +50,7 @@ func (b *proxyBootstrap) Start(ctx context.Context) error {
// It blocks until the context is cancelled.
func (b *proxyBootstrap) run(ctx context.Context) error {
// Setup the environment variables.
environment, err := env.NewEnvironment(ctx)
environment, err := env.NewProxyEnvironment(ctx)
if err != nil {
return errors.Wrapf(err, "create environment")
}
@ -81,7 +81,7 @@ func (b *proxyBootstrap) run(ctx context.Context) error {
}
// initializeLoadBalancer sets up the load balancer based on configuration.
func (b *proxyBootstrap) initializeLoadBalancer(ctx context.Context, environment env.Environment) error {
func (b *proxyBootstrap) initializeLoadBalancer(ctx context.Context, environment env.ProxyEnvironment) error {
switch environment.LoadBalancerType() {
case "redis":
lb.SrsLoadBalancer = lb.NewRedisLoadBalancer(environment)
@ -97,7 +97,7 @@ func (b *proxyBootstrap) initializeLoadBalancer(ctx context.Context, environment
}
// startServers initializes and starts all protocol servers.
func (b *proxyBootstrap) startServers(ctx context.Context, environment env.Environment, gracefulQuitTimeout time.Duration) error {
func (b *proxyBootstrap) startServers(ctx context.Context, environment env.ProxyEnvironment, gracefulQuitTimeout time.Duration) error {
// Start the RTMP server.
srsRTMPServer := protocol.NewSRSRTMPServer(environment)
if err := srsRTMPServer.Run(ctx); err != nil {

View File

@ -11,10 +11,10 @@ import (
"srsx/internal/logger"
)
func HandleGoPprof(ctx context.Context, environment env.Environment) {
func HandleGoPprof(ctx context.Context, environment env.ProxyEnvironment) {
if addr := environment.GoPprof(); addr != "" {
go func() {
logger.Df(ctx, "Start Go pprof at %v", addr)
logger.Debug(ctx, "Start Go pprof at %v", addr)
http.ListenAndServe(addr, nil)
}()
}

62
internal/env/env.go vendored
View File

@ -25,8 +25,8 @@ var (
}
)
// Environment provides access to environment variables.
type Environment interface {
// ProxyEnvironment provides access to proxy environment variables.
type ProxyEnvironment interface {
// Go pprof profiling
GoPprof() string
// Graceful quit timeout
@ -73,102 +73,102 @@ type Environment interface {
DefaultBackendSRT() string
}
type environment struct{}
type proxyEnvironment struct{}
// NewEnvironment creates a new Environment instance, loading and building default environment variables.
func NewEnvironment(ctx context.Context) (Environment, error) {
// NewProxyEnvironment creates a new ProxyEnvironment instance, loading and building default environment variables.
func NewProxyEnvironment(ctx context.Context) (ProxyEnvironment, error) {
if err := loadEnvFile(ctx); err != nil {
return nil, err
}
buildDefaultEnvironmentVariables(ctx)
return &environment{}, nil
return &proxyEnvironment{}, nil
}
func (e *environment) GoPprof() string {
func (e *proxyEnvironment) GoPprof() string {
return getEnv("GO_PPROF")
}
func (e *environment) GraceQuitTimeout() string {
func (e *proxyEnvironment) GraceQuitTimeout() string {
return getEnv("PROXY_GRACE_QUIT_TIMEOUT")
}
func (e *environment) ForceQuitTimeout() string {
func (e *proxyEnvironment) ForceQuitTimeout() string {
return getEnv("PROXY_FORCE_QUIT_TIMEOUT")
}
func (e *environment) HttpAPI() string {
func (e *proxyEnvironment) HttpAPI() string {
return getEnv("PROXY_HTTP_API")
}
func (e *environment) HttpServer() string {
func (e *proxyEnvironment) HttpServer() string {
return getEnv("PROXY_HTTP_SERVER")
}
func (e *environment) RtmpServer() string {
func (e *proxyEnvironment) RtmpServer() string {
return getEnv("PROXY_RTMP_SERVER")
}
func (e *environment) WebRTCServer() string {
func (e *proxyEnvironment) WebRTCServer() string {
return getEnv("PROXY_WEBRTC_SERVER")
}
func (e *environment) SRTServer() string {
func (e *proxyEnvironment) SRTServer() string {
return getEnv("PROXY_SRT_SERVER")
}
func (e *environment) SystemAPI() string {
func (e *proxyEnvironment) SystemAPI() string {
return getEnv("PROXY_SYSTEM_API")
}
func (e *environment) StaticFiles() string {
func (e *proxyEnvironment) StaticFiles() string {
return getEnv("PROXY_STATIC_FILES")
}
func (e *environment) LoadBalancerType() string {
func (e *proxyEnvironment) LoadBalancerType() string {
return getEnv("PROXY_LOAD_BALANCER_TYPE")
}
func (e *environment) RedisHost() string {
func (e *proxyEnvironment) RedisHost() string {
return getEnv("PROXY_REDIS_HOST")
}
func (e *environment) RedisPort() string {
func (e *proxyEnvironment) RedisPort() string {
return getEnv("PROXY_REDIS_PORT")
}
func (e *environment) RedisPassword() string {
func (e *proxyEnvironment) RedisPassword() string {
return getEnv("PROXY_REDIS_PASSWORD")
}
func (e *environment) RedisDB() string {
func (e *proxyEnvironment) RedisDB() string {
return getEnv("PROXY_REDIS_DB")
}
func (e *environment) DefaultBackendEnabled() string {
func (e *proxyEnvironment) DefaultBackendEnabled() string {
return getEnv("PROXY_DEFAULT_BACKEND_ENABLED")
}
func (e *environment) DefaultBackendIP() string {
func (e *proxyEnvironment) DefaultBackendIP() string {
return getEnv("PROXY_DEFAULT_BACKEND_IP")
}
func (e *environment) DefaultBackendRTMP() string {
func (e *proxyEnvironment) DefaultBackendRTMP() string {
return getEnv("PROXY_DEFAULT_BACKEND_RTMP")
}
func (e *environment) DefaultBackendHttp() string {
func (e *proxyEnvironment) DefaultBackendHttp() string {
return getEnv("PROXY_DEFAULT_BACKEND_HTTP")
}
func (e *environment) DefaultBackendAPI() string {
func (e *proxyEnvironment) DefaultBackendAPI() string {
return getEnv("PROXY_DEFAULT_BACKEND_API")
}
func (e *environment) DefaultBackendRTC() string {
func (e *proxyEnvironment) DefaultBackendRTC() string {
return getEnv("PROXY_DEFAULT_BACKEND_RTC")
}
func (e *environment) DefaultBackendSRT() string {
func (e *proxyEnvironment) DefaultBackendSRT() string {
return getEnv("PROXY_DEFAULT_BACKEND_SRT")
}
@ -177,7 +177,7 @@ func loadEnvFile(ctx context.Context) error {
envMap, err := parseEnvFile(".env")
if err != nil {
if os.IsNotExist(err) {
logger.Df(ctx, "no .env file found, skipping")
logger.Debug(ctx, "no .env file found, skipping")
return nil
}
return errors.Wrapf(err, "load .env file")
@ -190,7 +190,7 @@ func loadEnvFile(ctx context.Context) error {
}
}
logger.Df(ctx, "successfully loaded .env file")
logger.Debug(ctx, "successfully loaded .env file")
return nil
}
@ -315,7 +315,7 @@ func buildDefaultEnvironmentVariables(ctx context.Context) {
// Default backend udp srt port, for debugging.
setEnvDefault("PROXY_DEFAULT_BACKEND_SRT", "10080")
logger.Df(ctx, "load .env as GO_PPROF=%v, "+
logger.Debug(ctx, "load .env as GO_PPROF=%v, "+
"PROXY_FORCE_QUIT_TIMEOUT=%v, PROXY_GRACE_QUIT_TIMEOUT=%v, "+
"PROXY_HTTP_API=%v, PROXY_HTTP_SERVER=%v, PROXY_RTMP_SERVER=%v, "+
"PROXY_WEBRTC_SERVER=%v, PROXY_SRT_SERVER=%v, "+

View File

@ -303,7 +303,7 @@ func TestSetEnvDefault_PreservesExisting(t *testing.T) {
}
}
func TestNewEnvironment_AppliesDefaultsAndAccessors(t *testing.T) {
func TestNewProxyEnvironment_AppliesDefaultsAndAccessors(t *testing.T) {
withFakeEnv(t)
// No .env file present.
withFakeOpen(t, "", os.ErrNotExist)
@ -312,9 +312,9 @@ func TestNewEnvironment_AppliesDefaultsAndAccessors(t *testing.T) {
// pre-set it so the accessor has a value to return.
setEnv("PROXY_DEFAULT_BACKEND_HTTP", "8080")
env, err := NewEnvironment(context.Background())
env, err := NewProxyEnvironment(context.Background())
if err != nil {
t.Fatalf("NewEnvironment: %v", err)
t.Fatalf("NewProxyEnvironment: %v", err)
}
cases := []struct {
@ -352,26 +352,26 @@ func TestNewEnvironment_AppliesDefaultsAndAccessors(t *testing.T) {
}
}
func TestNewEnvironment_PreservesPreSetValues(t *testing.T) {
func TestNewProxyEnvironment_PreservesPreSetValues(t *testing.T) {
withFakeEnv(t)
withFakeOpen(t, "", os.ErrNotExist)
setEnv("PROXY_HTTP_API", "9999")
env, err := NewEnvironment(context.Background())
env, err := NewProxyEnvironment(context.Background())
if err != nil {
t.Fatalf("NewEnvironment: %v", err)
t.Fatalf("NewProxyEnvironment: %v", err)
}
if got := env.HttpAPI(); got != "9999" {
t.Errorf("HttpAPI() = %q, want %q", got, "9999")
}
}
func TestNewEnvironment_LoadEnvFailurePropagates(t *testing.T) {
func TestNewProxyEnvironment_LoadEnvFailurePropagates(t *testing.T) {
withFakeEnv(t)
sentinel := errors.New("open failed")
withFakeOpen(t, "", sentinel)
_, err := NewEnvironment(context.Background())
_, err := NewProxyEnvironment(context.Background())
if srserrors.Cause(err) != sentinel {
t.Errorf("expected wrapped sentinel, got: %v", err)
}

View File

@ -6,7 +6,7 @@ import (
"sync"
)
type FakeEnvironment struct {
type FakeProxyEnvironment struct {
DefaultBackendAPIStub func() string
defaultBackendAPIMutex sync.RWMutex
defaultBackendAPIArgsForCall []struct {
@ -231,7 +231,7 @@ type FakeEnvironment struct {
invocationsMutex sync.RWMutex
}
func (fake *FakeEnvironment) DefaultBackendAPI() string {
func (fake *FakeProxyEnvironment) DefaultBackendAPI() string {
fake.defaultBackendAPIMutex.Lock()
ret, specificReturn := fake.defaultBackendAPIReturnsOnCall[len(fake.defaultBackendAPIArgsForCall)]
fake.defaultBackendAPIArgsForCall = append(fake.defaultBackendAPIArgsForCall, struct {
@ -249,19 +249,19 @@ func (fake *FakeEnvironment) DefaultBackendAPI() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendAPICallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendAPICallCount() int {
fake.defaultBackendAPIMutex.RLock()
defer fake.defaultBackendAPIMutex.RUnlock()
return len(fake.defaultBackendAPIArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendAPICalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendAPICalls(stub func() string) {
fake.defaultBackendAPIMutex.Lock()
defer fake.defaultBackendAPIMutex.Unlock()
fake.DefaultBackendAPIStub = stub
}
func (fake *FakeEnvironment) DefaultBackendAPIReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendAPIReturns(result1 string) {
fake.defaultBackendAPIMutex.Lock()
defer fake.defaultBackendAPIMutex.Unlock()
fake.DefaultBackendAPIStub = nil
@ -270,7 +270,7 @@ func (fake *FakeEnvironment) DefaultBackendAPIReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendAPIReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendAPIReturnsOnCall(i int, result1 string) {
fake.defaultBackendAPIMutex.Lock()
defer fake.defaultBackendAPIMutex.Unlock()
fake.DefaultBackendAPIStub = nil
@ -284,7 +284,7 @@ func (fake *FakeEnvironment) DefaultBackendAPIReturnsOnCall(i int, result1 strin
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendEnabled() string {
func (fake *FakeProxyEnvironment) DefaultBackendEnabled() string {
fake.defaultBackendEnabledMutex.Lock()
ret, specificReturn := fake.defaultBackendEnabledReturnsOnCall[len(fake.defaultBackendEnabledArgsForCall)]
fake.defaultBackendEnabledArgsForCall = append(fake.defaultBackendEnabledArgsForCall, struct {
@ -302,19 +302,19 @@ func (fake *FakeEnvironment) DefaultBackendEnabled() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendEnabledCallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendEnabledCallCount() int {
fake.defaultBackendEnabledMutex.RLock()
defer fake.defaultBackendEnabledMutex.RUnlock()
return len(fake.defaultBackendEnabledArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendEnabledCalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendEnabledCalls(stub func() string) {
fake.defaultBackendEnabledMutex.Lock()
defer fake.defaultBackendEnabledMutex.Unlock()
fake.DefaultBackendEnabledStub = stub
}
func (fake *FakeEnvironment) DefaultBackendEnabledReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendEnabledReturns(result1 string) {
fake.defaultBackendEnabledMutex.Lock()
defer fake.defaultBackendEnabledMutex.Unlock()
fake.DefaultBackendEnabledStub = nil
@ -323,7 +323,7 @@ func (fake *FakeEnvironment) DefaultBackendEnabledReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendEnabledReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendEnabledReturnsOnCall(i int, result1 string) {
fake.defaultBackendEnabledMutex.Lock()
defer fake.defaultBackendEnabledMutex.Unlock()
fake.DefaultBackendEnabledStub = nil
@ -337,7 +337,7 @@ func (fake *FakeEnvironment) DefaultBackendEnabledReturnsOnCall(i int, result1 s
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendHttp() string {
func (fake *FakeProxyEnvironment) DefaultBackendHttp() string {
fake.defaultBackendHttpMutex.Lock()
ret, specificReturn := fake.defaultBackendHttpReturnsOnCall[len(fake.defaultBackendHttpArgsForCall)]
fake.defaultBackendHttpArgsForCall = append(fake.defaultBackendHttpArgsForCall, struct {
@ -355,19 +355,19 @@ func (fake *FakeEnvironment) DefaultBackendHttp() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendHttpCallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendHttpCallCount() int {
fake.defaultBackendHttpMutex.RLock()
defer fake.defaultBackendHttpMutex.RUnlock()
return len(fake.defaultBackendHttpArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendHttpCalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendHttpCalls(stub func() string) {
fake.defaultBackendHttpMutex.Lock()
defer fake.defaultBackendHttpMutex.Unlock()
fake.DefaultBackendHttpStub = stub
}
func (fake *FakeEnvironment) DefaultBackendHttpReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendHttpReturns(result1 string) {
fake.defaultBackendHttpMutex.Lock()
defer fake.defaultBackendHttpMutex.Unlock()
fake.DefaultBackendHttpStub = nil
@ -376,7 +376,7 @@ func (fake *FakeEnvironment) DefaultBackendHttpReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendHttpReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendHttpReturnsOnCall(i int, result1 string) {
fake.defaultBackendHttpMutex.Lock()
defer fake.defaultBackendHttpMutex.Unlock()
fake.DefaultBackendHttpStub = nil
@ -390,7 +390,7 @@ func (fake *FakeEnvironment) DefaultBackendHttpReturnsOnCall(i int, result1 stri
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendIP() string {
func (fake *FakeProxyEnvironment) DefaultBackendIP() string {
fake.defaultBackendIPMutex.Lock()
ret, specificReturn := fake.defaultBackendIPReturnsOnCall[len(fake.defaultBackendIPArgsForCall)]
fake.defaultBackendIPArgsForCall = append(fake.defaultBackendIPArgsForCall, struct {
@ -408,19 +408,19 @@ func (fake *FakeEnvironment) DefaultBackendIP() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendIPCallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendIPCallCount() int {
fake.defaultBackendIPMutex.RLock()
defer fake.defaultBackendIPMutex.RUnlock()
return len(fake.defaultBackendIPArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendIPCalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendIPCalls(stub func() string) {
fake.defaultBackendIPMutex.Lock()
defer fake.defaultBackendIPMutex.Unlock()
fake.DefaultBackendIPStub = stub
}
func (fake *FakeEnvironment) DefaultBackendIPReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendIPReturns(result1 string) {
fake.defaultBackendIPMutex.Lock()
defer fake.defaultBackendIPMutex.Unlock()
fake.DefaultBackendIPStub = nil
@ -429,7 +429,7 @@ func (fake *FakeEnvironment) DefaultBackendIPReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendIPReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendIPReturnsOnCall(i int, result1 string) {
fake.defaultBackendIPMutex.Lock()
defer fake.defaultBackendIPMutex.Unlock()
fake.DefaultBackendIPStub = nil
@ -443,7 +443,7 @@ func (fake *FakeEnvironment) DefaultBackendIPReturnsOnCall(i int, result1 string
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendRTC() string {
func (fake *FakeProxyEnvironment) DefaultBackendRTC() string {
fake.defaultBackendRTCMutex.Lock()
ret, specificReturn := fake.defaultBackendRTCReturnsOnCall[len(fake.defaultBackendRTCArgsForCall)]
fake.defaultBackendRTCArgsForCall = append(fake.defaultBackendRTCArgsForCall, struct {
@ -461,19 +461,19 @@ func (fake *FakeEnvironment) DefaultBackendRTC() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendRTCCallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendRTCCallCount() int {
fake.defaultBackendRTCMutex.RLock()
defer fake.defaultBackendRTCMutex.RUnlock()
return len(fake.defaultBackendRTCArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendRTCCalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendRTCCalls(stub func() string) {
fake.defaultBackendRTCMutex.Lock()
defer fake.defaultBackendRTCMutex.Unlock()
fake.DefaultBackendRTCStub = stub
}
func (fake *FakeEnvironment) DefaultBackendRTCReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendRTCReturns(result1 string) {
fake.defaultBackendRTCMutex.Lock()
defer fake.defaultBackendRTCMutex.Unlock()
fake.DefaultBackendRTCStub = nil
@ -482,7 +482,7 @@ func (fake *FakeEnvironment) DefaultBackendRTCReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendRTCReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendRTCReturnsOnCall(i int, result1 string) {
fake.defaultBackendRTCMutex.Lock()
defer fake.defaultBackendRTCMutex.Unlock()
fake.DefaultBackendRTCStub = nil
@ -496,7 +496,7 @@ func (fake *FakeEnvironment) DefaultBackendRTCReturnsOnCall(i int, result1 strin
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendRTMP() string {
func (fake *FakeProxyEnvironment) DefaultBackendRTMP() string {
fake.defaultBackendRTMPMutex.Lock()
ret, specificReturn := fake.defaultBackendRTMPReturnsOnCall[len(fake.defaultBackendRTMPArgsForCall)]
fake.defaultBackendRTMPArgsForCall = append(fake.defaultBackendRTMPArgsForCall, struct {
@ -514,19 +514,19 @@ func (fake *FakeEnvironment) DefaultBackendRTMP() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendRTMPCallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendRTMPCallCount() int {
fake.defaultBackendRTMPMutex.RLock()
defer fake.defaultBackendRTMPMutex.RUnlock()
return len(fake.defaultBackendRTMPArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendRTMPCalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendRTMPCalls(stub func() string) {
fake.defaultBackendRTMPMutex.Lock()
defer fake.defaultBackendRTMPMutex.Unlock()
fake.DefaultBackendRTMPStub = stub
}
func (fake *FakeEnvironment) DefaultBackendRTMPReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendRTMPReturns(result1 string) {
fake.defaultBackendRTMPMutex.Lock()
defer fake.defaultBackendRTMPMutex.Unlock()
fake.DefaultBackendRTMPStub = nil
@ -535,7 +535,7 @@ func (fake *FakeEnvironment) DefaultBackendRTMPReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendRTMPReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendRTMPReturnsOnCall(i int, result1 string) {
fake.defaultBackendRTMPMutex.Lock()
defer fake.defaultBackendRTMPMutex.Unlock()
fake.DefaultBackendRTMPStub = nil
@ -549,7 +549,7 @@ func (fake *FakeEnvironment) DefaultBackendRTMPReturnsOnCall(i int, result1 stri
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendSRT() string {
func (fake *FakeProxyEnvironment) DefaultBackendSRT() string {
fake.defaultBackendSRTMutex.Lock()
ret, specificReturn := fake.defaultBackendSRTReturnsOnCall[len(fake.defaultBackendSRTArgsForCall)]
fake.defaultBackendSRTArgsForCall = append(fake.defaultBackendSRTArgsForCall, struct {
@ -567,19 +567,19 @@ func (fake *FakeEnvironment) DefaultBackendSRT() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) DefaultBackendSRTCallCount() int {
func (fake *FakeProxyEnvironment) DefaultBackendSRTCallCount() int {
fake.defaultBackendSRTMutex.RLock()
defer fake.defaultBackendSRTMutex.RUnlock()
return len(fake.defaultBackendSRTArgsForCall)
}
func (fake *FakeEnvironment) DefaultBackendSRTCalls(stub func() string) {
func (fake *FakeProxyEnvironment) DefaultBackendSRTCalls(stub func() string) {
fake.defaultBackendSRTMutex.Lock()
defer fake.defaultBackendSRTMutex.Unlock()
fake.DefaultBackendSRTStub = stub
}
func (fake *FakeEnvironment) DefaultBackendSRTReturns(result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendSRTReturns(result1 string) {
fake.defaultBackendSRTMutex.Lock()
defer fake.defaultBackendSRTMutex.Unlock()
fake.DefaultBackendSRTStub = nil
@ -588,7 +588,7 @@ func (fake *FakeEnvironment) DefaultBackendSRTReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) DefaultBackendSRTReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) DefaultBackendSRTReturnsOnCall(i int, result1 string) {
fake.defaultBackendSRTMutex.Lock()
defer fake.defaultBackendSRTMutex.Unlock()
fake.DefaultBackendSRTStub = nil
@ -602,7 +602,7 @@ func (fake *FakeEnvironment) DefaultBackendSRTReturnsOnCall(i int, result1 strin
}{result1}
}
func (fake *FakeEnvironment) ForceQuitTimeout() string {
func (fake *FakeProxyEnvironment) ForceQuitTimeout() string {
fake.forceQuitTimeoutMutex.Lock()
ret, specificReturn := fake.forceQuitTimeoutReturnsOnCall[len(fake.forceQuitTimeoutArgsForCall)]
fake.forceQuitTimeoutArgsForCall = append(fake.forceQuitTimeoutArgsForCall, struct {
@ -620,19 +620,19 @@ func (fake *FakeEnvironment) ForceQuitTimeout() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) ForceQuitTimeoutCallCount() int {
func (fake *FakeProxyEnvironment) ForceQuitTimeoutCallCount() int {
fake.forceQuitTimeoutMutex.RLock()
defer fake.forceQuitTimeoutMutex.RUnlock()
return len(fake.forceQuitTimeoutArgsForCall)
}
func (fake *FakeEnvironment) ForceQuitTimeoutCalls(stub func() string) {
func (fake *FakeProxyEnvironment) ForceQuitTimeoutCalls(stub func() string) {
fake.forceQuitTimeoutMutex.Lock()
defer fake.forceQuitTimeoutMutex.Unlock()
fake.ForceQuitTimeoutStub = stub
}
func (fake *FakeEnvironment) ForceQuitTimeoutReturns(result1 string) {
func (fake *FakeProxyEnvironment) ForceQuitTimeoutReturns(result1 string) {
fake.forceQuitTimeoutMutex.Lock()
defer fake.forceQuitTimeoutMutex.Unlock()
fake.ForceQuitTimeoutStub = nil
@ -641,7 +641,7 @@ func (fake *FakeEnvironment) ForceQuitTimeoutReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) ForceQuitTimeoutReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) ForceQuitTimeoutReturnsOnCall(i int, result1 string) {
fake.forceQuitTimeoutMutex.Lock()
defer fake.forceQuitTimeoutMutex.Unlock()
fake.ForceQuitTimeoutStub = nil
@ -655,7 +655,7 @@ func (fake *FakeEnvironment) ForceQuitTimeoutReturnsOnCall(i int, result1 string
}{result1}
}
func (fake *FakeEnvironment) GoPprof() string {
func (fake *FakeProxyEnvironment) GoPprof() string {
fake.goPprofMutex.Lock()
ret, specificReturn := fake.goPprofReturnsOnCall[len(fake.goPprofArgsForCall)]
fake.goPprofArgsForCall = append(fake.goPprofArgsForCall, struct {
@ -673,19 +673,19 @@ func (fake *FakeEnvironment) GoPprof() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) GoPprofCallCount() int {
func (fake *FakeProxyEnvironment) GoPprofCallCount() int {
fake.goPprofMutex.RLock()
defer fake.goPprofMutex.RUnlock()
return len(fake.goPprofArgsForCall)
}
func (fake *FakeEnvironment) GoPprofCalls(stub func() string) {
func (fake *FakeProxyEnvironment) GoPprofCalls(stub func() string) {
fake.goPprofMutex.Lock()
defer fake.goPprofMutex.Unlock()
fake.GoPprofStub = stub
}
func (fake *FakeEnvironment) GoPprofReturns(result1 string) {
func (fake *FakeProxyEnvironment) GoPprofReturns(result1 string) {
fake.goPprofMutex.Lock()
defer fake.goPprofMutex.Unlock()
fake.GoPprofStub = nil
@ -694,7 +694,7 @@ func (fake *FakeEnvironment) GoPprofReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) GoPprofReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) GoPprofReturnsOnCall(i int, result1 string) {
fake.goPprofMutex.Lock()
defer fake.goPprofMutex.Unlock()
fake.GoPprofStub = nil
@ -708,7 +708,7 @@ func (fake *FakeEnvironment) GoPprofReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) GraceQuitTimeout() string {
func (fake *FakeProxyEnvironment) GraceQuitTimeout() string {
fake.graceQuitTimeoutMutex.Lock()
ret, specificReturn := fake.graceQuitTimeoutReturnsOnCall[len(fake.graceQuitTimeoutArgsForCall)]
fake.graceQuitTimeoutArgsForCall = append(fake.graceQuitTimeoutArgsForCall, struct {
@ -726,19 +726,19 @@ func (fake *FakeEnvironment) GraceQuitTimeout() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) GraceQuitTimeoutCallCount() int {
func (fake *FakeProxyEnvironment) GraceQuitTimeoutCallCount() int {
fake.graceQuitTimeoutMutex.RLock()
defer fake.graceQuitTimeoutMutex.RUnlock()
return len(fake.graceQuitTimeoutArgsForCall)
}
func (fake *FakeEnvironment) GraceQuitTimeoutCalls(stub func() string) {
func (fake *FakeProxyEnvironment) GraceQuitTimeoutCalls(stub func() string) {
fake.graceQuitTimeoutMutex.Lock()
defer fake.graceQuitTimeoutMutex.Unlock()
fake.GraceQuitTimeoutStub = stub
}
func (fake *FakeEnvironment) GraceQuitTimeoutReturns(result1 string) {
func (fake *FakeProxyEnvironment) GraceQuitTimeoutReturns(result1 string) {
fake.graceQuitTimeoutMutex.Lock()
defer fake.graceQuitTimeoutMutex.Unlock()
fake.GraceQuitTimeoutStub = nil
@ -747,7 +747,7 @@ func (fake *FakeEnvironment) GraceQuitTimeoutReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) GraceQuitTimeoutReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) GraceQuitTimeoutReturnsOnCall(i int, result1 string) {
fake.graceQuitTimeoutMutex.Lock()
defer fake.graceQuitTimeoutMutex.Unlock()
fake.GraceQuitTimeoutStub = nil
@ -761,7 +761,7 @@ func (fake *FakeEnvironment) GraceQuitTimeoutReturnsOnCall(i int, result1 string
}{result1}
}
func (fake *FakeEnvironment) HttpAPI() string {
func (fake *FakeProxyEnvironment) HttpAPI() string {
fake.httpAPIMutex.Lock()
ret, specificReturn := fake.httpAPIReturnsOnCall[len(fake.httpAPIArgsForCall)]
fake.httpAPIArgsForCall = append(fake.httpAPIArgsForCall, struct {
@ -779,19 +779,19 @@ func (fake *FakeEnvironment) HttpAPI() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) HttpAPICallCount() int {
func (fake *FakeProxyEnvironment) HttpAPICallCount() int {
fake.httpAPIMutex.RLock()
defer fake.httpAPIMutex.RUnlock()
return len(fake.httpAPIArgsForCall)
}
func (fake *FakeEnvironment) HttpAPICalls(stub func() string) {
func (fake *FakeProxyEnvironment) HttpAPICalls(stub func() string) {
fake.httpAPIMutex.Lock()
defer fake.httpAPIMutex.Unlock()
fake.HttpAPIStub = stub
}
func (fake *FakeEnvironment) HttpAPIReturns(result1 string) {
func (fake *FakeProxyEnvironment) HttpAPIReturns(result1 string) {
fake.httpAPIMutex.Lock()
defer fake.httpAPIMutex.Unlock()
fake.HttpAPIStub = nil
@ -800,7 +800,7 @@ func (fake *FakeEnvironment) HttpAPIReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) HttpAPIReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) HttpAPIReturnsOnCall(i int, result1 string) {
fake.httpAPIMutex.Lock()
defer fake.httpAPIMutex.Unlock()
fake.HttpAPIStub = nil
@ -814,7 +814,7 @@ func (fake *FakeEnvironment) HttpAPIReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) HttpServer() string {
func (fake *FakeProxyEnvironment) HttpServer() string {
fake.httpServerMutex.Lock()
ret, specificReturn := fake.httpServerReturnsOnCall[len(fake.httpServerArgsForCall)]
fake.httpServerArgsForCall = append(fake.httpServerArgsForCall, struct {
@ -832,19 +832,19 @@ func (fake *FakeEnvironment) HttpServer() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) HttpServerCallCount() int {
func (fake *FakeProxyEnvironment) HttpServerCallCount() int {
fake.httpServerMutex.RLock()
defer fake.httpServerMutex.RUnlock()
return len(fake.httpServerArgsForCall)
}
func (fake *FakeEnvironment) HttpServerCalls(stub func() string) {
func (fake *FakeProxyEnvironment) HttpServerCalls(stub func() string) {
fake.httpServerMutex.Lock()
defer fake.httpServerMutex.Unlock()
fake.HttpServerStub = stub
}
func (fake *FakeEnvironment) HttpServerReturns(result1 string) {
func (fake *FakeProxyEnvironment) HttpServerReturns(result1 string) {
fake.httpServerMutex.Lock()
defer fake.httpServerMutex.Unlock()
fake.HttpServerStub = nil
@ -853,7 +853,7 @@ func (fake *FakeEnvironment) HttpServerReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) HttpServerReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) HttpServerReturnsOnCall(i int, result1 string) {
fake.httpServerMutex.Lock()
defer fake.httpServerMutex.Unlock()
fake.HttpServerStub = nil
@ -867,7 +867,7 @@ func (fake *FakeEnvironment) HttpServerReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) LoadBalancerType() string {
func (fake *FakeProxyEnvironment) LoadBalancerType() string {
fake.loadBalancerTypeMutex.Lock()
ret, specificReturn := fake.loadBalancerTypeReturnsOnCall[len(fake.loadBalancerTypeArgsForCall)]
fake.loadBalancerTypeArgsForCall = append(fake.loadBalancerTypeArgsForCall, struct {
@ -885,19 +885,19 @@ func (fake *FakeEnvironment) LoadBalancerType() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) LoadBalancerTypeCallCount() int {
func (fake *FakeProxyEnvironment) LoadBalancerTypeCallCount() int {
fake.loadBalancerTypeMutex.RLock()
defer fake.loadBalancerTypeMutex.RUnlock()
return len(fake.loadBalancerTypeArgsForCall)
}
func (fake *FakeEnvironment) LoadBalancerTypeCalls(stub func() string) {
func (fake *FakeProxyEnvironment) LoadBalancerTypeCalls(stub func() string) {
fake.loadBalancerTypeMutex.Lock()
defer fake.loadBalancerTypeMutex.Unlock()
fake.LoadBalancerTypeStub = stub
}
func (fake *FakeEnvironment) LoadBalancerTypeReturns(result1 string) {
func (fake *FakeProxyEnvironment) LoadBalancerTypeReturns(result1 string) {
fake.loadBalancerTypeMutex.Lock()
defer fake.loadBalancerTypeMutex.Unlock()
fake.LoadBalancerTypeStub = nil
@ -906,7 +906,7 @@ func (fake *FakeEnvironment) LoadBalancerTypeReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) LoadBalancerTypeReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) LoadBalancerTypeReturnsOnCall(i int, result1 string) {
fake.loadBalancerTypeMutex.Lock()
defer fake.loadBalancerTypeMutex.Unlock()
fake.LoadBalancerTypeStub = nil
@ -920,7 +920,7 @@ func (fake *FakeEnvironment) LoadBalancerTypeReturnsOnCall(i int, result1 string
}{result1}
}
func (fake *FakeEnvironment) RedisDB() string {
func (fake *FakeProxyEnvironment) RedisDB() string {
fake.redisDBMutex.Lock()
ret, specificReturn := fake.redisDBReturnsOnCall[len(fake.redisDBArgsForCall)]
fake.redisDBArgsForCall = append(fake.redisDBArgsForCall, struct {
@ -938,19 +938,19 @@ func (fake *FakeEnvironment) RedisDB() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) RedisDBCallCount() int {
func (fake *FakeProxyEnvironment) RedisDBCallCount() int {
fake.redisDBMutex.RLock()
defer fake.redisDBMutex.RUnlock()
return len(fake.redisDBArgsForCall)
}
func (fake *FakeEnvironment) RedisDBCalls(stub func() string) {
func (fake *FakeProxyEnvironment) RedisDBCalls(stub func() string) {
fake.redisDBMutex.Lock()
defer fake.redisDBMutex.Unlock()
fake.RedisDBStub = stub
}
func (fake *FakeEnvironment) RedisDBReturns(result1 string) {
func (fake *FakeProxyEnvironment) RedisDBReturns(result1 string) {
fake.redisDBMutex.Lock()
defer fake.redisDBMutex.Unlock()
fake.RedisDBStub = nil
@ -959,7 +959,7 @@ func (fake *FakeEnvironment) RedisDBReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisDBReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) RedisDBReturnsOnCall(i int, result1 string) {
fake.redisDBMutex.Lock()
defer fake.redisDBMutex.Unlock()
fake.RedisDBStub = nil
@ -973,7 +973,7 @@ func (fake *FakeEnvironment) RedisDBReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisHost() string {
func (fake *FakeProxyEnvironment) RedisHost() string {
fake.redisHostMutex.Lock()
ret, specificReturn := fake.redisHostReturnsOnCall[len(fake.redisHostArgsForCall)]
fake.redisHostArgsForCall = append(fake.redisHostArgsForCall, struct {
@ -991,19 +991,19 @@ func (fake *FakeEnvironment) RedisHost() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) RedisHostCallCount() int {
func (fake *FakeProxyEnvironment) RedisHostCallCount() int {
fake.redisHostMutex.RLock()
defer fake.redisHostMutex.RUnlock()
return len(fake.redisHostArgsForCall)
}
func (fake *FakeEnvironment) RedisHostCalls(stub func() string) {
func (fake *FakeProxyEnvironment) RedisHostCalls(stub func() string) {
fake.redisHostMutex.Lock()
defer fake.redisHostMutex.Unlock()
fake.RedisHostStub = stub
}
func (fake *FakeEnvironment) RedisHostReturns(result1 string) {
func (fake *FakeProxyEnvironment) RedisHostReturns(result1 string) {
fake.redisHostMutex.Lock()
defer fake.redisHostMutex.Unlock()
fake.RedisHostStub = nil
@ -1012,7 +1012,7 @@ func (fake *FakeEnvironment) RedisHostReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisHostReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) RedisHostReturnsOnCall(i int, result1 string) {
fake.redisHostMutex.Lock()
defer fake.redisHostMutex.Unlock()
fake.RedisHostStub = nil
@ -1026,7 +1026,7 @@ func (fake *FakeEnvironment) RedisHostReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisPassword() string {
func (fake *FakeProxyEnvironment) RedisPassword() string {
fake.redisPasswordMutex.Lock()
ret, specificReturn := fake.redisPasswordReturnsOnCall[len(fake.redisPasswordArgsForCall)]
fake.redisPasswordArgsForCall = append(fake.redisPasswordArgsForCall, struct {
@ -1044,19 +1044,19 @@ func (fake *FakeEnvironment) RedisPassword() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) RedisPasswordCallCount() int {
func (fake *FakeProxyEnvironment) RedisPasswordCallCount() int {
fake.redisPasswordMutex.RLock()
defer fake.redisPasswordMutex.RUnlock()
return len(fake.redisPasswordArgsForCall)
}
func (fake *FakeEnvironment) RedisPasswordCalls(stub func() string) {
func (fake *FakeProxyEnvironment) RedisPasswordCalls(stub func() string) {
fake.redisPasswordMutex.Lock()
defer fake.redisPasswordMutex.Unlock()
fake.RedisPasswordStub = stub
}
func (fake *FakeEnvironment) RedisPasswordReturns(result1 string) {
func (fake *FakeProxyEnvironment) RedisPasswordReturns(result1 string) {
fake.redisPasswordMutex.Lock()
defer fake.redisPasswordMutex.Unlock()
fake.RedisPasswordStub = nil
@ -1065,7 +1065,7 @@ func (fake *FakeEnvironment) RedisPasswordReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisPasswordReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) RedisPasswordReturnsOnCall(i int, result1 string) {
fake.redisPasswordMutex.Lock()
defer fake.redisPasswordMutex.Unlock()
fake.RedisPasswordStub = nil
@ -1079,7 +1079,7 @@ func (fake *FakeEnvironment) RedisPasswordReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisPort() string {
func (fake *FakeProxyEnvironment) RedisPort() string {
fake.redisPortMutex.Lock()
ret, specificReturn := fake.redisPortReturnsOnCall[len(fake.redisPortArgsForCall)]
fake.redisPortArgsForCall = append(fake.redisPortArgsForCall, struct {
@ -1097,19 +1097,19 @@ func (fake *FakeEnvironment) RedisPort() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) RedisPortCallCount() int {
func (fake *FakeProxyEnvironment) RedisPortCallCount() int {
fake.redisPortMutex.RLock()
defer fake.redisPortMutex.RUnlock()
return len(fake.redisPortArgsForCall)
}
func (fake *FakeEnvironment) RedisPortCalls(stub func() string) {
func (fake *FakeProxyEnvironment) RedisPortCalls(stub func() string) {
fake.redisPortMutex.Lock()
defer fake.redisPortMutex.Unlock()
fake.RedisPortStub = stub
}
func (fake *FakeEnvironment) RedisPortReturns(result1 string) {
func (fake *FakeProxyEnvironment) RedisPortReturns(result1 string) {
fake.redisPortMutex.Lock()
defer fake.redisPortMutex.Unlock()
fake.RedisPortStub = nil
@ -1118,7 +1118,7 @@ func (fake *FakeEnvironment) RedisPortReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RedisPortReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) RedisPortReturnsOnCall(i int, result1 string) {
fake.redisPortMutex.Lock()
defer fake.redisPortMutex.Unlock()
fake.RedisPortStub = nil
@ -1132,7 +1132,7 @@ func (fake *FakeEnvironment) RedisPortReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RtmpServer() string {
func (fake *FakeProxyEnvironment) RtmpServer() string {
fake.rtmpServerMutex.Lock()
ret, specificReturn := fake.rtmpServerReturnsOnCall[len(fake.rtmpServerArgsForCall)]
fake.rtmpServerArgsForCall = append(fake.rtmpServerArgsForCall, struct {
@ -1150,19 +1150,19 @@ func (fake *FakeEnvironment) RtmpServer() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) RtmpServerCallCount() int {
func (fake *FakeProxyEnvironment) RtmpServerCallCount() int {
fake.rtmpServerMutex.RLock()
defer fake.rtmpServerMutex.RUnlock()
return len(fake.rtmpServerArgsForCall)
}
func (fake *FakeEnvironment) RtmpServerCalls(stub func() string) {
func (fake *FakeProxyEnvironment) RtmpServerCalls(stub func() string) {
fake.rtmpServerMutex.Lock()
defer fake.rtmpServerMutex.Unlock()
fake.RtmpServerStub = stub
}
func (fake *FakeEnvironment) RtmpServerReturns(result1 string) {
func (fake *FakeProxyEnvironment) RtmpServerReturns(result1 string) {
fake.rtmpServerMutex.Lock()
defer fake.rtmpServerMutex.Unlock()
fake.RtmpServerStub = nil
@ -1171,7 +1171,7 @@ func (fake *FakeEnvironment) RtmpServerReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) RtmpServerReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) RtmpServerReturnsOnCall(i int, result1 string) {
fake.rtmpServerMutex.Lock()
defer fake.rtmpServerMutex.Unlock()
fake.RtmpServerStub = nil
@ -1185,7 +1185,7 @@ func (fake *FakeEnvironment) RtmpServerReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) SRTServer() string {
func (fake *FakeProxyEnvironment) SRTServer() string {
fake.sRTServerMutex.Lock()
ret, specificReturn := fake.sRTServerReturnsOnCall[len(fake.sRTServerArgsForCall)]
fake.sRTServerArgsForCall = append(fake.sRTServerArgsForCall, struct {
@ -1203,19 +1203,19 @@ func (fake *FakeEnvironment) SRTServer() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) SRTServerCallCount() int {
func (fake *FakeProxyEnvironment) SRTServerCallCount() int {
fake.sRTServerMutex.RLock()
defer fake.sRTServerMutex.RUnlock()
return len(fake.sRTServerArgsForCall)
}
func (fake *FakeEnvironment) SRTServerCalls(stub func() string) {
func (fake *FakeProxyEnvironment) SRTServerCalls(stub func() string) {
fake.sRTServerMutex.Lock()
defer fake.sRTServerMutex.Unlock()
fake.SRTServerStub = stub
}
func (fake *FakeEnvironment) SRTServerReturns(result1 string) {
func (fake *FakeProxyEnvironment) SRTServerReturns(result1 string) {
fake.sRTServerMutex.Lock()
defer fake.sRTServerMutex.Unlock()
fake.SRTServerStub = nil
@ -1224,7 +1224,7 @@ func (fake *FakeEnvironment) SRTServerReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) SRTServerReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) SRTServerReturnsOnCall(i int, result1 string) {
fake.sRTServerMutex.Lock()
defer fake.sRTServerMutex.Unlock()
fake.SRTServerStub = nil
@ -1238,7 +1238,7 @@ func (fake *FakeEnvironment) SRTServerReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) StaticFiles() string {
func (fake *FakeProxyEnvironment) StaticFiles() string {
fake.staticFilesMutex.Lock()
ret, specificReturn := fake.staticFilesReturnsOnCall[len(fake.staticFilesArgsForCall)]
fake.staticFilesArgsForCall = append(fake.staticFilesArgsForCall, struct {
@ -1256,19 +1256,19 @@ func (fake *FakeEnvironment) StaticFiles() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) StaticFilesCallCount() int {
func (fake *FakeProxyEnvironment) StaticFilesCallCount() int {
fake.staticFilesMutex.RLock()
defer fake.staticFilesMutex.RUnlock()
return len(fake.staticFilesArgsForCall)
}
func (fake *FakeEnvironment) StaticFilesCalls(stub func() string) {
func (fake *FakeProxyEnvironment) StaticFilesCalls(stub func() string) {
fake.staticFilesMutex.Lock()
defer fake.staticFilesMutex.Unlock()
fake.StaticFilesStub = stub
}
func (fake *FakeEnvironment) StaticFilesReturns(result1 string) {
func (fake *FakeProxyEnvironment) StaticFilesReturns(result1 string) {
fake.staticFilesMutex.Lock()
defer fake.staticFilesMutex.Unlock()
fake.StaticFilesStub = nil
@ -1277,7 +1277,7 @@ func (fake *FakeEnvironment) StaticFilesReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) StaticFilesReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) StaticFilesReturnsOnCall(i int, result1 string) {
fake.staticFilesMutex.Lock()
defer fake.staticFilesMutex.Unlock()
fake.StaticFilesStub = nil
@ -1291,7 +1291,7 @@ func (fake *FakeEnvironment) StaticFilesReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) SystemAPI() string {
func (fake *FakeProxyEnvironment) SystemAPI() string {
fake.systemAPIMutex.Lock()
ret, specificReturn := fake.systemAPIReturnsOnCall[len(fake.systemAPIArgsForCall)]
fake.systemAPIArgsForCall = append(fake.systemAPIArgsForCall, struct {
@ -1309,19 +1309,19 @@ func (fake *FakeEnvironment) SystemAPI() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) SystemAPICallCount() int {
func (fake *FakeProxyEnvironment) SystemAPICallCount() int {
fake.systemAPIMutex.RLock()
defer fake.systemAPIMutex.RUnlock()
return len(fake.systemAPIArgsForCall)
}
func (fake *FakeEnvironment) SystemAPICalls(stub func() string) {
func (fake *FakeProxyEnvironment) SystemAPICalls(stub func() string) {
fake.systemAPIMutex.Lock()
defer fake.systemAPIMutex.Unlock()
fake.SystemAPIStub = stub
}
func (fake *FakeEnvironment) SystemAPIReturns(result1 string) {
func (fake *FakeProxyEnvironment) SystemAPIReturns(result1 string) {
fake.systemAPIMutex.Lock()
defer fake.systemAPIMutex.Unlock()
fake.SystemAPIStub = nil
@ -1330,7 +1330,7 @@ func (fake *FakeEnvironment) SystemAPIReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) SystemAPIReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) SystemAPIReturnsOnCall(i int, result1 string) {
fake.systemAPIMutex.Lock()
defer fake.systemAPIMutex.Unlock()
fake.SystemAPIStub = nil
@ -1344,7 +1344,7 @@ func (fake *FakeEnvironment) SystemAPIReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) WebRTCServer() string {
func (fake *FakeProxyEnvironment) WebRTCServer() string {
fake.webRTCServerMutex.Lock()
ret, specificReturn := fake.webRTCServerReturnsOnCall[len(fake.webRTCServerArgsForCall)]
fake.webRTCServerArgsForCall = append(fake.webRTCServerArgsForCall, struct {
@ -1362,19 +1362,19 @@ func (fake *FakeEnvironment) WebRTCServer() string {
return fakeReturns.result1
}
func (fake *FakeEnvironment) WebRTCServerCallCount() int {
func (fake *FakeProxyEnvironment) WebRTCServerCallCount() int {
fake.webRTCServerMutex.RLock()
defer fake.webRTCServerMutex.RUnlock()
return len(fake.webRTCServerArgsForCall)
}
func (fake *FakeEnvironment) WebRTCServerCalls(stub func() string) {
func (fake *FakeProxyEnvironment) WebRTCServerCalls(stub func() string) {
fake.webRTCServerMutex.Lock()
defer fake.webRTCServerMutex.Unlock()
fake.WebRTCServerStub = stub
}
func (fake *FakeEnvironment) WebRTCServerReturns(result1 string) {
func (fake *FakeProxyEnvironment) WebRTCServerReturns(result1 string) {
fake.webRTCServerMutex.Lock()
defer fake.webRTCServerMutex.Unlock()
fake.WebRTCServerStub = nil
@ -1383,7 +1383,7 @@ func (fake *FakeEnvironment) WebRTCServerReturns(result1 string) {
}{result1}
}
func (fake *FakeEnvironment) WebRTCServerReturnsOnCall(i int, result1 string) {
func (fake *FakeProxyEnvironment) WebRTCServerReturnsOnCall(i int, result1 string) {
fake.webRTCServerMutex.Lock()
defer fake.webRTCServerMutex.Unlock()
fake.WebRTCServerStub = nil
@ -1397,7 +1397,7 @@ func (fake *FakeEnvironment) WebRTCServerReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *FakeEnvironment) Invocations() map[string][][]interface{} {
func (fake *FakeProxyEnvironment) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
@ -1407,7 +1407,7 @@ func (fake *FakeEnvironment) Invocations() map[string][][]interface{} {
return copiedInvocations
}
func (fake *FakeEnvironment) recordInvocation(key string, args []interface{}) {
func (fake *FakeProxyEnvironment) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
@ -1419,4 +1419,4 @@ func (fake *FakeEnvironment) recordInvocation(key string, args []interface{}) {
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ env.Environment = new(FakeEnvironment)
var _ env.ProxyEnvironment = new(FakeProxyEnvironment)

2
internal/env/gen.go vendored
View File

@ -3,4 +3,4 @@
// SPDX-License-Identifier: MIT
package env
//go:generate go tool counterfeiter -o envfakes/fake_environment.go . Environment
//go:generate go tool counterfeiter -o envfakes/fake_proxy_environment.go . ProxyEnvironment

View File

@ -13,7 +13,7 @@ import (
)
// NewDefaultSRSForDebugging initialize the default SRS media server, for debugging only.
func NewDefaultSRSForDebugging(environment env.Environment) (*SRSServer, error) {
func NewDefaultSRSForDebugging(environment env.ProxyEnvironment) (*SRSServer, error) {
if environment.DefaultBackendEnabled() != "on" {
return nil, nil
}

View File

@ -18,7 +18,7 @@ import (
// MemoryLoadBalancer stores state in memory.
type MemoryLoadBalancer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// All available SRS servers, key is server ID.
servers sync.Map[string, *SRSServer]
// The picked server to service client by specified stream URL, key is stream url.
@ -34,7 +34,7 @@ type MemoryLoadBalancer struct {
}
// NewMemoryLoadBalancer creates a new memory-based load balancer.
func NewMemoryLoadBalancer(environment env.Environment) SRSLoadBalancer {
func NewMemoryLoadBalancer(environment env.ProxyEnvironment) SRSLoadBalancer {
return &MemoryLoadBalancer{
environment: environment,
servers: sync.NewMap[string, *SRSServer](),
@ -65,12 +65,12 @@ func (v *MemoryLoadBalancer) Initialize(ctx context.Context) error {
return
case <-time.After(30 * time.Second):
if err := v.Update(ctx, server); err != nil {
logger.Wf(ctx, "update default SRS %+v failed, %+v", server, err)
logger.Warn(ctx, "update default SRS %+v failed, %+v", server, err)
}
}
}
}()
logger.Df(ctx, "MemoryLB: Initialize default SRS media server, %+v", server)
logger.Debug(ctx, "MemoryLB: Initialize default SRS media server, %+v", server)
}
return nil
}

View File

@ -22,13 +22,13 @@ import (
// RedisLoadBalancer stores state in Redis.
type RedisLoadBalancer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The redis client sdk.
rdb *redis.Client
}
// NewRedisLoadBalancer creates a new Redis-based load balancer.
func NewRedisLoadBalancer(environment env.Environment) SRSLoadBalancer {
func NewRedisLoadBalancer(environment env.ProxyEnvironment) SRSLoadBalancer {
return &RedisLoadBalancer{
environment: environment,
}
@ -50,7 +50,7 @@ func (v *RedisLoadBalancer) Initialize(ctx context.Context) error {
if err := rdb.Ping(ctx).Err(); err != nil {
return errors.Wrapf(err, "unable to connect to redis %v", rdb.String())
}
logger.Df(ctx, "RedisLB: connected to redis %v ok", rdb.String())
logger.Debug(ctx, "RedisLB: connected to redis %v ok", rdb.String())
server, err := NewDefaultSRSForDebugging(v.environment)
if err != nil {
@ -70,12 +70,12 @@ func (v *RedisLoadBalancer) Initialize(ctx context.Context) error {
return
case <-time.After(30 * time.Second):
if err := v.Update(ctx, server); err != nil {
logger.Wf(ctx, "update default SRS %+v failed, %+v", server, err)
logger.Warn(ctx, "update default SRS %+v failed, %+v", server, err)
}
}
}
}()
logger.Df(ctx, "RedisLB: Initialize default SRS media server, %+v", server)
logger.Debug(ctx, "RedisLB: Initialize default SRS media server, %+v", server)
}
return nil
}

View File

@ -9,10 +9,13 @@ import (
"io"
"log/slog"
"os"
"strings"
"srsx/internal/version"
)
type logger interface {
Printf(ctx context.Context, format string, v ...any)
Log(ctx context.Context, msg string, args ...any)
}
type loggerPlus struct {
@ -28,95 +31,73 @@ func newLoggerPlus(opts ...func(*loggerPlus)) *loggerPlus {
return v
}
func (v *loggerPlus) Printf(ctx context.Context, f string, a ...any) {
attrs := []slog.Attr{slog.Int("pid", os.Getpid())}
if cid := ContextID(ctx); cid != "" {
attrs = append(attrs, slog.String("cid", cid))
func (v *loggerPlus) Log(ctx context.Context, msg string, args ...any) {
attrs := []any{
"pid", os.Getpid(),
"version", version.Version(),
}
v.logger.LogAttrs(ctx, v.level, fmt.Sprintf(f, a...), attrs...)
}
var verboseLogger logger
if cid := ContextID(ctx); cid != "" {
attrs = append(attrs, "cid", cid)
}
func Vf(ctx context.Context, format string, a ...any) {
verboseLogger.Printf(ctx, format, a...)
// Keep compatibility with the old *f call sites while exposing the new
// slog-style API. New code should pass structured key/value args.
if len(args) > 0 && strings.Contains(msg, "%") {
msg = fmt.Sprintf(msg, args...)
args = nil
}
attrs = append(attrs, args...)
v.logger.Log(ctx, v.level, msg, attrs...)
}
var debugLogger logger
func Df(ctx context.Context, format string, a ...any) {
debugLogger.Printf(ctx, format, a...)
func Debug(ctx context.Context, msg string, args ...any) {
debugLogger.Log(ctx, msg, args...)
}
var infoLogger logger
func Info(ctx context.Context, msg string, args ...any) {
infoLogger.Log(ctx, msg, args...)
}
var warnLogger logger
func Wf(ctx context.Context, format string, a ...any) {
warnLogger.Printf(ctx, format, a...)
func Warn(ctx context.Context, msg string, args ...any) {
warnLogger.Log(ctx, msg, args...)
}
var errorLogger logger
func Ef(ctx context.Context, format string, a ...any) {
errorLogger.Printf(ctx, format, a...)
func Error(ctx context.Context, msg string, args ...any) {
errorLogger.Log(ctx, msg, args...)
}
const (
levelVerb slog.Level = slog.LevelDebug - 4
levelDebug slog.Level = slog.LevelDebug
levelWarn slog.Level = slog.LevelWarn
levelError slog.Level = slog.LevelError
)
// newJSONLogger builds a slog.Logger that writes JSON records to w, renders the
// time in UTC, and maps our custom levels to short lowercase labels.
// newJSONLogger builds a slog.Logger that writes JSON records to w.
func newJSONLogger(w io.Writer) *slog.Logger {
h := slog.NewJSONHandler(w, &slog.HandlerOptions{
Level: levelVerb,
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
if len(groups) != 0 {
return a
}
switch a.Key {
case slog.TimeKey:
return slog.Time(slog.TimeKey, a.Value.Time().UTC())
case slog.LevelKey:
return slog.String(slog.LevelKey, levelLabel(a.Value.Any().(slog.Level)))
}
return a
},
Level: slog.LevelDebug,
})
return slog.New(h)
}
func levelLabel(l slog.Level) string {
switch l {
case levelVerb:
return "verb"
case levelDebug:
return "debug"
case levelWarn:
return "warn"
case levelError:
return "error"
}
return l.String()
}
func init() {
verboseLogger = newLoggerPlus(func(l *loggerPlus) {
l.logger = newJSONLogger(io.Discard)
l.level = levelVerb
})
debugLogger = newLoggerPlus(func(l *loggerPlus) {
l.logger = newJSONLogger(os.Stdout)
l.level = levelDebug
l.level = slog.LevelDebug
})
infoLogger = newLoggerPlus(func(l *loggerPlus) {
l.logger = newJSONLogger(os.Stdout)
l.level = slog.LevelInfo
})
warnLogger = newLoggerPlus(func(l *loggerPlus) {
l.logger = newJSONLogger(os.Stderr)
l.level = levelWarn
l.level = slog.LevelWarn
})
errorLogger = newLoggerPlus(func(l *loggerPlus) {
l.logger = newJSONLogger(os.Stderr)
l.level = levelError
l.level = slog.LevelError
})
}

View File

@ -10,7 +10,6 @@ import (
"io"
"log/slog"
"os"
"strings"
"testing"
"time"
)
@ -31,39 +30,15 @@ func bufLoggerPlus(w io.Writer, level slog.Level) *loggerPlus {
})
}
func TestLevelLabel_Known(t *testing.T) {
cases := map[slog.Level]string{
levelVerb: "verb",
levelDebug: "debug",
levelWarn: "warn",
levelError: "error",
}
for lvl, want := range cases {
if got := levelLabel(lvl); got != want {
t.Errorf("levelLabel(%v) = %q, want %q", lvl, got, want)
}
}
}
func TestLevelLabel_UnknownFallsBackToString(t *testing.T) {
got := levelLabel(slog.Level(99))
if got == "" {
t.Fatalf("levelLabel(99) returned empty")
}
if got == "verb" || got == "debug" || got == "warn" || got == "error" {
t.Fatalf("levelLabel(99) = %q, want slog.Level.String() form", got)
}
}
func TestPrintf_EmitsAllFields(t *testing.T) {
func TestLog_EmitsAllFields(t *testing.T) {
var buf bytes.Buffer
lp := bufLoggerPlus(&buf, levelDebug)
lp := bufLoggerPlus(&buf, slog.LevelDebug)
ctx := withContextID(context.Background(), "abc1234")
lp.Printf(ctx, "hello %s %d", "world", 42)
lp.Log(ctx, "hello %s %d", "world", 42)
m := decodeLine(t, buf.Bytes())
if m["level"] != "debug" {
t.Errorf("level = %v, want debug", m["level"])
if m["level"] != "DEBUG" {
t.Errorf("level = %v, want DEBUG", m["level"])
}
if m["msg"] != "hello world 42" {
t.Errorf("msg = %v, want %q", m["msg"], "hello world 42")
@ -76,40 +51,56 @@ func TestPrintf_EmitsAllFields(t *testing.T) {
t.Errorf("pid = %v, want %d", m["pid"], os.Getpid())
}
ts, ok := m["time"].(string)
if !ok || !strings.HasSuffix(ts, "Z") {
t.Errorf("time = %v, want UTC suffix Z", m["time"])
if !ok {
t.Fatalf("time = %v, want string", m["time"])
}
if _, err := time.Parse(time.RFC3339Nano, ts); err != nil {
t.Errorf("time %q not RFC3339Nano: %v", ts, err)
}
}
func TestPrintf_OmitsCIDWhenAbsent(t *testing.T) {
func TestLog_OmitsCIDWhenAbsent(t *testing.T) {
var buf bytes.Buffer
bufLoggerPlus(&buf, levelWarn).Printf(context.Background(), "no cid here")
bufLoggerPlus(&buf, slog.LevelWarn).Log(context.Background(), "no cid here")
m := decodeLine(t, buf.Bytes())
if v, present := m["cid"]; present {
t.Errorf("cid should be absent, got %v", v)
}
if m["level"] != "warn" {
t.Errorf("level = %v, want warn", m["level"])
if m["level"] != "WARN" {
t.Errorf("level = %v, want WARN", m["level"])
}
}
func TestPrintf_AllLevelsMapToLabel(t *testing.T) {
func TestLog_EmitsStructuredArgs(t *testing.T) {
var buf bytes.Buffer
bufLoggerPlus(&buf, slog.LevelInfo).Log(context.Background(), "hello", "stream", "live/livestream", "retry", 2)
m := decodeLine(t, buf.Bytes())
if m["msg"] != "hello" {
t.Errorf("msg = %v, want hello", m["msg"])
}
if m["stream"] != "live/livestream" {
t.Errorf("stream = %v, want live/livestream", m["stream"])
}
if retry, ok := m["retry"].(float64); !ok || retry != 2 {
t.Errorf("retry = %v, want 2", m["retry"])
}
}
func TestLog_AllLevelsMapToLabel(t *testing.T) {
cases := []struct {
level slog.Level
label string
}{
{levelVerb, "verb"},
{levelDebug, "debug"},
{levelWarn, "warn"},
{levelError, "error"},
{slog.LevelInfo, "INFO"},
{slog.LevelDebug, "DEBUG"},
{slog.LevelWarn, "WARN"},
{slog.LevelError, "ERROR"},
}
for _, tc := range cases {
var buf bytes.Buffer
bufLoggerPlus(&buf, tc.level).Printf(context.Background(), "hi")
bufLoggerPlus(&buf, tc.level).Log(context.Background(), "hi")
m := decodeLine(t, buf.Bytes())
if m["level"] != tc.label {
t.Errorf("level(%v) rendered as %v, want %q", tc.level, m["level"], tc.label)
@ -120,7 +111,7 @@ func TestPrintf_AllLevelsMapToLabel(t *testing.T) {
func TestNewJSONLogger_GroupedAttrsPassThrough(t *testing.T) {
var buf bytes.Buffer
lg := newJSONLogger(&buf)
lg.LogAttrs(context.Background(), levelDebug, "grouped",
lg.LogAttrs(context.Background(), slog.LevelDebug, "grouped",
slog.Group("meta", slog.String("inner", "v")))
m := decodeLine(t, buf.Bytes())
@ -134,22 +125,22 @@ func TestNewJSONLogger_GroupedAttrsPassThrough(t *testing.T) {
}
func TestPackageWrappers_RouteToRightLogger(t *testing.T) {
origV, origD, origW, origE := verboseLogger, debugLogger, warnLogger, errorLogger
origI, origD, origW, origE := infoLogger, debugLogger, warnLogger, errorLogger
t.Cleanup(func() {
verboseLogger, debugLogger, warnLogger, errorLogger = origV, origD, origW, origE
infoLogger, debugLogger, warnLogger, errorLogger = origI, origD, origW, origE
})
vBuf, dBuf, wBuf, eBuf := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
verboseLogger = bufLoggerPlus(vBuf, levelVerb)
debugLogger = bufLoggerPlus(dBuf, levelDebug)
warnLogger = bufLoggerPlus(wBuf, levelWarn)
errorLogger = bufLoggerPlus(eBuf, levelError)
iBuf, dBuf, wBuf, eBuf := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
infoLogger = bufLoggerPlus(iBuf, slog.LevelInfo)
debugLogger = bufLoggerPlus(dBuf, slog.LevelDebug)
warnLogger = bufLoggerPlus(wBuf, slog.LevelWarn)
errorLogger = bufLoggerPlus(eBuf, slog.LevelError)
ctx := context.Background()
Vf(ctx, "v=%d", 1)
Df(ctx, "d=%d", 2)
Wf(ctx, "w=%d", 3)
Ef(ctx, "e=%d", 4)
Info(ctx, "v=%d", 1)
Debug(ctx, "d=%d", 2)
Warn(ctx, "w=%d", 3)
Error(ctx, "e=%d", 4)
checks := []struct {
name string
@ -157,10 +148,10 @@ func TestPackageWrappers_RouteToRightLogger(t *testing.T) {
label string
msg string
}{
{"Vf", vBuf, "verb", "v=1"},
{"Df", dBuf, "debug", "d=2"},
{"Wf", wBuf, "warn", "w=3"},
{"Ef", eBuf, "error", "e=4"},
{"Info", iBuf, "INFO", "v=1"},
{"Debug", dBuf, "DEBUG", "d=2"},
{"Warn", wBuf, "WARN", "w=3"},
{"Error", eBuf, "ERROR", "e=4"},
}
for _, c := range checks {
m := decodeLine(t, c.buf.Bytes())

View File

@ -24,7 +24,7 @@ import (
// to proxy other HTTP API of SRS like the streams and clients, etc.
type srsHTTPAPIServer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The underlayer HTTP server.
server *http.Server
// The WebRTC server.
@ -35,7 +35,7 @@ type srsHTTPAPIServer struct {
wg sync.WaitGroup
}
func NewSRSHTTPAPIServer(environment env.Environment, gracefulQuitTimeout time.Duration, rtc *srsWebRTCServer) *srsHTTPAPIServer {
func NewSRSHTTPAPIServer(environment env.ProxyEnvironment, gracefulQuitTimeout time.Duration, rtc *srsWebRTCServer) *srsHTTPAPIServer {
v := &srsHTTPAPIServer{
environment: environment,
gracefulQuitTimeout: gracefulQuitTimeout,
@ -63,7 +63,7 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
// Create server and handler.
mux := http.NewServeMux()
v.server = &http.Server{Addr: addr, Handler: mux}
logger.Df(ctx, "HTTP API server listen at %v", addr)
logger.Debug(ctx, "HTTP API server listen at %v", addr)
// Shutdown the server gracefully when quiting.
go func() {
@ -77,7 +77,7 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
}()
// The basic version handler, also can be used as health check API.
logger.Df(ctx, "Handle /api/v1/versions by %v", addr)
logger.Debug(ctx, "Handle /api/v1/versions by %v", addr)
mux.HandleFunc("/api/v1/versions", func(w http.ResponseWriter, r *http.Request) {
utils.ApiResponse(ctx, w, r, map[string]string{
"signature": version.Signature(),
@ -86,7 +86,7 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
})
// The WebRTC WHIP API handler.
logger.Df(ctx, "Handle /rtc/v1/whip/ by %v", addr)
logger.Debug(ctx, "Handle /rtc/v1/whip/ by %v", addr)
mux.HandleFunc("/rtc/v1/whip/", func(w http.ResponseWriter, r *http.Request) {
if err := v.rtc.HandleApiForWHIP(ctx, w, r); err != nil {
utils.ApiError(ctx, w, r, err)
@ -94,7 +94,7 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
})
// The WebRTC WHEP API handler.
logger.Df(ctx, "Handle /rtc/v1/whep/ by %v", addr)
logger.Debug(ctx, "Handle /rtc/v1/whep/ by %v", addr)
mux.HandleFunc("/rtc/v1/whep/", func(w http.ResponseWriter, r *http.Request) {
if err := v.rtc.HandleApiForWHEP(ctx, w, r); err != nil {
utils.ApiError(ctx, w, r, err)
@ -109,12 +109,12 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
err := v.server.ListenAndServe()
if err != nil {
if err == http.ErrServerClosed {
logger.Df(ctx, "HTTP API server done")
logger.Debug(ctx, "HTTP API server done")
} else if ctx.Err() != nil {
logger.Df(ctx, "HTTP API server done with context canceled")
logger.Debug(ctx, "HTTP API server done with context canceled")
} else {
// TODO: If HTTP API server closed unexpectedly, we should notice the main loop to quit.
logger.Wf(ctx, "HTTP API accept err %+v", err)
logger.Warn(ctx, "HTTP API accept err %+v", err)
}
}
}()
@ -127,7 +127,7 @@ func (v *srsHTTPAPIServer) Run(ctx context.Context) error {
// for Prometheus metrics.
type systemAPI struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The underlayer HTTP server.
server *http.Server
// The gracefully quit timeout, wait server to quit.
@ -136,7 +136,7 @@ type systemAPI struct {
wg sync.WaitGroup
}
func NewSystemAPI(environment env.Environment, gracefulQuitTimeout time.Duration) *systemAPI {
func NewSystemAPI(environment env.ProxyEnvironment, gracefulQuitTimeout time.Duration) *systemAPI {
v := &systemAPI{
environment: environment,
gracefulQuitTimeout: gracefulQuitTimeout,
@ -163,7 +163,7 @@ func (v *systemAPI) Run(ctx context.Context) error {
// Create server and handler.
mux := http.NewServeMux()
v.server = &http.Server{Addr: addr, Handler: mux}
logger.Df(ctx, "System API server listen at %v", addr)
logger.Debug(ctx, "System API server listen at %v", addr)
// Shutdown the server gracefully when quiting.
go func() {
@ -177,7 +177,7 @@ func (v *systemAPI) Run(ctx context.Context) error {
}()
// The basic version handler, also can be used as health check API.
logger.Df(ctx, "Handle /api/v1/versions by %v", addr)
logger.Debug(ctx, "Handle /api/v1/versions by %v", addr)
mux.HandleFunc("/api/v1/versions", func(w http.ResponseWriter, r *http.Request) {
utils.ApiResponse(ctx, w, r, map[string]string{
"signature": version.Signature(),
@ -186,7 +186,7 @@ func (v *systemAPI) Run(ctx context.Context) error {
})
// The register service for SRS media servers.
logger.Df(ctx, "Handle /api/v1/srs/register by %v", addr)
logger.Debug(ctx, "Handle /api/v1/srs/register by %v", addr)
mux.HandleFunc("/api/v1/srs/register", func(w http.ResponseWriter, r *http.Request) {
if err := func() error {
var deviceID, ip, serverID, serviceID, pid string
@ -247,7 +247,7 @@ func (v *systemAPI) Run(ctx context.Context) error {
return errors.Wrapf(err, "update SRS server %+v", server)
}
logger.Df(ctx, "Register SRS media server, %+v", server)
logger.Debug(ctx, "Register SRS media server, %+v", server)
return nil
}(); err != nil {
utils.ApiError(ctx, w, r, err)
@ -271,12 +271,12 @@ func (v *systemAPI) Run(ctx context.Context) error {
err := v.server.ListenAndServe()
if err != nil {
if err == http.ErrServerClosed {
logger.Df(ctx, "System API server done")
logger.Debug(ctx, "System API server done")
} else if ctx.Err() != nil {
logger.Df(ctx, "System API server done with context canceled")
logger.Debug(ctx, "System API server done with context canceled")
} else {
// TODO: If System API server closed unexpectedly, we should notice the main loop to quit.
logger.Wf(ctx, "System API accept err %+v", err)
logger.Warn(ctx, "System API accept err %+v", err)
}
}
}()

View File

@ -28,7 +28,7 @@ import (
// the request to the origin server.
type srsHTTPStreamServer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The underlayer HTTP server.
server *http.Server
// The gracefully quit timeout, wait server to quit.
@ -37,7 +37,7 @@ type srsHTTPStreamServer struct {
wg stdSync.WaitGroup
}
func NewSRSHTTPStreamServer(environment env.Environment, gracefulQuitTimeout time.Duration) *srsHTTPStreamServer {
func NewSRSHTTPStreamServer(environment env.ProxyEnvironment, gracefulQuitTimeout time.Duration) *srsHTTPStreamServer {
v := &srsHTTPStreamServer{
environment: environment,
gracefulQuitTimeout: gracefulQuitTimeout,
@ -64,7 +64,7 @@ func (v *srsHTTPStreamServer) Run(ctx context.Context) error {
// Create server and handler.
mux := http.NewServeMux()
v.server = &http.Server{Addr: addr, Handler: mux}
logger.Df(ctx, "HTTP Stream server listen at %v", addr)
logger.Debug(ctx, "HTTP Stream server listen at %v", addr)
// Shutdown the server gracefully when quiting.
go func() {
@ -78,7 +78,7 @@ func (v *srsHTTPStreamServer) Run(ctx context.Context) error {
}()
// The basic version handler, also can be used as health check API.
logger.Df(ctx, "Handle /api/v1/versions by %v", addr)
logger.Debug(ctx, "Handle /api/v1/versions by %v", addr)
mux.HandleFunc("/api/v1/versions", func(w http.ResponseWriter, r *http.Request) {
type Response struct {
Code int `json:"code"`
@ -108,11 +108,11 @@ func (v *srsHTTPStreamServer) Run(ctx context.Context) error {
}
staticServer = http.FileServer(http.Dir(staticFiles))
logger.Df(ctx, "Handle static files at %v", staticFiles)
logger.Debug(ctx, "Handle static files at %v", staticFiles)
}
// The default handler, for both static web server and streaming server.
logger.Df(ctx, "Handle / by %v", addr)
logger.Debug(ctx, "Handle / by %v", addr)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// For HLS streaming, we will proxy the request to the streaming server.
if strings.HasSuffix(r.URL.Path, ".m3u8") {
@ -169,12 +169,12 @@ func (v *srsHTTPStreamServer) Run(ctx context.Context) error {
err := v.server.ListenAndServe()
if err != nil {
if err == http.ErrServerClosed {
logger.Df(ctx, "HTTP Stream server done")
logger.Debug(ctx, "HTTP Stream server done")
} else if ctx.Err() != nil {
logger.Df(ctx, "HTTP Stream server done with context canceled")
logger.Debug(ctx, "HTTP Stream server done with context canceled")
} else {
// TODO: If HTTP Stream server closed unexpectedly, we should notice the main loop to quit.
logger.Wf(ctx, "HTTP Stream accept err %+v", err)
logger.Warn(ctx, "HTTP Stream accept err %+v", err)
}
}
}()
@ -208,7 +208,7 @@ func (v *HTTPFlvTsConnection) ServeHTTP(w http.ResponseWriter, r *http.Request)
if err := v.serve(ctx, w, r); err != nil {
utils.ApiError(ctx, w, r, err)
} else {
logger.Df(ctx, "HTTP client done")
logger.Debug(ctx, "HTTP client done")
}
}
@ -220,7 +220,7 @@ func (v *HTTPFlvTsConnection) serve(ctx context.Context, w http.ResponseWriter,
// Build the stream URL in vhost/app/stream schema.
unifiedURL, fullURL := utils.ConvertURLToStreamURL(r)
logger.Df(ctx, "Got HTTP client from %v for %v", r.RemoteAddr, fullURL)
logger.Debug(ctx, "Got HTTP client from %v for %v", r.RemoteAddr, fullURL)
streamURL, err := utils.BuildStreamURL(unifiedURL)
if err != nil {
@ -278,7 +278,7 @@ func (v *HTTPFlvTsConnection) serveByBackend(ctx context.Context, w http.Respons
}
}
logger.Df(ctx, "HTTP start streaming")
logger.Debug(ctx, "HTTP start streaming")
// Proxy the stream from backend to client.
if _, err := io.Copy(w, resp.Body); err != nil {
@ -332,7 +332,7 @@ func (v *HLSPlayStream) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err := v.serve(v.ctx, w, r); err != nil {
utils.ApiError(v.ctx, w, r, err)
} else {
logger.Df(v.ctx, "HLS client %v for %v with %v done",
logger.Debug(v.ctx, "HLS client %v for %v with %v done",
v.SRSProxyBackendHLSID, v.StreamURL, r.URL.Path)
}
}

View File

@ -28,7 +28,7 @@ import (
// SDP answer.
type srsWebRTCServer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The UDP listener for WebRTC server.
listener *net.UDPConn
@ -44,7 +44,7 @@ type srsWebRTCServer struct {
wg stdSync.WaitGroup
}
func NewSRSWebRTCServer(environment env.Environment, opts ...func(*srsWebRTCServer)) *srsWebRTCServer {
func NewSRSWebRTCServer(environment env.ProxyEnvironment, opts ...func(*srsWebRTCServer)) *srsWebRTCServer {
v := &srsWebRTCServer{
environment: environment,
usernames: sync.NewMap[string, *RTCConnection](),
@ -82,7 +82,7 @@ func (v *srsWebRTCServer) HandleApiForWHIP(ctx context.Context, w http.ResponseW
// Build the stream URL in vhost/app/stream schema.
unifiedURL, fullURL := utils.ConvertURLToStreamURL(r)
logger.Df(ctx, "Got WebRTC WHIP from %v with %vB offer for %v", r.RemoteAddr, len(remoteSDPOffer), fullURL)
logger.Debug(ctx, "Got WebRTC WHIP from %v with %vB offer for %v", r.RemoteAddr, len(remoteSDPOffer), fullURL)
streamURL, err := utils.BuildStreamURL(unifiedURL)
if err != nil {
@ -119,7 +119,7 @@ func (v *srsWebRTCServer) HandleApiForWHEP(ctx context.Context, w http.ResponseW
// Build the stream URL in vhost/app/stream schema.
unifiedURL, fullURL := utils.ConvertURLToStreamURL(r)
logger.Df(ctx, "Got WebRTC WHEP from %v with %vB offer for %v", r.RemoteAddr, len(remoteSDPOffer), fullURL)
logger.Debug(ctx, "Got WebRTC WHEP from %v with %vB offer for %v", r.RemoteAddr, len(remoteSDPOffer), fullURL)
streamURL, err := utils.BuildStreamURL(unifiedURL)
if err != nil {
@ -234,7 +234,7 @@ func (v *srsWebRTCServer) proxyApiToBackend(
return errors.Wrapf(err, "write local sdp answer %v", localSDPAnswer)
}
logger.Df(ctx, "Create WebRTC connection with local answer %vB with ice-ufrag=%v, ice-pwd=%vB",
logger.Debug(ctx, "Create WebRTC connection with local answer %vB with ice-ufrag=%v, ice-pwd=%vB",
len(localSDPAnswer), localICEUfrag, len(localICEPwd))
return nil
}
@ -256,7 +256,7 @@ func (v *srsWebRTCServer) Run(ctx context.Context) error {
return errors.Wrapf(err, "listen udp %v", saddr)
}
v.listener = listener
logger.Df(ctx, "WebRTC server listen at %v", saddr)
logger.Debug(ctx, "WebRTC server listen at %v", saddr)
// Consume all messages from UDP media transport.
v.wg.Add(1)
@ -269,17 +269,17 @@ func (v *srsWebRTCServer) Run(ctx context.Context) error {
if err != nil {
// If context is canceled or connection is closed, exit gracefully without logging error.
if ctx.Err() != nil || utils.IsClosedNetworkError(err) {
logger.Df(ctx, "WebRTC server done")
logger.Debug(ctx, "WebRTC server done")
return
}
// TODO: If WebRTC server closed unexpectedly, we should notice the main loop to quit.
logger.Wf(ctx, "WebRTC read from udp failed, err=%+v", err)
logger.Warn(ctx, "WebRTC read from udp failed, err=%+v", err)
time.Sleep(1 * time.Second)
continue
}
if err := v.handleClientUDP(ctx, caddr, buf[:n]); err != nil {
logger.Wf(ctx, "WebRTC handle udp %vB failed, addr=%v, err=%+v", n, caddr, err)
logger.Warn(ctx, "WebRTC handle udp %vB failed, addr=%v, err=%+v", n, caddr, err)
}
}
}()
@ -312,7 +312,7 @@ func (v *srsWebRTCServer) handleClientUDP(ctx context.Context, addr *net.UDPAddr
return errors.Wrapf(err, "load webrtc by ufrag %v", pkt.Username)
} else {
connection = s.(*RTCConnection).Initialize(ctx, v.listener)
logger.Df(ctx, "Create WebRTC connection by ufrag=%v, stream=%v", pkt.Username, connection.StreamURL)
logger.Debug(ctx, "Create WebRTC connection by ufrag=%v, stream=%v", pkt.Username, connection.StreamURL)
}
// Cache connection for fast search.
@ -418,13 +418,13 @@ func (v *RTCConnection) HandlePacket(addr *net.UDPAddr, data []byte) error {
n, _, err := v.backendUDP.ReadFromUDP(buf)
if err != nil {
// TODO: If backend server closed unexpectedly, we should notice the stream to quit.
logger.Wf(ctx, "read from backend failed, err=%v", err)
logger.Warn(ctx, "read from backend failed, err=%v", err)
break
}
if _, err = v.listenerUDP.WriteToUDP(buf[:n], v.clientUDP); err != nil {
// TODO: If backend server closed unexpectedly, we should notice the stream to quit.
logger.Wf(ctx, "write to client failed, err=%v", err)
logger.Warn(ctx, "write to client failed, err=%v", err)
break
}
}

View File

@ -25,14 +25,14 @@ import (
// not cache the stream, but just proxy the stream to backend.
type srsRTMPServer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The TCP listener for RTMP server.
listener *net.TCPListener
// The wait group for all goroutines.
wg sync.WaitGroup
}
func NewSRSRTMPServer(environment env.Environment, opts ...func(*srsRTMPServer)) *srsRTMPServer {
func NewSRSRTMPServer(environment env.ProxyEnvironment, opts ...func(*srsRTMPServer)) *srsRTMPServer {
v := &srsRTMPServer{environment: environment}
for _, opt := range opts {
opt(v)
@ -65,7 +65,7 @@ func (v *srsRTMPServer) Run(ctx context.Context) error {
return errors.Wrapf(err, "listen rtmp addr %v", addr)
}
v.listener = listener
logger.Df(ctx, "RTMP server listen at %v", addr)
logger.Debug(ctx, "RTMP server listen at %v", addr)
v.wg.Add(1)
go func() {
@ -76,10 +76,10 @@ func (v *srsRTMPServer) Run(ctx context.Context) error {
if err != nil {
// If context is canceled or connection is closed, exit gracefully without logging error.
if ctx.Err() != nil || utils.IsClosedNetworkError(err) {
logger.Df(ctx, "RTMP server done")
logger.Debug(ctx, "RTMP server done")
} else {
// TODO: If RTMP server closed unexpectedly, we should notice the main loop to quit.
logger.Wf(ctx, "RTMP server accept err %+v", err)
logger.Warn(ctx, "RTMP server accept err %+v", err)
}
return
}
@ -91,9 +91,9 @@ func (v *srsRTMPServer) Run(ctx context.Context) error {
handleErr := func(err error) {
if utils.IsPeerClosedError(err) || utils.IsClosedNetworkError(err) {
logger.Df(ctx, "RTMP connection closed")
logger.Debug(ctx, "RTMP connection closed")
} else {
logger.Wf(ctx, "RTMP serve err %+v", err)
logger.Warn(ctx, "RTMP serve err %+v", err)
}
}
@ -101,7 +101,7 @@ func (v *srsRTMPServer) Run(ctx context.Context) error {
if err := rc.serve(ctx, conn); err != nil {
handleErr(err)
} else {
logger.Df(ctx, "RTMP client done")
logger.Debug(ctx, "RTMP client done")
}
}(logger.WithContext(ctx), conn)
}
@ -128,7 +128,7 @@ func NewRTMPConnection(opts ...func(*RTMPConnection)) *RTMPConnection {
}
func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
logger.Df(ctx, "Got RTMP client from %v", conn.RemoteAddr())
logger.Debug(ctx, "Got RTMP client from %v", conn.RemoteAddr())
// If any goroutine quit, cancel another one.
parentCtx := ctx
@ -168,7 +168,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
}
client := rtmp.NewProtocol(conn)
logger.Df(ctx, "RTMP simple handshake done")
logger.Debug(ctx, "RTMP simple handshake done")
// Expect RTMP connect command with tcUrl.
var connectReq *rtmp.ConnectAppPacket
@ -209,7 +209,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
}
tcUrl := connectReq.TcUrl()
logger.Df(ctx, "RTMP connect app %v", tcUrl)
logger.Debug(ctx, "RTMP connect app %v", tcUrl)
// Expect RTMP command to identify the client, a publisher or viewer.
var currentStreamID, nextStreamID int
@ -285,7 +285,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
// Update the stream ID for next request.
currentStreamID = nextStreamID
}
logger.Df(ctx, "RTMP identify tcUrl=%v, stream=%v, id=%v, type=%v",
logger.Debug(ctx, "RTMP identify tcUrl=%v, stream=%v, id=%v, type=%v",
tcUrl, streamName, currentStreamID, clientType)
// Find a backend SRS server to proxy the RTMP stream.
@ -333,7 +333,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
return errors.Wrapf(err, "start play")
}
}
logger.Df(ctx, "RTMP start streaming")
logger.Debug(ctx, "RTMP start streaming")
// For all proxy goroutines.
var wg sync.WaitGroup
@ -352,7 +352,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
if err != nil {
return errors.Wrapf(err, "read message")
}
//logger.Df(ctx, "client<- %v %v %vB", m.MessageType, m.Timestamp, len(m.Payload))
//logger.Debug(ctx, "client<- %v %v %vB", m.MessageType, m.Timestamp, len(m.Payload))
// TODO: Update the stream ID if not the same.
if err := client.WriteMessage(ctx, m); err != nil {
@ -375,7 +375,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
if err != nil {
return errors.Wrapf(err, "read message")
}
//logger.Df(ctx, "client-> %v %v %vB", m.MessageType, m.Timestamp, len(m.Payload))
//logger.Debug(ctx, "client-> %v %v %vB", m.MessageType, m.Timestamp, len(m.Payload))
// TODO: Update the stream ID if not the same.
if err := backend.client.WriteMessage(ctx, m); err != nil {
@ -392,7 +392,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
if r0 != nil {
// If backend connection closed normally, treat as normal disconnection
if utils.IsClosedNetworkError(r0) || utils.IsPeerClosedError(r0) {
logger.Df(ctx, "RTMP backend disconnected")
logger.Debug(ctx, "RTMP backend disconnected")
return nil
}
return errors.Wrapf(r0, "proxy backend->client")
@ -400,7 +400,7 @@ func (v *RTMPConnection) serve(ctx context.Context, conn *net.TCPConn) error {
if r1 != nil {
// If client connection closed normally, treat as normal disconnection
if utils.IsClosedNetworkError(r1) || utils.IsPeerClosedError(r1) {
logger.Df(ctx, "RTMP client disconnected")
logger.Debug(ctx, "RTMP client disconnected")
return nil
}
return errors.Wrapf(r1, "proxy client->backend")
@ -495,7 +495,7 @@ func (v *RTMPClientToBackend) Connect(ctx context.Context, tcUrl, streamName str
if _, err = hs.ReadC2S2(c); err != nil {
return errors.Wrapf(err, "read c2")
}
logger.Df(ctx, "backend simple handshake done, server=%v", addr)
logger.Debug(ctx, "backend simple handshake done, server=%v", addr)
if err := hs.WriteC2S2(c, hs.C1S1()); err != nil {
return errors.Wrapf(err, "write c2")
@ -515,7 +515,7 @@ func (v *RTMPClientToBackend) Connect(ctx context.Context, tcUrl, streamName str
if _, err := rtmp.ExpectPacket(ctx, client, &connectAppRes); err != nil {
return errors.Wrapf(err, "expect connect app res")
}
logger.Df(ctx, "backend connect RTMP app, tcUrl=%v, id=%v", tcUrl, connectAppRes.SrsID())
logger.Debug(ctx, "backend connect RTMP app, tcUrl=%v, id=%v", tcUrl, connectAppRes.SrsID())
}
// Play or view RTMP stream with server.
@ -615,7 +615,7 @@ func (v *RTMPClientToBackend) publish(ctx context.Context, client *rtmp.Protocol
break
}
}
logger.Df(ctx, "backend publish stream=%v, sid=%v", streamName, currentStreamID)
logger.Debug(ctx, "backend publish stream=%v, sid=%v", streamName, currentStreamID)
return nil
}

View File

@ -26,7 +26,7 @@ import (
// backend server.
type srsSRTServer struct {
// The environment interface.
environment env.Environment
environment env.ProxyEnvironment
// The UDP listener for SRT server.
listener *net.UDPConn
@ -39,7 +39,7 @@ type srsSRTServer struct {
wg stdSync.WaitGroup
}
func NewSRSSRTServer(environment env.Environment, opts ...func(*srsSRTServer)) *srsSRTServer {
func NewSRSSRTServer(environment env.ProxyEnvironment, opts ...func(*srsSRTServer)) *srsSRTServer {
v := &srsSRTServer{
environment: environment,
start: time.Now(),
@ -78,7 +78,7 @@ func (v *srsSRTServer) Run(ctx context.Context) error {
return errors.Wrapf(err, "listen udp %v", saddr)
}
v.listener = listener
logger.Df(ctx, "SRT server listen at %v", saddr)
logger.Debug(ctx, "SRT server listen at %v", saddr)
// Consume all messages from UDP media transport.
v.wg.Add(1)
@ -91,17 +91,17 @@ func (v *srsSRTServer) Run(ctx context.Context) error {
if err != nil {
// If context is canceled or connection is closed, exit gracefully without logging error.
if ctx.Err() != nil || utils.IsClosedNetworkError(err) {
logger.Df(ctx, "SRT server done")
logger.Debug(ctx, "SRT server done")
return
}
// TODO: If SRT server closed unexpectedly, we should notice the main loop to quit.
logger.Wf(ctx, "SRT read from udp failed, err=%+v", err)
logger.Warn(ctx, "SRT read from udp failed, err=%+v", err)
time.Sleep(1 * time.Second)
continue
}
if err := v.handleClientUDP(ctx, caddr, buf[:n]); err != nil {
logger.Wf(ctx, "SRT handle udp %vB failed, addr=%v, err=%+v", n, caddr, err)
logger.Warn(ctx, "SRT handle udp %vB failed, addr=%v, err=%+v", n, caddr, err)
}
}
}()
@ -132,7 +132,7 @@ func (v *srsSRTServer) handleClientUDP(ctx context.Context, addr *net.UDPAddr, d
ctx = conn.ctx
if !ok {
logger.Df(ctx, "Create new SRT connection skt=%v", socketID)
logger.Debug(ctx, "Create new SRT connection skt=%v", socketID)
}
if newSocketID, err := conn.HandlePacket(pkt, addr, data); err != nil {
@ -213,7 +213,7 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
if pkt.SynCookie == 0 {
// Save handshake 0 packet.
v.handshake0 = pkt
logger.Df(ctx, "SRT Handshake 0: %v", v.handshake0)
logger.Debug(ctx, "SRT Handshake 0: %v", v.handshake0)
// Response handshake 1.
v.handshake1 = &SRTHandshakePacket{
@ -234,7 +234,7 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
SynCookie: 0x418d5e4e,
PeerIP: net.ParseIP("127.0.0.1"),
}
logger.Df(ctx, "SRT Handshake 1: %v", v.handshake1)
logger.Debug(ctx, "SRT Handshake 1: %v", v.handshake1)
if b, err := v.handshake1.MarshalBinary(); err != nil {
return errors.Wrapf(err, "marshal handshake 1")
@ -254,7 +254,7 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
// Save handshake packet.
v.handshake2 = pkt
logger.Df(ctx, "SRT Handshake 2: %v, sid=%v", v.handshake2, streamID)
logger.Debug(ctx, "SRT Handshake 2: %v, sid=%v", v.handshake2, streamID)
// Start the UDP proxy to backend.
if err := v.connectBackend(ctx, streamID); err != nil {
@ -272,7 +272,7 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
} else if _, err = v.backendUDP.Write(b); err != nil {
return errors.Wrapf(err, "write handshake 0")
}
logger.Df(ctx, "Proxy send handshake 0: %v", v.handshake0)
logger.Debug(ctx, "Proxy send handshake 0: %v", v.handshake0)
// Read handshake 1 from backend server.
b := make([]byte, 4096)
@ -282,7 +282,7 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
} else if err := handshake1p.UnmarshalBinary(b[:nn]); err != nil {
return errors.Wrapf(err, "unmarshal handshake 1")
}
logger.Df(ctx, "Proxy got handshake 1: %v", handshake1p)
logger.Debug(ctx, "Proxy got handshake 1: %v", handshake1p)
// Proxy handshake 2 to backend server.
handshake2p := *v.handshake2
@ -292,7 +292,7 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
} else if _, err = v.backendUDP.Write(b); err != nil {
return errors.Wrapf(err, "write handshake 2")
}
logger.Df(ctx, "Proxy send handshake 2: %v", handshake2p)
logger.Debug(ctx, "Proxy send handshake 2: %v", handshake2p)
// Read handshake 3 from backend server.
handshake3p := &SRTHandshakePacket{}
@ -301,13 +301,13 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
} else if err := handshake3p.UnmarshalBinary(b[:nn]); err != nil {
return errors.Wrapf(err, "unmarshal handshake 3")
}
logger.Df(ctx, "Proxy got handshake 3: %v", handshake3p)
logger.Debug(ctx, "Proxy got handshake 3: %v", handshake3p)
// Response handshake 3 to client.
v.handshake3 = &*handshake3p
v.handshake3.SynCookie = v.handshake1.SynCookie
v.socketID = handshake3p.SRTSocketID
logger.Df(ctx, "Handshake 3: %v", v.handshake3)
logger.Debug(ctx, "Handshake 3: %v", v.handshake3)
if b, err := v.handshake3.MarshalBinary(); err != nil {
return errors.Wrapf(err, "marshal handshake 3")
@ -322,12 +322,12 @@ func (v *SRTConnection) handleHandshake(ctx context.Context, pkt *SRTHandshakePa
nn, err := v.backendUDP.Read(b)
if err != nil {
// TODO: If backend server closed unexpectedly, we should notice the stream to quit.
logger.Wf(ctx, "read from backend failed, err=%v", err)
logger.Warn(ctx, "read from backend failed, err=%v", err)
return
}
if _, err = v.listenerUDP.WriteToUDP(b[:nn], addr); err != nil {
// TODO: If backend server closed unexpectedly, we should notice the stream to quit.
logger.Wf(ctx, "write to client failed, err=%v", err)
logger.Warn(ctx, "write to client failed, err=%v", err)
return
}
}

View File

@ -27,13 +27,13 @@ func InstallSignals(ctx context.Context, cancel context.CancelFunc) {
go func() {
for s := range sc {
logger.Df(ctx, "Got signal %v", s)
logger.Debug(ctx, "Got signal %v", s)
cancel()
}
}()
}
func InstallForceQuit(ctx context.Context, environment env.Environment) error {
func InstallForceQuit(ctx context.Context, environment env.ProxyEnvironment) error {
var forceTimeout time.Duration
timeoutStr := environment.ForceQuitTimeout()
if t, err := time.ParseDuration(timeoutStr); err != nil {
@ -45,7 +45,7 @@ func InstallForceQuit(ctx context.Context, environment env.Environment) error {
go func() {
<-ctx.Done()
time.Sleep(forceTimeout)
logger.Wf(ctx, "Force to exit by timeout")
logger.Warn(ctx, "Force to exit by timeout")
osExit(1)
}()
return nil

View File

@ -102,7 +102,7 @@ func TestInstallSignals_HandlesRepeatedSignals(t *testing.T) {
}
func TestInstallForceQuit_InvalidDurationReturnsError(t *testing.T) {
fakeEnv := &envfakes.FakeEnvironment{}
fakeEnv := &envfakes.FakeProxyEnvironment{}
fakeEnv.ForceQuitTimeoutReturns("not-a-duration")
err := InstallForceQuit(t.Context(), fakeEnv)
@ -121,7 +121,7 @@ func TestInstallForceQuit_ExitsAfterTimeout(t *testing.T) {
called, done, restore := swapExit(t)
defer restore()
fakeEnv := &envfakes.FakeEnvironment{}
fakeEnv := &envfakes.FakeProxyEnvironment{}
fakeEnv.ForceQuitTimeoutReturns("1ms")
ctx, cancel := context.WithCancel(t.Context())
@ -149,7 +149,7 @@ func TestInstallForceQuit_WaitsForCancelBeforeSleeping(t *testing.T) {
called, done, restore := swapExit(t)
defer restore()
fakeEnv := &envfakes.FakeEnvironment{}
fakeEnv := &envfakes.FakeProxyEnvironment{}
fakeEnv.ForceQuitTimeoutReturns("10ms")
// Intentionally use a never-canceled context and leak the goroutine:

View File

@ -40,7 +40,7 @@ func ApiResponse(ctx context.Context, w http.ResponseWriter, r *http.Request, da
}
func ApiError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error) {
logger.Wf(ctx, "HTTP API error %+v", err)
logger.Warn(ctx, "HTTP API error %+v", err)
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "%v\n", err)

View File

@ -15,7 +15,7 @@ func VersionMinor() int {
}
func VersionRevision() int {
return 145
return 146
}
func Version() string {

View File

@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v7-changes"></a>
## SRS 7.0 Changelog
* v7.0, 2026-04-28, Merge [#4670](https://github.com/ossrs/srs/pull/4670): Proxy: Refine logger and environment APIs. v7.0.146 (#4670)
* v7.0, 2026-04-23, Merge [#4667](https://github.com/ossrs/srs/pull/4667): Proxy: Refactor internal/errors and internal/sync, and add unit tests across internal/*. v7.0.145 (#4667)
* v7.0, 2026-04-18, Merge [#4665](https://github.com/ossrs/srs/pull/4665): Proxy: Harden internal/env tests and add counterfeiter fake generation. v7.0.144 (#4665)
* v7.0, 2026-04-12, Merge [#4661](https://github.com/ossrs/srs/pull/4661): Proxy: Move build output to bin/, replace godotenv with custom .env parser, and update docs. v7.0.143 (#4661)

View File

@ -9,6 +9,6 @@
#define VERSION_MAJOR 7
#define VERSION_MINOR 0
#define VERSION_REVISION 145
#define VERSION_REVISION 146
#endif