Add free domain DNS onboarding hints

This commit is contained in:
jwinterm
2026-07-06 18:52:57 -04:00
parent 1dd601b0e4
commit b2bf06e050
7 changed files with 182 additions and 1 deletions
+24
View File
@@ -43,6 +43,7 @@ from .dns import (
DNS_MODES,
DNSPlan,
DNSRecordPlan,
FreeDomainHint,
dns_check,
dns_plan,
)
@@ -197,6 +198,11 @@ def main(argv: list[str] | None = None) -> int:
action="store_true",
help="Include NAT/router/tunnel reachability hints.",
)
dns_plan_parser.add_argument(
"--free-domain-hints",
action="store_true",
help="Include optional free subdomain registries to consider.",
)
dns_check_parser = dns_subcommands.add_parser(
"check",
help="Resolve clearnet domains and compare optional expected addresses.",
@@ -598,11 +604,14 @@ def _cmd_dns(config, args) -> int:
ipv6=args.ipv6,
dynamic_hostname=args.dynamic_hostname,
behind_router=args.behind_router,
free_domain_hints=args.free_domain_hints,
)
for record in plan.records:
_print_dns_record(record)
for hint in plan.hints:
_print_connectivity_hint(hint)
for hint in plan.free_domains:
_print_free_domain_hint(hint)
_print_dns_summary(plan)
return 1 if plan.status == "blocked" else 0
@@ -1094,6 +1103,20 @@ def _print_connectivity_hint(hint: ConnectivityHint) -> None:
)
def _print_free_domain_hint(hint: FreeDomainHint) -> None:
print(
"AMPG_FREE_DOMAIN_HINT "
f"provider=\"{_quote(hint.provider)}\" "
f"suffixes=\"{_quote(','.join(hint.suffixes))}\" "
f"fit=\"{_quote(hint.fit)}\" "
f"records=\"{_quote(hint.records)}\" "
f"workflow=\"{_quote(hint.workflow)}\" "
f"status={hint.status} "
f"url=\"{_quote(hint.url)}\" "
f"message=\"{_quote(hint.message)}\""
)
def _print_dns_summary(plan: DNSPlan) -> None:
statuses = [record.status for record in plan.records]
statuses.extend(hint.status for hint in plan.hints)
@@ -1102,6 +1125,7 @@ def _print_dns_summary(plan: DNSPlan) -> None:
f"status={plan.status} "
f"records={len(plan.records)} "
f"hints={len(plan.hints)} "
f"free_domain_hints={len(plan.free_domains)} "
f"todo={statuses.count('todo')} "
f"review={statuses.count('review')} "
f"blocked={statuses.count('blocked')} "
+72
View File
@@ -28,11 +28,24 @@ class ConnectivityHint:
message: str
@dataclass(frozen=True)
class FreeDomainHint:
provider: str
suffixes: tuple[str, ...]
fit: str
records: str
workflow: str
status: str
url: str
message: str
@dataclass(frozen=True)
class DNSPlan:
status: str
records: tuple[DNSRecordPlan, ...]
hints: tuple[ConnectivityHint, ...]
free_domains: tuple[FreeDomainHint, ...]
message: str
@@ -55,6 +68,7 @@ def dns_plan(
ipv6: str | None = None,
dynamic_hostname: str | None = None,
behind_router: bool = False,
free_domain_hints: bool = False,
) -> DNSPlan:
if mode not in DNS_MODES:
raise ValueError(f"unsupported DNS mode {mode!r}")
@@ -64,6 +78,7 @@ def dns_plan(
status="skipped",
records=(),
hints=(),
free_domains=(),
message="clearnet is not selected",
)
@@ -74,15 +89,72 @@ def dns_plan(
else:
records.extend(_dynamic_records(site_id, domain, dynamic_hostname=dynamic_hostname))
hints = _connectivity_hints(behind_router=behind_router)
free_domains = FREE_DOMAIN_HINTS if free_domain_hints else ()
status = _plan_status([record.status for record in records] + [hint.status for hint in hints])
return DNSPlan(
status=status,
records=tuple(records),
hints=tuple(hints),
free_domains=free_domains,
message=_plan_message(status),
)
FREE_DOMAIN_HINTS: tuple[FreeDomainHint, ...] = (
FreeDomainHint(
provider="is-a.dev",
suffixes=("is-a.dev",),
fit="developer personal sites and projects",
records="DNS records through reviewed repository changes",
workflow="fork repository, add domain config, open pull request",
status="community-reviewed",
url="https://github.com/is-a-dev/register",
message="good beginner option when a developer-branded subdomain is acceptable",
),
FreeDomainHint(
provider="JS.ORG",
suffixes=("js.org",),
fit="JavaScript ecosystem projects",
records="CNAME",
workflow="configure hosting custom domain, then open pull request",
status="strict-scope",
url="https://github.com/js-org/js.org",
message="only use for sites directly related to the JavaScript community",
),
FreeDomainHint(
provider="Open Domains",
suffixes=("is-cool.dev", "is-local.org", "is-not-a.dev", "localplayer.dev"),
fit="students and open-source projects",
records="A, AAAA, CNAME, NS, TXT, and related DNS records",
workflow="register through the current Open Domains web app",
status="verify-current-domains",
url="https://opendomains.andrewstech.me/",
message="GitHub registry moved to a web app; verify the current domain list before use",
),
FreeDomainHint(
provider="Community GitHub registries",
suffixes=(
"is-an.app",
"cluster.ws",
"wip.la",
"thedev.id",
"io.day",
"jsid.dev",
"is-a.co",
"is-a-good.dev",
"is-really.cool",
"js.cool",
),
fit="personal sites, hobby apps, and open-source projects",
records="varies by registry",
workflow="review registry terms, then open the requested issue or pull request",
status="verify-before-use",
url="https://github.com/tarampampam/domains",
message="treat as optional naming ideas; availability and rules can change",
),
)
def dns_check(
config: GatewayConfig,
*,