mafintosh / dns-packet

An abstract-encoding compliant module for encoding / decoding DNS packets
MIT License
201 stars 70 forks source link

DoH query id should always be 0 according to RFC 8484 #77

Open TrevinAvery opened 2 years ago

TrevinAvery commented 2 years ago

According to RFC 8484 section 4.1, the id should always be 0 to optimize caching:

In order to maximize HTTP cache friendliness, DoH clients using media formats that include the ID field from the DNS message header, such as "application/dns-message", SHOULD use a DNS ID of 0 in every DNS request. HTTP correlates the request and response, thus eliminating the need for the ID in a media type such as "application/dns-message". The use of a varying DNS ID can cause semantically equivalent DNS queries to be cached separately.

https://github.com/mafintosh/dns-packet/blob/8e6d91c078c9175708bcf13c071d6ffae963a635/examples/doh.js#L20