11 Commits
Author SHA1 Message Date
tchivert 827e9fd8b9 update registry
docker / docker (push) Successful in 2m15s
2026-10-24 00:20:08 +02:00
tchivert 42d73bf190 fix: allow to configure both ipv4 and ipv6 for a given host
docker / docker (push) Successful in 2m37s
package / apt (push) Successful in 58s
2026-10-19 16:01:01 +02:00
tchivert 2cc8bc6b1b update readme
docker / docker (push) Successful in 2m10s
2026-10-11 22:38:00 +00:00
tchivert 24443e302b fix: set explicit permissions when building deb packages
docker / docker (push) Successful in 2m11s
package / apt (push) Successful in 58s
dpkg-deb rejects a control directory with mode 777, which is what
mkdir -p produces on runners running with umask 000. Normalize the
package tree after copying (directories 0755, files 0644, binary
0755) and build with dpkg-deb --root-owner-group so the archives
record root:root ownership instead of the runner's uid.
2026-10-11 22:57:18 +02:00
tchivert cb6403471d fix: docker actions versions
docker / docker (push) Successful in 2m37s
package / apt (push) Failing after 46s
2026-10-11 21:29:01 +02:00
tchivert 6cb247da60 fix: update ci image registry
docker / docker (push) Failing after 51s
2026-10-11 21:23:49 +02:00
tchivert 2a3e20d8d7 close remaining RFC 7873/6891 spec gaps from review
test / test (pull_request) Successful in 10s
Malformed COOKIE options (RFC 7873 section 5.2.2): option lengths other
than 8 and 16-40 are now answered with FORMERR and never get a COOKIE
in the response; getQueryCookie classifies absent/valid/malformed.

Server-cookie learning probes (RFC 7873 section 5.4): question-less
queries carrying a COOKIE option are answered NOERROR with a freshly
minted server cookie, or BADCOOKIE when re-establishing an invalid
server cookie. miekg's ServeMux refuses question-less queries, so the
servers now use handleQuery directly as their handler, and
msgAcceptFunc lets QDCOUNT=0 QUERY requests through.

EDNS/OPT handling (RFC 6891): the upstream OPT record is no longer
cached or forwarded (sections 6.1.1 and 6.2.1) — it is removed before
caching and rebuilt per query. Responses to EDNS queries always carry
an OPT record advertising the responder's payload size and echoing
the query's DO bit (sections 6.1.1 and 6.2.4); responses to non-EDNS
queries never carry one (section 7). applyCookie is now applyEDNS.

Tests: malformed-COOKIE FORMERR for lengths 4/12/41 and normal
answers for 8/16/40, cookie probe (NOERROR/BADCOOKIE) at the handler
level and through a real miekg server over UDP (independent raw-socket
verification included), msgAcceptFunc unit test, OPT-never-cached and
OPT-rebuild assertions, non-EDNS responses carry no OPT.

README documents the new EDNS and COOKIE behaviors.
2026-10-11 19:22:04 +02:00
tchivert 8628de05d0 harden response handling and packaging; make cookies fully RFC 9018-compliant
test / test (pull_request) Successful in 35s
Response handling:
- Clear the DNSSEC AD bit in all responses (RFC 6840 section 5.8): rdns
  forwards but does not validate, so it must not relay the upstream AD bit
- Truncate UDP responses exceeding the client's advertised payload size
  (RFC 6891 section 6.2.5): set TC and let clients retry over TCP; the
  COOKIE option survives truncation. Server UDP buffer raised to 4096
- Decrement TTLs of cached responses by the time spent in the cache
  (positive and negative answers); -t remains the cache lifetime source
  of truth. OPT pseudo-records are left untouched
- Reject upstream responses whose question section does not match the
  query, then try the next nameserver (anti-spoofing)
- Echo the current query's question section on cache hits and forwarded
  responses (0x20 case), and stop mutating the client's message when
  adding EDNS for the upstream exchange
- Advertise 1232 bytes to upstream when the client sends no EDNS, and
  gate DoT connection error logging behind -l

Cookies:
- Make server cookies fully RFC 9018-compliant, pinned against the RFC
  Appendix A test vectors: version 1, second-granularity timestamps,
  little-endian hash sub-field, RFC 1982 serial-number skew checks,
  reserved sub-field hashed as received on validation
- Strip COOKIE options before caching instead of on every cache hit
- Count server cookies presented by clients in the
  rdns_cookie_checks_total metric (valid/invalid/absent), wiring
  validateServerCookie into the serving path
- Response OPT advertises the responder's payload size (RFC 6891)

Packaging and CI:
- package.yml: fix the deb Description/Homepage copy-paste errors,
  install the binary to /usr/local/bin (matching the systemd unit),
  register /etc/rdns conffiles, ship the systemd unit and the
  logrotate/rsyslog configs, add Installed-Size
- New test.yml workflow running go vet and go test -race on pull
  requests; image/release pushes stay tied to main/tags
- Stop tracking the generated conf/blocklist.txt (gitignore it,
  generate with utils/blocklist_update)
- README: fix the project description, document cookie handling, the
  AD-bit and truncation behavior, TTL decrementing, and utils/

Tests:
- Mock-upstream integration tests: end-to-end cookie rewrite and AD
  clearing, question-mismatch rejection, TCP retry on truncation, TC
  truncation per client buffer, TTL decrement on cache serve, question
  case echo, cache entry stored without COOKIE
- Unit tests: all 64 SipHash-2-4 reference vectors, RFC 9018 Appendix A
  cookie vectors, cookie validation metric

Upstream ports are overridable (upstreamDNSPort/upstreamDoTPort) so
tests can point the resolver at a mock nameserver.
2026-10-11 17:51:24 +02:00
tchivert a567a01c9f fix EDNS COOKIE (RFC 7873/9018) handling: terminate cookies at the resolver
Cached responses were served verbatim, replaying the COOKIE option of the
original upstream exchange to clients with a different client cookie, which
made dig report 'Client COOKIE mismatch' on repeat queries. Upstream server
cookies were also relayed downstream.

- Synthesize server cookies ourselves (RFC 9018: SipHash-2-4 over client
  cookie, version, timestamp and client IP, keyed with a rotating server
  secret, 1h rotation with previous-secret retention and timestamp skew
  tolerance)
- Echo the current query's client cookie unchanged in every response
- Strip/rebuild the COOKIE option on cache hits, including negative
  (NXDOMAIN) responses, and never relay the upstream server cookie
- Respond without a COOKIE option when the query has none
- Keep cached entries pristine (store a copy) so per-client rewriting never
  mutates a cached message
- Add unit and integration regression tests
2026-10-11 17:10:00 +02:00
tchivert 9365d08fcf ci: run go vet and tests before builds
docker / docker (push) Successful in 12m7s
package / apt (push) Successful in 1m18s
2026-08-21 22:36:49 +02:00
tchivert 0d8ea0927f fix cache races, cross-class cache poisoning, TCP retry on truncation, blocklist_update separators; add singleflight, graceful shutdown, hardening and tests 2026-08-21 22:34:25 +02:00