[Request]: DNSServer should support TCP transport (RFC 7766)
- Dominant language
- Swift
- Stars
- 49.9k
- Forks
- 1.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 22
Description
The bundled DNS server in `Sources/DNSServer/DNSServer.swift` is UDP-only today. Two TODO markers in the source flag this as known-incomplete:
- `DNSServer.swift:39` `// TODO: TCP server`
- `DNSServer.swift:62` `// TODO: TCP server`
RFC 7766 ("DNS Transport over TCP - Implementation Requirements") requires modern resolvers to support TCP both as a fallback when UDP responses exceed 512 bytes (TC bit set) and as a primary transport. Without TCP, these query classes return truncated data or fail inside containers:
- DNSSEC-signed responses (RRSIG records push past 512 bytes regularly)
- Large AAAA / SRV / TXT records
- SPF / DKIM TXT chains (`_spf.google.com` is a common offender)
This shows up in the wild as "DNS sometimes works" bugs that are hard to attribute to the bundled resolver.
Proposed scope: add a TCP listener bound to the same address as the UDP socket, parse RFC 1035 length-prefixed messages, dispatch to the existing `Handlers/` stack, write the response back with the length prefix. Reuses the parser and handlers - transport-layer change only. ~200 lines including tests.
Happy to put up a PR if this fits the project's direction. Filing the issue first since I didn't see one tracking it.
Contributor guide
Research direction
Start with Sources/DNSServer/DNSServer.swift and the two TODO markers at lines 39 and 62, then trace how the existing Handlers/ stack receives UDP messages. Add coverage for RFC 1035 length-prefixed TCP messages and verify that TCP responses use the same framing and handler path. Done means the listener shares the UDP address and supports oversized or TCP-primary DNS queries without changing existing UDP behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100