mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Patch for access to full DNS packet data in unbound python module
from Ondrej Mikle. git-svn-id: file:///svn/unbound/trunk@2643 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
fc52ee5aca
commit
4e92719611
3 changed files with 44 additions and 0 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
16 March 2012: Wouter
|
||||||
|
- Patch for access to full DNS packet data in unbound python module
|
||||||
|
from Ondrej Mikle.
|
||||||
|
|
||||||
9 March 2012: Wouter
|
9 March 2012: Wouter
|
||||||
- Applied line-buffer patch from Augie Schwer to validation.reporter.sh.
|
- Applied line-buffer patch from Augie Schwer to validation.reporter.sh.
|
||||||
|
|
||||||
|
|
|
||||||
35
libunbound/python/examples/dnssec_test.py
Normal file
35
libunbound/python/examples/dnssec_test.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
from unbound import ub_ctx, RR_TYPE_A, RR_TYPE_RRSIG, RR_TYPE_NSEC, RR_TYPE_NSEC3
|
||||||
|
import ldns
|
||||||
|
|
||||||
|
def dnssecParse(domain, rrType=RR_TYPE_A):
|
||||||
|
print "Resolving domain", domain
|
||||||
|
s, r = resolver.resolve(domain)
|
||||||
|
print "status: %s, secure: %s, rcode: %s, havedata: %s, answer_len; %s" % (s, r.secure, r.rcode_str, r.havedata, r.answer_len)
|
||||||
|
|
||||||
|
s, pkt = ldns.ldns_wire2pkt(r.packet)
|
||||||
|
if s != 0:
|
||||||
|
raise RuntimeError("Error parsing DNS packet")
|
||||||
|
|
||||||
|
rrsigs = pkt.rr_list_by_type(RR_TYPE_RRSIG, ldns.LDNS_SECTION_ANSWER)
|
||||||
|
print "RRSIGs from answer:", rrsigs
|
||||||
|
|
||||||
|
rrsigs = pkt.rr_list_by_type(RR_TYPE_RRSIG, ldns.LDNS_SECTION_AUTHORITY)
|
||||||
|
print "RRSIGs from authority:", rrsigs
|
||||||
|
|
||||||
|
nsecs = pkt.rr_list_by_type(RR_TYPE_NSEC, ldns.LDNS_SECTION_AUTHORITY)
|
||||||
|
print "NSECs:", nsecs
|
||||||
|
|
||||||
|
nsec3s = pkt.rr_list_by_type(RR_TYPE_NSEC3, ldns.LDNS_SECTION_AUTHORITY)
|
||||||
|
print "NSEC3s:", nsec3s
|
||||||
|
|
||||||
|
print "---"
|
||||||
|
|
||||||
|
|
||||||
|
resolver = ub_ctx()
|
||||||
|
resolver.add_ta(". IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5")
|
||||||
|
|
||||||
|
dnssecParse("nic.cz")
|
||||||
|
dnssecParse("nonexistent-domain-blablabla.cz")
|
||||||
|
dnssecParse("nonexistent-domain-blablabla.root.cz")
|
||||||
|
|
||||||
|
|
@ -768,6 +768,10 @@ Result: ['74.125.43.147', '74.125.43.99', '74.125.43.103', '74.125.43.104']
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject* _packet() {
|
||||||
|
return PyString_FromStringAndSize($self->answer_packet, $self->answer_len);
|
||||||
|
}
|
||||||
|
|
||||||
%pythoncode %{
|
%pythoncode %{
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -805,6 +809,7 @@ Result: ['74.125.43.147', '74.125.43.99', '74.125.43.103', '74.125.43.104']
|
||||||
return ub_data(self._ub_result_data(self))
|
return ub_data(self._ub_result_data(self))
|
||||||
|
|
||||||
__swig_getmethods__["data"] = _get_data
|
__swig_getmethods__["data"] = _get_data
|
||||||
|
__swig_getmethods__["packet"] = _packet
|
||||||
data = property(_get_data, doc="Returns :class:`ub_data` instance containing various decoding functions or None")
|
data = property(_get_data, doc="Returns :class:`ub_data` instance containing various decoding functions or None")
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue