2000-02-26 10:24:46 +00:00
|
|
|
# $Id$
|
|
|
|
|
# routines for lazy people.
|
|
|
|
|
import Base
|
|
|
|
|
|
|
|
|
|
def revlookup(name):
|
|
|
|
|
"convenience routine for doing a reverse lookup of an address"
|
2001-08-08 20:51:42 +00:00
|
|
|
a = name.split('.')
|
2000-02-26 10:24:46 +00:00
|
|
|
a.reverse()
|
2001-08-08 20:51:42 +00:00
|
|
|
b = '.'.join(a)+'.in-addr.arpa'
|
2000-02-26 10:24:46 +00:00
|
|
|
# this will only return one of any records returned.
|
|
|
|
|
return Base.DnsRequest(b, qtype = 'ptr').req().answers[0]['data']
|
|
|
|
|
|
2001-10-17 17:03:08 +00:00
|
|
|
def mxlookup(name, protocol="tcp"):
|
2000-02-26 10:24:46 +00:00
|
|
|
"""
|
|
|
|
|
convenience routine for doing an MX lookup of a name. returns a
|
|
|
|
|
sorted list of (preference, mail exchanger) records
|
|
|
|
|
"""
|
2001-08-23 14:06:46 +00:00
|
|
|
a = Base.DnsRequest(name, qtype='mx', protocol=protocol).req().answers
|
2000-02-26 10:24:46 +00:00
|
|
|
l = map(lambda x:x['data'], a)
|
|
|
|
|
l.sort()
|
|
|
|
|
return l
|
|
|
|
|
|