summaryrefslogtreecommitdiff
path: root/contrib/python/examples/ldns-mx1.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/examples/ldns-mx1.py')
-rwxr-xr-xcontrib/python/examples/ldns-mx1.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/python/examples/ldns-mx1.py b/contrib/python/examples/ldns-mx1.py
new file mode 100755
index 0000000..3dade1e
--- /dev/null
+++ b/contrib/python/examples/ldns-mx1.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+#
+# MX is a small program that prints out the mx records for a particular domain
+#
+import ldns
+
+dname = ldns.ldns_dname("nic.cz")
+print dname
+
+resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+
+pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN)
+
+if (pkt):
+ mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER)
+ if (mx):
+ mx.sort()
+ print mx