https://github.com/danog/libdnsnative
Encoder/decoder for PHP's dns_get_record raw format based on libdns
https://github.com/danog/libdnsnative
Last synced: 2 months ago
JSON representation
Encoder/decoder for PHP's dns_get_record raw format based on libdns
- Host: GitHub
- URL: https://github.com/danog/libdnsnative
- Owner: danog
- License: mit
- Created: 2019-07-15T12:56:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-25T18:45:49.000Z (almost 7 years ago)
- Last Synced: 2025-01-12T20:13:14.258Z (over 1 year ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LibDNSNative
[](https://travis-ci.org/danog/libdnsnative)

Encoder/decoder for the raw format of [PHP's dns_get_record function](https://www.php.net/manual/en/function.dns-get-record.php) based on [libdns](https://github.com/DaveRandom/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
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);
```