Skip to content

custom-domain: stop publishing an underscore-leading CNAME target - #123

Merged
Leechael merged 1 commit into
mainfrom
check-underscore-dns-android
Sep 12, 2026
Merged

Leechael merged 1 commit into
mainfrom
check-underscore-dns-android

Conversation

@h4x3rotab

@h4x3rotab h4x3rotab commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

GATEWAY_DOMAIN is published as the custom domain's CNAME target, and the examples used _.<gateway-domain>. That name is unresolvable on Android.

Android's resolver runs every name in an A/AAAA answer through res_hnok, including the CNAME RDATA (getaddrinfo.cpp), and res_hnok accepts _ only between two alphanumerics:

#define borderchar(c) (alphachar(c) || digitchar(c))
#define middlechar(c) (borderchar(c) || hyphenchar(c) || underscorechar(c))

A label starting with _ sits in the border position, fails the check, and getanswer() drops the whole chain — so the hostname does not resolve on Android. glibc permits _ at any position and only rejects a leading -, which is why this never shows up in Linux or desktop-browser testing.

Note that _access would fail identically; the fix has to avoid a leading underscore, not just the bare _ label.

Change

Examples now use gateway.<gateway-domain>. The label is arbitrary: the gateway zone is a wildcard, the name never travels on the wire, and routing is driven by the client's SNI plus the app-address TXT record. Docs and default values only — no script logic changed, since dnsguide.py and dnsman.py already pass the value through verbatim.

_. keeps resolving, so this breaks no existing deployment — those are simply still broken on Android until they move.

Matching docs change: Phala-Network/phala-docs#177

🤖 Generated with Claude Code

GATEWAY_DOMAIN is published as the custom domain's CNAME target, and the
examples used `_.<gateway-domain>`. Android's resolver runs every name in an
A/AAAA answer through res_hnok, including the CNAME RDATA, and res_hnok
accepts `_` only between two alphanumerics. A label starting with `_` fails,
getanswer() drops the chain, and the hostname is unresolvable on Android --
while glibc, which permits `_` anywhere, resolves it fine, so the breakage
never shows up in Linux testing.

Switch the examples to `gateway.<gateway-domain>`. The label is arbitrary: the
gateway zone is a wildcard, the name never travels on the wire, and routing is
driven by the client's SNI plus the app-address TXT record. `_.` keeps
resolving, so existing deployments are unaffected by this change -- they are
simply still broken on Android until they move.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@Leechael Leechael 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.

lgtm

@Leechael
Leechael merged commit fd162b0 into main Sep 12, 2026
6 checks passed
@Leechael
Leechael deleted the check-underscore-dns-android branch September 12, 2026 03:56
samgbafa added a commit to TinyCloudLabs/openkey that referenced this pull request Oct 3, 2026
…C-513) (#207)

The dstack-ingress sidecar CNAMEs DOMAIN to GATEWAY_DOMAIN on every fresh
container start. It was _.${DSTACK_GATEWAY_DOMAIN}; Android's resolver
(bionic res_hnok) rejects a CNAME target whose first label is '_', so
api.openkey.so does not resolve on Android (WebView and native).

Use gateway.${DSTACK_GATEWAY_DOMAIN}: the CNAME target Phala Cloud
advertises (gateway.cname) and upstream dstack-ingress documents since
Dstack-TEE/dstack-examples#123. It resolves to the same gateway IP; the
gateway still routes by SNI + the _dstack-app-address TXT record, so TLS
remains terminated inside the CVM.
samgbafa added a commit to TinyCloudLabs/tinycloud-node that referenced this pull request Oct 4, 2026
…ud.xyz (TC-513) (#242)

The dstack-ingress sidecar CNAMEs DOMAIN to GATEWAY_DOMAIN on every fresh
container start. It was _.${DSTACK_GATEWAY_DOMAIN}; Android's resolver
(bionic res_hnok) rejects a CNAME target whose first label is '_', so
tee.node.tinycloud.xyz does not resolve on Android (WebView and native).

Use gateway.${DSTACK_GATEWAY_DOMAIN}: the CNAME target Phala Cloud
advertises for this CVM (gateway.cname) and upstream dstack-ingress
documents since Dstack-TEE/dstack-examples#123. It resolves to the same
gateway IP; the gateway still routes by SNI + the _dstack-app-address TXT
record, so TLS remains terminated inside the CVM.

(cherry picked from commit 091688b)
samgbafa added a commit to TinyCloudLabs/tinycloud-node that referenced this pull request Oct 4, 2026
…ud.xyz (TC-513) (#241)

The dstack-ingress sidecar CNAMEs DOMAIN to GATEWAY_DOMAIN on every fresh
container start. It was _.${DSTACK_GATEWAY_DOMAIN}; Android's resolver
(bionic res_hnok) rejects a CNAME target whose first label is '_', so
tee.node.tinycloud.xyz does not resolve on Android (WebView and native).

Use gateway.${DSTACK_GATEWAY_DOMAIN}: the CNAME target Phala Cloud
advertises for this CVM (gateway.cname) and upstream dstack-ingress
documents since Dstack-TEE/dstack-examples#123. It resolves to the same
gateway IP; the gateway still routes by SNI + the _dstack-app-address TXT
record, so TLS remains terminated inside the CVM.
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