summaryrefslogtreecommitdiff
path: root/contrib/python/examples/python3/ldns-mx2.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/examples/python3/ldns-mx2.py')
-rwxr-xr-xcontrib/python/examples/python3/ldns-mx2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/python/examples/python3/ldns-mx2.py b/contrib/python/examples/python3/ldns-mx2.py
new file mode 100755
index 0000000..9c8b103
--- /dev/null
+++ b/contrib/python/examples/python3/ldns-mx2.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+#
+# MX is a small program that prints out the mx records for a particular domain
+#
+import ldns
+
+resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+
+pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN)
+if (pkt) and (pkt.answer()):
+
+ for rr in pkt.answer().rrs():
+ if (rr.get_type() != ldns.LDNS_RR_TYPE_MX):
+ continue
+
+ rdf = rr.owner()
+ print(rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ", end=" ")
+ print(" ".join(str(rdf) for rdf in rr.rdfs()))
+