summaryrefslogtreecommitdiff
path: root/contrib/ldnsx/examples/ldnsx-walk.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ldnsx/examples/ldnsx-walk.py')
-rwxr-xr-xcontrib/ldnsx/examples/ldnsx-walk.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/ldnsx/examples/ldnsx-walk.py b/contrib/ldnsx/examples/ldnsx-walk.py
new file mode 100755
index 0000000..9810939
--- /dev/null
+++ b/contrib/ldnsx/examples/ldnsx-walk.py
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+#
+# Walk a domain that's using NSEC and print in zonefile format.
+
+import sys
+import ldnsx
+
+def walk(domain):
+ res = ldnsx.resolver("193.110.157.136", dnssec=True)
+ pkt = res.query(domain, 666)
+ try:
+ nsec_rr = pkt.authority(rr_type="NSEC")[0]
+ except:
+ print "no NSEC found, domain is not signed or using NSEC3"
+ sys.exit()
+ for rr_type in nsec_rr[5].split(' ')[:-1]:
+ for rr in ldnsx.get_rrs(domain, rr_type):
+ print str(rr)[:-1]
+ next_rec = nsec_rr[4]
+ if (next_rec != domain) and (next_rec[-len(domain):] == domain):
+ walk(next_rec)
+
+walk("xelerance.com")
+