1
0
mirror of https://github.com/danog/LibDNSNative.git synced 2024-11-26 12:04:40 +01:00
Go to file
2019-08-22 22:48:52 +02:00
examples phpcs fix 2019-07-15 14:59:42 +02:00
lib Fixes 2019-08-22 22:48:52 +02:00
test phpcs fix 2019-07-15 14:59:42 +02:00
.gitignore First commit 2019-07-15 14:41:26 +02:00
.php_cs.dist First commit 2019-07-15 14:41:26 +02:00
.travis.yml First commit 2019-07-15 14:41:26 +02:00
appveyor.yml First commit 2019-07-15 14:41:26 +02:00
composer.json First commit 2019-07-15 14:41:26 +02:00
LICENSE First commit 2019-07-15 14:41:26 +02:00
phpunit.xml.dist First commit 2019-07-15 14:41:26 +02:00
README.md First commit 2019-07-15 14:41:26 +02:00

LibDNSNative

Build Status License

Encoder/decoder for the raw format of PHP's dns_get_record function based on libdns: allows usage of the function to fetch all kinds of DNS records, not just the ones supported by the DNS_ constants.

The API consists of a NativeEncoderFactory that creates NativeEncoder objects, that can encode libdns Message objects to a list of parameters that that must be passed to the dns_get_record function.

The NativeDecoderFactory creates NativeDecoder objects, that accept the results of the dns_get_record function and decode them back to Message objects.

Installation

composer require danog/libdns-native

Usage

<?php

require 'vendor/autoload.php';

use danog\LibDNSNative\NativeEncoderFactory;
use danog\LibDNSNative\NativeDecoderFactory;
use LibDNS\Records\QuestionFactory;
use LibDNS\Records\ResourceQTypes;
use LibDNS\Messages\MessageFactory;
use LibDNS\Messages\MessageTypes;

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