[Unbound-users] Accessing the values of returning queries from a python module

W.C.A. Wijngaards wouter at nlnetlabs.nl
Thu Mar 1 09:10:25 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Gerald,

On 02/20/2012 03:54 PM, Gerald McNulty wrote:
> Hello,
> 
> Is there an easy way to access the values of A or CNAME or NS
> records from a python module? I'd like to do something with the IP
> address in the A record but after digging down into 
> qstate.return_msg.rep.rrsets[i].entry.data.rr_data[j], I can't see
> how to turn that into an IP address (for RR_TYPE_A) or hostname
> (for RR_TYPE_CNAME).
> 
> Any help would be much appreciated.

You know that the IP address in the RR TYPE A is the plain 4 octets
that make up the IPv4 address?  You can convert it to string with
various system routines.  The CNAME data is a hostname in DNS
wireformat.  That you can also read in, but you need DNS routines.
(the formats are defined in RFC1034).

ldns, has a python library API.  That can read DNS records, and then
you can manipulate them, and convert them.  That also works for other
record types (DNSKEY and DS and so on).  http://nlnetlabs.nl/projects/ldns

Best regards,
   Wouter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPTzz9AAoJEJ9vHC1+BF+N8wYQAINO/ni6qiGK/khFuTwx0++x
TC4E6ubFcLeis2/dJ5c2ceIckHASRU/GKku95vFc0GrkpYYCsUS/oxVg82f+4VRF
YVXCUKaGrvm6nVMuxEKFMrEd8M3njeWLDJKnCkVUwNCCyiGURPTNDT+5+cQWzXHc
j3xjxm4W/9ewjY638qw+I/a3Uj5L8iajT2HuzM1Lp5Qa2nF867wms1X5DKWmpw09
o5sXQgBLhhgPIuMWV0D1WuCVCVcG1TKoQsDpDeFriaXMYIACgFxfqJa2eSbRBlFm
6ZQY6G2e50Q6TDAUc9OlqHvnI01OA4N6sixvgTIX28n4ZLHyCR1Uh+S8iQP4O8Ir
uttt387XZFpZLI62MXz7wEdyPung9Vdz4PYs9tqAWlySr3XdN+lXw52ozD8V/Z0f
oTZW0INpcLAizKWbgKWSRbnfwhZsRFZg3AzhLmtFpwV0Z5LVr9hz26NimY7BrgPi
6XiPkUwagsTUsVvG9QRwUUaquc0UeQi+NAh4KT9j+F7/9P+Ua2rvk5Cpy74ReclK
x5epH5NjUaYq8uN8gFyH9OmVJcDCRo86ZI25ISjjJDZlnE+0vgl6g/v2GIoYA/YT
hsn6Y557Z1koj/9hE7Kk+HIBPhyOjJa7HdB6JPBdd6ZV9yv0wFoLZx4B53Pm7xeF
ZkCpTOOXf6lPffwdfzHY
=Swtn
-----END PGP SIGNATURE-----



More information about the Unbound-users mailing list