feat(ipv6): add dual-stack upstream support and URL handling#520
Conversation
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d593d2c6a6
ℹ️ 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".
| session->connect_next = session->connect_results; | ||
| session->connect_last_errno = 0; | ||
| if (session->connect_results) { | ||
| session->upstream_family = session->connect_results->ai_family; |
There was a problem hiding this comment.
Defer STUN socket family until a candidate connects
When rtsp-stun-server is enabled for a dual-stack hostname, this records the family of the first resolver result before any TCP candidate has actually connected, and the immediately following early STUN path creates RTP/RTCP sockets with that family. If the first address later times out or fails and rtsp_try_next_candidate() falls back to the other family, those UDP/STUN sockets are kept and reused for SETUP, so an IPv6-first/IPv4-fallback (or reverse) connection advertises ports from sockets created for the wrong address family instead of recreating them for the connected upstream.
Useful? React with 👍 / 👎.
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net |
Enable IPv6-only upstream connections for HTTP proxy and RTSP, improve Host/URL bracket handling, and add IPv6 e2e coverage with graceful FCC and mcast-rejoin fallbacks. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net |
There was a problem hiding this comment.
Pull request overview
This PR extends rtp2httpd’s IPv6 support end-to-end by adding shared IPv6 host/URL helpers, enabling dual-stack upstream connection fallback for HTTP proxy and RTSP-over-TCP, and tightening IPv6 bracket handling across core URL generation, config parsing, and LuCI. It also expands RTSP UDP/STUN and adjusts FCC/multicast behavior where IPv6 is unsupported, with new e2e coverage for IPv6 loopback.
Changes:
- Add reusable host/authority parsing + formatting helpers (IPv6 bracketing, host[:port] parsing, sockaddr port setters) and apply them across HTTP/RTSP/M3U logic.
- Implement dual-stack sequential getaddrinfo candidate fallback for HTTP proxy and RTSP TCP upstream connects.
- Add IPv6-capable STUN parsing/sending and multicast/FCC IPv6 guardrails; introduce IPv6 loopback e2e tests and supporting helper updates.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils.h | Declare new shared host/URL + sockaddr helpers for IPv6 handling. |
| src/utils.c | Implement host bracketing/authority formatting and host[:port] parsing utilities. |
| src/stun.c | Update STUN server parsing and add dual-stack resolution + IPv6 XOR-MAPPED-ADDRESS parsing. |
| src/service.c | Disable FCC when IPv6 is involved (FCC protocol IPv4-only), fallback to multicast. |
| src/rtsp.h | Add dual-stack connect state to RTSP session and document IPv6 host storage semantics. |
| src/rtsp.c | Dual-stack sequential-fallback async connect; bracket IPv6 in RTSP request URIs; IPv6-capable UDP sockets/NAT probe. |
| src/multicast.h | Add warn-once flag for unsupported IPv6 periodic rejoin. |
| src/multicast.c | Skip periodic rejoin for IPv6 groups with a warn-once log. |
| src/m3u.c | Bracket IPv6 in generated base URLs and prefer IPv4 then IPv6 addresses for server address selection. |
| src/http.c | Use shared host[:port] parser for Host validation with IPv6 bracket support. |
| src/http_proxy.h | Add dual-stack async connect state; clarify that stored host is bare (no IPv6 brackets). |
| src/http_proxy.c | Dual-stack sequential-fallback async connect; robust host[:port] parsing; bracket IPv6 in Host header generation. |
| src/http_proxy_rewrite.c | Rewrite relative URLs using formatted IPv6-safe authority (with default-port omission). |
| src/configuration.c | Allow bracketed IPv6 in [bind] by stripping [] before getaddrinfo. |
| openwrt-support/luci-app-rtp2httpd/htdocs/luci-static/resources/view/rtp2httpd.js | Bracket bare IPv6 literals for URL parsing / UI URL construction. |
| e2e/test_ipv6.py | New IPv6 loopback e2e coverage for HTTP proxy, RTSP TCP, Host validation, base URL generation, FCC fallback. |
| e2e/helpers/ports.py | Add IPv6-aware free-port selection and ipv6 loopback availability probe. |
| e2e/helpers/mock_rtsp.py | Allow mock RTSP server to listen on IPv6 loopback. |
| e2e/helpers/mock_http.py | Allow mock HTTP upstream to listen on IPv6 loopback. |
| e2e/helpers/http.py | Bracket IPv6 in Host header for stream helper requests. |
| e2e/helpers/init.py | Export ipv6_loopback_available helper. |
| docs/reference/configuration.md | Document IPv6 limitation for mcast-rejoin-interval and IPv6 bind examples. |
| docs/guide/url-formats.md | Add IPv6 URL format guidance and dual-stack behavior notes (ZH). |
| docs/en/reference/configuration.md | Document IPv6 limitation for mcast-rejoin-interval and IPv6 bind examples (EN). |
| docs/en/guide/url-formats.md | Add IPv6 URL format guidance and dual-stack behavior notes (EN). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reset UDP/STUN sockets when dual-stack connect switches address family, validate ports with strtol in parse_host_port, and bracket IPv6 in LuCI URLs that include an explicit scheme. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net |
Summary
mcast-rejoin-intervalsafely when IPv6 is involvede2e/test_ipv6.pycoverageTest plan
e2e/test_ipv6.pypasses on IPv6-capable hosts (skips gracefully otherwise)[::1]:portupstream with correct Host header/rtsp/[::1]:port/...Made with Cursor