Skip to content

Latest commit

 

History

History
227 lines (196 loc) · 4.98 KB

aaaa.md

File metadata and controls

227 lines (196 loc) · 4.98 KB

Address (IP v6) records

Create

Create from constructor

$record = new AAAA([
	'host' => "aaaa.test.bluelibraries.com",
	'ttl' => 3600,
	'ipv6' => "::ffff:1451:6f55"
]);

echo 'getHost = ' . $record->getHost() . PHP_EOL;
echo 'getTtl = ' . $record->getTtl() . PHP_EOL;
echo 'getClass = ' . $record->getClass() . PHP_EOL;
echo 'getTypeName = ' . $record->getTypeName() . PHP_EOL;
echo 'getIPV6 = ' . $record->getIPV6() . PHP_EOL;
getHost = aaaa.test.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = AAAA
getIPV6 = ::ffff:1451:6f55

Create with a setter

$record = new AAAA();
                $record->setData([
	'host' => "aaaa.test.bluelibraries.com",
	'ttl' => 3600,
	'ipv6' => "::ffff:1451:6f55"
]);

echo 'getHost = ' . $record->getHost() . PHP_EOL;
echo 'getTtl = ' . $record->getTtl() . PHP_EOL;
echo 'getClass = ' . $record->getClass() . PHP_EOL;
echo 'getTypeName = ' . $record->getTypeName() . PHP_EOL;
echo 'getIPV6 = ' . $record->getIPV6() . PHP_EOL;
getHost = aaaa.test.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = AAAA
getIPV6 = ::ffff:1451:6f55

Create from string

$record = Record::fromString('aaaa.test.bluelibraries.com 3600 IN AAAA ::ffff:1451:6f55');

echo 'getHost = ' . $record->getHost() . PHP_EOL;
echo 'getTtl = ' . $record->getTtl() . PHP_EOL;
echo 'getClass = ' . $record->getClass() . PHP_EOL;
echo 'getTypeName = ' . $record->getTypeName() . PHP_EOL;
echo 'getIPV6 = ' . $record->getIPV6() . PHP_EOL;
getHost = aaaa.test.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = AAAA
getIPV6 = ::ffff:1451:6f55

Create from initialized array

$record = Record::fromNormalizedArray([
	'host' => "aaaa.test.bluelibraries.com",
	'ttl' => 3600,
	'ipv6' => "::ffff:1451:6f55",
	'type' => "AAAA"
]);

echo 'getHost = ' . $record->getHost() . PHP_EOL;
echo 'getTtl = ' . $record->getTtl() . PHP_EOL;
echo 'getClass = ' . $record->getClass() . PHP_EOL;
echo 'getTypeName = ' . $record->getTypeName() . PHP_EOL;
echo 'getIPV6 = ' . $record->getIPV6() . PHP_EOL;
getHost = aaaa.test.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = AAAA
getIPV6 = ::ffff:1451:6f55

Retrieve from Internet

Retrieve with helper

$records = DNS::getRecords('aaaa.test.bluelibraries.com', RecordTypes::AAAA);

print_r($records);
Array
(
    [0] => BlueLibraries\Dns\Records\Types\AAAA Object
        (
            [data:protected] => Array
                (
                    [host] => aaaa.test.bluelibraries.com
                    [ttl] => 3600
                    [ipv6] => ::ffff:1451:6f55
                    [type] => AAAA
                    [class] => IN
                )

        )

)

Retrieve without helper

$dns = new DnsRecords();
$records = $dns->get('aaaa.test.bluelibraries.com', RecordTypes::AAAA);

print_r($records);
Array
(
    [0] => BlueLibraries\Dns\Records\Types\AAAA Object
        (
            [data:protected] => Array
                (
                    [host] => aaaa.test.bluelibraries.com
                    [ttl] => 3600
                    [ipv6] => ::ffff:1451:6f55
                    [type] => AAAA
                    [class] => IN
                )

        )

)

Retrieve without helper, using custom handler settings

$dnsHandler = new TCP();
$dnsHandler->setRetries(2);
$dnsHandler->setTimeout(3);
$dnsHandler->setNameserver('8.8.8.8');

$dns = new DnsRecords($dnsHandler);

$records = $dns->get('aaaa.test.bluelibraries.com', RecordTypes::AAAA);

print_r($records);
Array
(
    [0] => BlueLibraries\Dns\Records\Types\AAAA Object
        (
            [data:protected] => Array
                (
                    [host] => aaaa.test.bluelibraries.com
                    [ttl] => 3600
                    [ipv6] => ::ffff:1451:6f55
                    [type] => AAAA
                    [class] => IN
                )

        )

)

Transform

Transform to String

$record = new AAAA([
	'host' => "aaaa.test.bluelibraries.com",
	'ttl' => 3600,
	'ipv6' => "::ffff:1451:6f55"
]);

echo 'string1 = ' . json_encode($record->toString()) . PHP_EOL;
echo 'string2 = ' . json_encode((string)$record) . PHP_EOL;
string1 = "aaaa.test.bluelibraries.com 3600 IN AAAA ::ffff:1451:6f55"
string2 = "aaaa.test.bluelibraries.com 3600 IN AAAA ::ffff:1451:6f55"

Transform to JSON

$record = new AAAA([
	'host' => "aaaa.test.bluelibraries.com",
	'ttl' => 3600,
	'ipv6' => "::ffff:1451:6f55"
]);

echo 'JSON = ' . json_encode($record) . PHP_EOL;
JSON = {"host":"aaaa.test.bluelibraries.com","ttl":3600,"ipv6":"::ffff:1451:6f55","class":"IN","type":"AAAA"}

Transform to Array

$record = new AAAA([
	'host' => "aaaa.test.bluelibraries.com",
	'ttl' => 3600,
	'ipv6' => "::ffff:1451:6f55"
]);

print_r($record->toArray());
Array
(
    [host] => aaaa.test.bluelibraries.com
    [ttl] => 3600
    [ipv6] => ::ffff:1451:6f55
    [class] => IN
    [type] => AAAA
)