https://github.com/danog/dns-over-https
Async DNS-over-HTTPS resolution for AMPHP.
https://github.com/danog/dns-over-https
Last synced: 4 months ago
JSON representation
Async DNS-over-HTTPS resolution for AMPHP.
- Host: GitHub
- URL: https://github.com/danog/dns-over-https
- Owner: danog
- License: mit
- Created: 2019-06-11T17:58:51.000Z (about 7 years ago)
- Default Branch: v1
- Last Pushed: 2024-12-02T16:42:59.000Z (over 1 year ago)
- Last Synced: 2025-09-23T01:48:48.370Z (10 months ago)
- Language: PHP
- Homepage:
- Size: 143 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-amphp - danog/dns-over-https - Async DNS-over-HTTPS resolution (DNS)
README
# dns

`danog/dns-over-https` provides asynchronous and secure DNS-over-HTTPS name resolution for [Amp](https://github.com/amphp/amp).
Supports [RFC 8484](https://tools.ietf.org/html/rfc8484) POST and GET syntaxes as well as [Google's proprietary JSON DNS format](https://developers.google.com/speed/public-dns/docs/dns-over-https).
Supports passing custom headers for [domain fronting](https://en.wikipedia.org/wiki/Domain_fronting) with google DNS.
## Installation
```bash
composer require danog/dns-over-https
```
## Example
```php
Amp\Dns\resolve("google.com", DnsRecord::A));
$googleIpv6 = \Amp\async(fn () => Amp\Dns\resolve("google.com", DnsRecord::AAAA));
$firstGoogleResult = awaitFirst([$googleIpv4, $googleIpv6]);
pretty_print_records("google.com", $firstGoogleResult);
$combinedGoogleResult = Amp\Dns\resolve("google.com");
pretty_print_records("google.com", $combinedGoogleResult);
$googleMx = Amp\Dns\query("google.com", DnsRecord::MX);
pretty_print_records("google.com", $googleMx);
$firstGoogleResult = awaitFirst([$googleIpv4, $googleIpv6]);
pretty_print_records("google.com", $firstGoogleResult);
$combinedGoogleResult = Amp\Dns\resolve("google.com");
pretty_print_records("google.com", $combinedGoogleResult);
$googleMx = Amp\Dns\query("google.com", DnsRecord::MX);
pretty_print_records("google.com", $googleMx);
```