Package SPF :: Module pydns
[hide private]
[frames] | no frames]

Source Code for Module SPF.pydns

 1  import DNS    # http://pydns.sourceforge.net 
 2  import spf 
 3   
 4  if not hasattr(DNS.Type, 'SPF'): 
 5      # patch in type99 support 
 6      DNS.Type.SPF = 99 
 7      DNS.Type.typemap[99] = 'SPF' 
 8      DNS.Lib.RRunpacker.getSPFdata = DNS.Lib.RRunpacker.getTXTdata 
 9   
10 -def DNSLookup(name, qtype, strict=True):
11 try: 12 req = DNS.DnsRequest(name, qtype=qtype) 13 resp = req.req() 14 #resp.show() 15 # key k: ('wayforward.net', 'A'), value v 16 # FIXME: pydns returns AAAA RR as 16 byte binary string, but 17 # A RR as dotted quad. For consistency, this driver should 18 # return both as binary string. 19 return [((a['name'], a['typename']), a['data']) for a in resp.answers] 20 except IOError, x: 21 raise spf.TempError, 'DNS ' + str(x) 22 except DNS.DNSError, x: 23 raise spf.TempError, 'DNS ' + str(x)
24 25 DNS.DiscoverNameServers() # Fails on Mac OS X? Add domain to /etc/resolv.conf 26 27 spf.DNSLookup = DNSLookup 28