2019-07-15 14:41:26 +02:00
|
|
|
<?php
|
|
|
|
use danog\LibDNSNative\NativeDecoderFactory;
|
2019-07-15 14:59:42 +02:00
|
|
|
use danog\LibDNSNative\NativeEncoderFactory;
|
2019-07-15 14:41:26 +02:00
|
|
|
use LibDNS\Messages\MessageFactory;
|
|
|
|
use LibDNS\Messages\MessageTypes;
|
2019-07-15 14:59:42 +02:00
|
|
|
use LibDNS\Records\QuestionFactory;
|
|
|
|
use LibDNS\Records\ResourceQTypes;
|
2019-07-15 14:41:26 +02:00
|
|
|
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
|
|
|
|
$question = (new QuestionFactory)->create(ResourceQTypes::DNSKEY);
|
|
|
|
$question->setName('daniil.it');
|
|
|
|
|
|
|
|
$message = (new MessageFactory)->create(MessageTypes::QUERY);
|
|
|
|
$records = $message->getQuestionRecords();
|
|
|
|
$records->add($question);
|
|
|
|
|
|
|
|
$encoder = (new NativeEncoderFactory)->create();
|
|
|
|
$question = $encoder->encode($message);
|
|
|
|
|
2019-07-15 14:59:42 +02:00
|
|
|
$result = \dns_get_record(...$question);
|
2019-07-15 14:41:26 +02:00
|
|
|
|
|
|
|
$decoder = (new NativeDecoderFactory)->create();
|
|
|
|
$result = $decoder->decode($result, ...$question);
|
|
|
|
|
2019-07-15 14:59:42 +02:00
|
|
|
\var_dump($result);
|