spf-discuss
[Top] [All Lists]

Re: [spf-discuss] DNS Packages

2006-05-20 11:54:03
On Sat, 20 May 2006, Scott Kitterman wrote:

From a production perspective, the size of the library is potentially a 
concern.  Twisted also has a DNS library.  If I had infinite free time I'd 
make pySPF library independent, but...

I have already isolated the pyspf DNS interface to the single 
DNSLookup function.  That is all that needs to be implemented to
use another DNS library.  We could create a package, and have
plugins that implement DNSLookup. 

Here is the entire pydns interface:

import DNS      # http://pydns.sourceforge.net

if not hasattr(DNS.Type,'SPF'):
  # patch in type99 support
  DNS.Type.SPF = 99
  DNS.Type.typemap[99] = 'SPF'
  DNS.Lib.RRunpacker.getSPFdata = DNS.Lib.RRunpacker.getTXTdata

def DNSLookup(name,qtype):
  try:
    req = DNS.DnsRequest(name, qtype=qtype)
    resp = req.req()
    #resp.show()
    # key k: ('wayforward.net', 'A'), value v
    return [((a['name'], a['typename']), a['data']) for a in resp.answers]
  except DNS.DNSError,x:
    raise TempError,'DNS ' + str(x)

DNS.DiscoverNameServers() # Fails on Mac OS X? Add domain to /etc/resolv.conf

-- 
              Stuart D. Gathman <stuart(_at_)bmsi(_dot_)com>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.

-------
Sender Policy Framework: http://www.openspf.org/
Archives at http://archives.listbox.com/spf-discuss/current/
To unsubscribe, change your address, or temporarily deactivate your 
subscription, 
please go to 
http://v2.listbox.com/member/?listname=spf-discuss(_at_)v2(_dot_)listbox(_dot_)com