Skip to content

Screen PDS endpoint hosts without Network.framework - #55

Merged
germ-mark merged 2 commits into
mainfrom
port/service-endpoint-libc
Aug 18, 2026
Merged

Screen PDS endpoint hosts without Network.framework#55
germ-mark merged 2 commits into
mainfrom
port/service-endpoint-libc

Conversation

@germ-mark

@germ-mark germ-mark commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

ServiceEndpoint.swift imported Darwin and Network, so the package does not
build on Linux or Android. This replaces those with libc plus one reimplemented
parser, ahead of adding the Linux and Android CI legs.

Why the parsers couldn't just move to inet_pton

Network's IPv4Address is not a strict dotted-quad parser. Readings taken from
it on macOS:

host IPv4Address inet_pton inet_aton
16843009 1.1.1.1 1.1.1.1
0x7f000001 127.0.0.1 127.0.0.1
127.1 127.0.0.1 127.0.0.1
0177.0.0.1 177.0.0.1 177.0.0.1 127.0.0.1
010 0.0.0.8 0.0.0.8

https://16843009 is an accepted endpoint in the existing tests, and it is only
accepted because IPv4Address vouches for it as a literal — inet_pton rejects
the short forms, so swapping it in would have started rejecting valid dotless
literals.

The probes pin down IPv4Address's actual shape: for a dotted quad it uses a
permissive grammar of its own (leading zero decimal, 0x hex); for everything
else
it defers to inet_aton, octal included — 010 is 0.0.0.8, and
018015111 is no address at all (8 is not an octal digit). IPLiteral.v4
mirrors exactly that: a reimplementation of the quad grammar, pinned by tests,
and legacyV4/inet_aton for every other shape. v6 moves to
inet_pton(AF_INET6) — byte-identical to IPv6Address on every case probed,
including embedded v4 and %zone suffixes — and IPLiteral.embeddedV4
reproduces asIPv4, since the ::1 distinction is what the loopback exemption
turns on.

Getting the non-quad deferral right matters for the screening, not just
compatibility: a decimal-everywhere reading would have accepted dotless
spellings like 018015111 as public literals, exempting them from the
single-label rule that exists because such names resolve through local search
domains. https://018015111 is now pinned as rejected in PDSEndpointTests.

Behavior

Unchanged on Apple platforms — all 33 existing tests pass untouched. The one
probed divergence from IPv4Address is a quad part of 0x with no digits
(1.0x.2.3), which read as zero there and has no reading here; it loses the
literal exemption and is screened as a name, and where the platform's
inet_aton reads it, that reading is still screened.

IPLiteralTests pins the accepted spellings (quad-decimal and octal-deferral
forms), the rejected ones, the leading-zero disagreement between the two v4
readings, and the v4-in-v6 table against readings probed from the real Network
parsers, so drift in the reimplementation fails a test rather than opening a
hole.

Part of GER-2175.

🤖 Generated with Claude Code

Network is Apple-only, so ServiceEndpoint.swift kept the package from
building on Linux or Android. IPv4Address has no libc equivalent — it
accepts 16843009 and 0x7f000001, which inet_pton rejects — so its grammar
is reimplemented and pinned against readings taken from the real parser.

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

changeset-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 17738ad

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

IPv4Address only reads leading zeros as decimal in dotted quads; shorter
forms take inet_aton's octal grammar, so 010 is 0.0.0.8 and 018015111 is
no address at all. The decimal-everywhere reimplementation read that last
class as public literals, exempting dotless spellings the single-label
rule rejects on main. Also fixes the changeset package name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@germ-mark
germ-mark merged commit 05be717 into main Aug 18, 2026
11 of 12 checks passed
@germ-mark
germ-mark deleted the port/service-endpoint-libc branch August 18, 2026 03:34
@github-actions github-actions Bot mentioned this pull request Aug 18, 2026
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.

1 participant