What I am trying to do is make a dns query using the dnspython
library and get the response in the dns wire format or a string of bytes. Right not the dns.resolver.resolve()
method is returning a <class 'dns.resolver.Answer'>
Is there a way I can get the dns response in the wire format or convert my dns.resolver.Answer
type to wire format?
You can convert the message to the compressed DNS wire format by using something like
my_answer.response.to_wire()
if that's what you need.
From the docs:
response
: Adns.message.Message
, the response message.
and also:
to_wire(origin=None, max_size=0, multi=False, tsig_ctx=None, **kw)
Return a string containing the message in DNS compressed wire format.