example8-1.py revision 238106
1#!/usr/bin/python 2# vim:fileencoding=utf-8 3# 4# Lookup for MX and NS records 5# 6import unbound 7 8ctx = unbound.ub_ctx() 9ctx.resolvconf("/etc/resolv.conf") 10 11status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_MX, unbound.RR_CLASS_IN) 12if status == 0 and result.havedata: 13 print "Result:" 14 print " raw data:", result.data 15 for k in result.data.mx_list: 16 print " priority:%d address:%s" % k 17 18status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_A, unbound.RR_CLASS_IN) 19if status == 0 and result.havedata: 20 print "Result:" 21 print " raw data:", result.data 22 for k in result.data.address_list: 23 print " address:%s" % k 24 25status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_NS, unbound.RR_CLASS_IN) 26if status == 0 and result.havedata: 27 print "Result:" 28 print " raw data:", result.data 29 for k in result.data.domain_list: 30 print " host: %s" % k 31 32