arrayaccess/dns-client

1.0.2 2023-11-13 08:59 UTC

This package is auto-updated.

Last update: 2024-11-03 18:19:24 UTC


README

Native Php DNS Client / Resolver implementation of RFC 1035. Support PSR-6: Caching Interface.

Requirements

  • Php 8.1 or later
  • Function focksopen enabled & allowed outbound connection to port 53
  • Network Connectivity (Absolutely!)

Installing

Currently, in development:

composer require arrayaccess/dns-client

Usage

use ArrayAccess\DnsRecord\Cache\Adapter\Psr6CacheAdapter;
use ArrayAccess\DnsRecord\DnsServerStorage;
use ArrayAccess\DnsRecord\Resolver;

$cache = new Psr6CacheAdapter();
// $cache->setCacheItemPool($cacheProvider);
$dnsServer = DnsServerStorage::createDefault();
$resolver = new Resolver($dnsServer, $cache);

/**
 * Lookup Single 
 */
$useCache = true; // default to true
$timeout = 3.5; // 3.5 seconds
$response = $resolver->lookup('domain-name.ext', 'A', 'IN', $timeout, $useCache);

/**
 * Enable Pseudo OPT 
 */
$resolver->setDnsSec(true);
$response = $resolver->lookup('domain-name.ext', 'A', 'IN');
$answers = $response->getAnswers();
$records = $answers->getRecords();
// Filter "A" Address Only
$arrayA = $records->getFilteredType('A');

IXFR & AXFR aren't fully implemented yet

Note

The RRTypes not completed yet, will use RRDefault as default.