Search by

rafalmasiarek / dns-resolver

rafalmasiarek

DNS resolver contract and a from-scratch client (A/AAAA/MX/TXT/PTR, EDNS0, TCP fallback, failover, caching) with a zero-config system-resolver default.

Package info

github.com/rafalmasiarek/php-dns-resolver

pkg:composer/rafalmasiarek/dns-resolver

Statistics

Installs: 45

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.1 2026-10-07 14:15 UTC

This package is auto-updated.

Last update: 2026-10-07 14:15:38 UTC


README

DNS resolver contract with two implementations:

  • SystemDnsResolver — zero-config, backed by PHP's own dns_get_record()/gethostbyaddr().
  • DnsClient/FailoverDnsClient — from-scratch raw UDP/TCP client targeting an explicit resolver, with its own timeout, independent of the system resolver.

Features

  • Record types: A, AAAA, MX (preference-sorted), TXT, PTR.
  • EDNS0 (RFC 6891): 4096-byte UDP payload advertisement + DNSSEC OK bit, with automatic TCP fallback when a response still arrives truncated.
  • AD (Authenticated Data) bit reporting on every answer — a soft signal that the queried resolver validated DNSSEC, not a cryptographic guarantee.
  • FailoverDnsClient: ordered multi-resolver failover, PSR-3 audit logging, and an optional total-timeout bounding every attempt across all configured resolvers combined.
  • resolveManyA(): concurrent batch A-record resolution over non-blocking sockets, with duplicate hostnames collapsed before querying.
  • CachingDnsResolver: TTL-respecting decorator for any DnsResolverInterface, backed by the included InMemoryDnsCache or a custom DnsCacheInterface implementation.