1
0
mirror of https://github.com/danog/LibDNSNative.git synced 2024-11-30 04:29:07 +01:00
LibDNSNative/examples/simple.php

27 lines
756 B
PHP
Raw Normal View History

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);