Skip to content

feat(ipv6): add dual-stack upstream support and URL handling#520

Merged
stackia merged 3 commits into
mainfrom
cursor/6db94245
Jun 12, 2026
Merged

feat(ipv6): add dual-stack upstream support and URL handling#520
stackia merged 3 commits into
mainfrom
cursor/6db94245

Conversation

@stackia

@stackia stackia commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add shared IPv6 URL/host helpers and dual-stack sequential-fallback async connect for HTTP proxy and RTSP TCP upstreams
  • Fix IPv6 bracket handling across Host validation, M3U/rewrite URLs, playlist base URL generation, bind config, and LuCI
  • Extend RTSP UDP/STUN for IPv6 address families; disable FCC and skip mcast-rejoin-interval safely when IPv6 is involved
  • Add IPv6 loopback e2e infrastructure and e2e/test_ipv6.py coverage

Test plan

  • C binary builds successfully
  • e2e/test_ipv6.py passes on IPv6-capable hosts (skips gracefully otherwise)
  • HTTP proxy to [::1]:port upstream with correct Host header
  • RTSP TCP interleaved playback via /rtsp/[::1]:port/...
  • Playlist/base URL generation with IPv6 listen address
  • FCC IPv6 address falls back to multicast without crash

Made with Cursor

@stackia stackia marked this pull request as ready for review June 12, 2026 04:22
@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/rtsp.c
session->connect_next = session->connect_results;
session->connect_last_errno = 0;
if (session->connect_results) {
session->upstream_family = session->connect_results->ai_family;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net

stackia and others added 2 commits June 12, 2026 12:25
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>
@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/utils.c
Comment thread src/stun.c
Comment thread src/rtsp.c
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>
@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-520.eastasia.1.azurestaticapps.net

@stackia stackia merged commit 8f5a4a4 into main Jun 12, 2026
10 checks passed
@stackia stackia deleted the cursor/6db94245 branch June 12, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants