Encode package:dns

DNS message encoder. Note: DNS is a client library, and its focus is on sending queries, and receiving replies. Thefore, while this module is reasonably adept at query generation, building a DNS server with this module requires additional work to handle message size limits, correct UDP truncation, proper EDNS negotiation, and so on. Support for server-side DNS is at best rudimentary. For sending queries, in most cases you should be using one of the functions from Lookup and LookupRaw, or lastly, if you want to handle the network reads and writes for yourself (with your own code for UDP retries, TCP fallback, EDNS fallback, ...), then perhaps encodeQuestion (letting DNS do the lookups for you in an async thread is likely much simpler).
Encode a DNSMessage for transmission over UDP. For transmission over TCP encapsulate the result via encodeVC, or use sendVC, which handles this internally. If any ResourceRecord in the message contains incorrectly encoded Domain name ByteStrings, this function may raise a DecodeError.
The encoded DNSMessage has the specified request ID. The default values of the RD, AD, CD and DO flag bits, as well as various EDNS features, can be adjusted via the QueryControls parameter. The caller is responsible for generating the ID via a securely seeded CSPRNG.
Encapsulate an encoded DNSMessage buffer for transmission over a TCP virtual circuit. With TCP the buffer needs to start with an explicit length (the length is implicit with UDP).