From 66151df6c6783f370273cabfa5b3beb29317cfa5 Mon Sep 17 00:00:00 2001 From: Roland Date: Sun, 13 Sep 2026 19:42:22 -0600 Subject: [PATCH] captive portal: never forward any record type for probe hosts `address=` only synthesizes A/AAAA answers. iOS also asks for the HTTPS record type; dnsmasq forwarded that upstream, Apple's answer aliased to captive.g.aaplimg.com, and the phone fetched the genuine "Success" from Apple instead of the portal. Each probe host now also gets `local=`, so dnsmasq answers every type itself, and the CDN alias is a probe host too. Observed with dnsmasq query logging on a hotspot with an eth0 uplink. Co-Authored-By: Claude Fable 5.1 --- controller/lib/captive_portal.py | 8 ++++++-- controller/test/test_captive_portal.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/controller/lib/captive_portal.py b/controller/lib/captive_portal.py index e204a1f1..285ac8f5 100644 --- a/controller/lib/captive_portal.py +++ b/controller/lib/captive_portal.py @@ -16,6 +16,7 @@ logger = logging.getLogger(__name__) # wildcard would break the hotspot's forwarding of everything else to the WROLPi's uplink. PROBE_HOSTS = ( 'captive.apple.com', # iOS / macOS + 'captive.g.aaplimg.com', # the CDN name captive.apple.com aliases to 'connectivitycheck.gstatic.com', # Android 'connectivitycheck.android.com', # Android (older) 'www.msftconnecttest.com', # Windows 10+ @@ -88,8 +89,11 @@ def render_dnsmasq_config(ip: str) -> str: '# Captive portal: captive-portal probe hostnames resolve to this WROLPi.', '# Only these names are hijacked so the hotspot still forwards everything else.', ] - lines.extend(f'address=/{host}/{ip}' for host in PROBE_HOSTS) - lines.append(f'address=/{FRIENDLY_NAME}/{ip}') + for host in (*PROBE_HOSTS, FRIENDLY_NAME): + # `address=` only answers A/AAAA. Phones also ask for the HTTPS record type, and a + # forwarded answer leads them to the real host; `local=` never forwards any type. + lines.append(f'local=/{host}/') + lines.append(f'address=/{host}/{ip}') return '\n'.join(lines) + '\n' diff --git a/controller/test/test_captive_portal.py b/controller/test/test_captive_portal.py index 1a77ec5f..46e2ae5b 100644 --- a/controller/test/test_captive_portal.py +++ b/controller/test/test_captive_portal.py @@ -41,6 +41,15 @@ class TestRenderDnsmasqConfig: assert f'address=/{host}/10.42.0.1' in config assert f'address=/{FRIENDLY_NAME}/10.42.0.1' in config + def test_probe_hosts_are_never_forwarded(self): + """iOS asks for the HTTPS record type too; a forwarded answer leads it to the real Apple.""" + config = render_dnsmasq_config('10.42.0.1') + for host in (*PROBE_HOSTS, FRIENDLY_NAME): + assert f'local=/{host}/' in config + + def test_apple_cdn_alias_is_a_probe_host(self): + assert 'captive.g.aaplimg.com' in PROBE_HOSTS + def test_no_wildcard(self): """A wildcard would break the hotspot's Internet passthrough.""" assert '/#/' not in render_dnsmasq_config('10.42.0.1')