feat(rtsp): add ZTE NAT traversal mode - #701
Conversation
Documentation previewThe documentation preview has been deployed for this pull request. |
There was a problem hiding this comment.
Pull request overview
This PR adds an explicit RTSP NAT traversal mode selection (none|stun|zte) and implements ZTE ZXV10STB NAT punching by deriving the actual local/peer endpoints from the established RTSP TCP control socket, keeping UDP socket binding aligned on multi-interface systems. It also updates OpenWrt/iKuai integration, configuration samples, and adds E2E coverage for the new mode and compatibility behavior.
Changes:
- Add
rtsp-nat-mode(config + CLI) with legacy STUN inference viaconfig_get_effective_rtsp_nat_mode(). - Implement ZTE NAT punch flow and control-endpoint capture; bind UDP sockets to the RTSP TCP-selected local IPv4 when in ZTE mode.
- Add OpenWrt/iKuai wiring, docs updates, and new E2E tests + mock server behavior for ZTE.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rtsp.h | Extend RTSP session state with captured control socket endpoints and ZTE mode flags. |
| src/rtsp.c | Implement endpoint capture, ZTE header + probe behavior, and ZTE-aligned UDP binding. |
| src/configuration.h | Introduce rtsp_nat_mode_t and expose effective NAT-mode resolver API. |
| src/configuration.c | Parse/validate rtsp-nat-mode, add CLI flag, and implement legacy inference logic. |
| rtp2httpd.conf | Document new NAT mode option in sample config. |
| openwrt-support/rtp2httpd/files/rtp2httpd.init | Pass --rtsp-nat-mode from UCI config to daemon. |
| openwrt-support/rtp2httpd/files/rtp2httpd.conf | Add UCI option example for rtsp_nat_mode. |
| openwrt-support/luci-app-rtp2httpd/po/zh_Hans/rtp2httpd.po | Add localized strings for NAT mode UI. |
| openwrt-support/luci-app-rtp2httpd/po/templates/rtp2httpd.pot | Add template strings for NAT mode UI. |
| openwrt-support/luci-app-rtp2httpd/htdocs/luci-static/resources/view/rtp2httpd.js | Add LuCI form option for selecting NAT mode. |
| ikuai-support/rtp2httpd/scripts/start.sh | Add env-driven --rtsp-nat-mode CLI wiring. |
| ikuai-support/rtp2httpd/app/option.json | Add iKuai UI/config option for NAT mode. |
| e2e/test_rtsp_zte_nat.py | New end-to-end tests covering ZTE punch bytes, ordering, interface alignment, redirects, IPv6 fallback, and reload behavior. |
| e2e/helpers/mock_rtsp.py | Add ZTE-capable mock RTSP server and request event instrumentation. |
| e2e/helpers/init.py | Export the new MockRTSPServerZTE helper. |
| docs/reference/configuration.md | Document --rtsp-nat-mode and add sample config entries (ZH). |
| docs/en/reference/configuration.md | Document --rtsp-nat-mode and add sample config entries (EN). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5c1968f69
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
rtsp-nat-mode = auto|stun|ztewith CLI override. Auto uses STUN whenrtsp-stun-serveris configured and otherwise leaves NAT traversal disabled.ZXV10STBNAT punch flow using the actual local and peer endpoints of the connected RTSP TCP socket.Why
Issue #700 shows a failure mode consistent with symmetric NAT, where a STUN-derived mapping may not remain valid for the RTSP media server. This adds the ZTE-specific traversal mode as an independent implementation based on observable wire behavior.
Impact
The available modes are Auto, STUN, and ZTE. Auto is the default and preserves existing STUN behavior when a server is configured. ZTE mode is IPv4-only and falls back to ordinary RTSP negotiation for IPv6 upstreams.
Refs #700.
Validation
pnpm run lintpnpm run docs:build