summaryrefslogtreecommitdiff
path: root/contrib/ldnsx/examples/ldnsx-axfr.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ldnsx/examples/ldnsx-axfr.py')
-rw-r--r--contrib/ldnsx/examples/ldnsx-axfr.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/contrib/ldnsx/examples/ldnsx-axfr.py b/contrib/ldnsx/examples/ldnsx-axfr.py
new file mode 100644
index 0000000..224bb57
--- /dev/null
+++ b/contrib/ldnsx/examples/ldnsx-axfr.py
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+#
+# AXFR client with IDN (Internationalized Domain Names) support
+#
+
+import ldns
+import encodings.idna
+
+def utf2name(name):
+ return '.'.join([encodings.idna.ToASCII(a) for a in name.split('.')])
+def name2utf(name):
+ return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')])
+
+resolver = ldnsx.resolver("zone.nic.cz")
+
+#Print results
+for rr in resolver.AXFR(utf2name(u"háčkyčárky.cz")):
+ # rdf = rr.owner()
+ # if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME):
+ # print "RDF owner: type=",rr.type(),"data=",name2utf(rr.owner())
+ # else:
+ # print "RDF owner: type=",rdf.get_type_str(),"data=",str(rdf)
+ # print " RR type=", rr.get_type_str()," ttl=",rr.ttl()
+ # for rdf in rr.rdfs():
+ # if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME):
+ # print " RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))
+ # else:
+ # print " RDF: type=",rdf.get_type_str(),"data=",str(rdf)
+