1
0
mirror of https://github.com/danog/LibDNSNative.git synced 2024-11-26 20:14:49 +01:00
LibDNSNative/examples/simple.php
2019-07-15 14:59:42 +02:00

27 lines
756 B
PHP

<?php
use danog\LibDNSNative\NativeDecoderFactory;
use danog\LibDNSNative\NativeEncoderFactory;
use LibDNS\Messages\MessageFactory;
use LibDNS\Messages\MessageTypes;
use LibDNS\Records\QuestionFactory;
use LibDNS\Records\ResourceQTypes;
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);
$result = \dns_get_record(...$question);
$decoder = (new NativeDecoderFactory)->create();
$result = $decoder->decode($result, ...$question);
\var_dump($result);