Skip to content

Add std/net DNS lookup helpers#114

Merged
joshcramer merged 4 commits into
mainfrom
feat/std-net-dns
Jun 6, 2026
Merged

Add std/net DNS lookup helpers#114
joshcramer merged 4 commits into
mainfrom
feat/std-net-dns

Conversation

@larimonious
Copy link
Copy Markdown
Contributor

@larimonious larimonious commented Jun 3, 2026

Summary

Adds the DD-046 DNS slice for std/net:

  • dns_lookup(name, record_type?, opts?) -> Result<Array<Map>, String>
    • Defaults record_type to A.
    • Supports data-bearing DNS lookup records: A, AAAA, ANAME, CAA, CDNSKEY, CDS, CNAME, CSYNC, DNSKEY, DS, HINFO, HTTPS, KEY, MX, NAPTR, NS, NSEC, NSEC3, NSEC3PARAM, NULL, OPENPGPKEY, PTR, RRSIG, SIG, SOA, SRV, SSHFP, SVCB, TLSA, TXT.
    • Rejects operational/meta record types like ANY, AXFR, IXFR, OPT, TSIG, and ZERO rather than treating them as normal app-level lookups.
    • Uses the system resolver only; custom nameserver support remains deferred because it can bypass DNS policy.
    • Returns record maps with actual returned type, name, value, and ttl.
  • dns_reverse(ip, opts?) -> Result<Array<String>, String>
    • Returns all PTR names for IPv4/IPv6 reverse lookup.
  • Keeps no-answer DNS responses as Ok([]) and invalid input / resolver setup / transport failures as Err(String).
  • Updates generated stdlib docs, AI guide, DD-046, typechecker signatures, and examples/std_net_dns.tnt.

Test Plan

  • cargo fmt -- --check
  • git diff --check
  • cargo check --profile dev-release
  • cargo test --lib stdlib::net::tests -- --nocapture
  • cargo test --test std_net_tests -- --nocapture
  • cargo test --test type_checker_tests std_net_phase1 -- --nocapture
  • cargo build --profile dev-release && ./target/dev-release/ntnt docs --generate
  • ./target/dev-release/ntnt validate examples/
  • ./target/dev-release/ntnt lint examples/std_net_dns.tnt
  • cargo test
  • NTNT_NET_EXTERNAL_DNS_TESTS=1 cargo test --test std_net_tests dns_lookup_external_smoke_is_opt_in -- --nocapture

Notes

External DNS smoke coverage stays opt-in so default CI is deterministic and does not depend on public DNS/network availability.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 3, 2026

Greptile Summary

This PR adds DNS lookup helpers to std/net. The main changes are:

  • Adds dns_lookup and dns_reverse runtime functions using the system resolver.
  • Supports a broad set of data-bearing DNS record types and rejects operational/meta types.
  • Returns DNS records as maps with actual type, name, value, and TTL.
  • Adds typechecker signatures, stdlib docs, design-doc updates, examples, and tests.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The latest example change keeps public DNS calls behind an explicit environment opt-in.
  • The earlier top-level DNS example behavior is no longer present.

Reviews (4): Last reviewed commit: "Make std net DNS example opt-in" | Re-trigger Greptile

Comment thread src/stdlib/net.rs
Comment thread examples/std_net_dns.tnt Outdated
@joshcramer joshcramer merged commit bfd0aeb into main Jun 6, 2026
10 checks passed
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