Skip to content

Commit 67db0dd

Browse files
stackiaclaude
andcommitted
feat: add configurable RTSP User-Agent header
Add --rtsp-user-agent CLI flag and rtsp-user-agent config option to customize the User-Agent sent in upstream RTSP requests. Some RTSP servers validate or require a specific User-Agent for compatibility. Also refactor e2e config tests into a parametrized framework covering config file, CLI, and CLI-over-config priority for multiple options. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 33500a4 commit 67db0dd

File tree

13 files changed

+470
-206
lines changed

13 files changed

+470
-206
lines changed

docs/en/reference/configuration.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ rtp2httpd [options]
3232

3333
> [!TIP]
3434
> In addition to global configuration, you can specify upstream interfaces per request using the `r2h-ifname` and `r2h-ifname-fcc` URL parameters. See [URL Formats](/en/guide/url-formats) for details.
35-
3635
> [!TIP]
3736
> On FreeBSD, specifying upstream interfaces is not supported except for multicast.
3837
@@ -79,7 +78,12 @@ rtp2httpd [options]
7978

8079
- `-U, --noudpxy` - Disable UDPxy compatibility mode (when disabled, only services defined in `[services]` or `external-m3u` can be used)
8180

82-
### RTSP NAT Traversal
81+
### RTSP Options
82+
83+
- `-u, --rtsp-user-agent <value>` - User-Agent header for upstream RTSP requests (default: `rtp2httpd/<version>`)
84+
- Applies to upstream RTSP requests such as OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, and GET_PARAMETER
85+
- Some upstream RTSP servers validate or require a specific User-Agent, so this option can be used for compatibility
86+
- When left empty, the built-in default value is used
8387

8488
- `-N, --rtsp-stun-server <host:port>` - STUN server address (default: disabled)
8589
- When an RTSP server only supports UDP transport and the client is behind NAT, STUN can be used to attempt NAT traversal (not guaranteed to succeed)
@@ -192,6 +196,10 @@ udp-rcvbuf-size = 524288
192196
# Not recommended if rtp2httpd is behind a reverse proxy (nginx/caddy/lucky, etc.)
193197
zerocopy-on-send = no
194198

199+
# User-Agent for upstream RTSP requests (default: rtp2httpd/<version>)
200+
# Configure this when an upstream RTSP server requires a specific User-Agent for compatibility
201+
rtsp-user-agent = rtp2httpd/custom
202+
195203
# STUN server for RTSP NAT traversal (default: disabled)
196204
# When an RTSP server only supports UDP transport and the client is behind NAT, STUN can be used to attempt NAT traversal (not guaranteed to succeed)
197205
# Format: host:port or host (default port: 3478)

docs/reference/configuration.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ rtp2httpd [选项]
3232

3333
> [!TIP]
3434
> 除了全局配置外,还可以在每个请求的 URL 中通过 `r2h-ifname``r2h-ifname-fcc` 参数指定上游接口,详见 [URL 格式说明](../guide/url-formats.md)
35-
3635
> [!TIP]
3736
> FreeBSD 系统下不支持指定除组播外的接口。
3837
@@ -79,7 +78,12 @@ rtp2httpd [选项]
7978

8079
- `-U, --noudpxy` - 禁用 UDPxy 兼容模式 (禁用后只能使用 `[services]``external-m3u` 中定义的服务)
8180

82-
### RTSP NAT 穿透
81+
### RTSP 相关
82+
83+
- `-u, --rtsp-user-agent <值>` - 上游 RTSP 请求的 User-Agent 头 (默认: `rtp2httpd/<version>`)
84+
- 作用于 OPTIONS、DESCRIBE、SETUP、PLAY、TEARDOWN、GET_PARAMETER 等上游 RTSP 请求
85+
- 某些上游 RTSP 服务器会校验或依赖特定 User-Agent,可通过此参数进行兼容
86+
- 留空时使用内置默认值
8387

8488
- `-N, --rtsp-stun-server <host:port>` - STUN 服务器地址 (默认: 禁用)
8589
- 当 RTSP 服务器仅支持 UDP 传输且客户端位于 NAT 后时,可尝试使用 STUN 进行 NAT 穿透(不保证成功)
@@ -192,6 +196,10 @@ udp-rcvbuf-size = 524288
192196
# 如果你的 rtp2httpd 位于反向代理之后 (nginx/caddy/lucky 等),不建议开启这个选项
193197
zerocopy-on-send = no
194198

199+
# 上游 RTSP 请求的 User-Agent(默认: rtp2httpd/<version>)
200+
# 当上游 RTSP 服务器要求特定 User-Agent 时可配置此项
201+
rtsp-user-agent = rtp2httpd/custom
202+
195203
# STUN 服务器用于 RTSP NAT 穿透(默认: 禁用)
196204
# 当 RTSP 服务器仅支持 UDP 传输且客户端位于 NAT 后时,可尝试使用 STUN 进行 NAT 穿透(不保证成功)
197205
# 格式: host:port 或 host(默认端口 3478)

0 commit comments

Comments
 (0)