Example: Querying HTTPS DNS records (type 65) with ReactPHP DNS #619
masakielastic
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While experimenting with HTTP/3 support, I noticed that modern websites sometimes publish DNS records that advertise which HTTP protocols they support.
These are called HTTPS DNS Resource Records (type 65).
They can contain information such as:
supported protocols (
h2,h3)alternative service endpoints
hints for modern clients
For example,
google.compublishes the following record.Checking with dig
You can see this using dig:
Example output:
This simply means:
h2)h3)Modern clients may use this information when deciding how to connect.
Checking the same record in PHP
PHP can retrieve this record using
dns_get_record().Example:
Typical output:
ReactPHP example
I created a small ReactPHP example that performs the same kind of lookup using ReactPHP DNS and prints the advertised protocols.
Gist:
https://gist.github.com/masakielastic/ff79ec78e844678f46529ff8edb0bbef
The example shows how to:
h2andh3Beta Was this translation helpful? Give feedback.
All reactions