mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-10 01:21:00 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@301 e7d03fd6-7b0d-0410-9947-9c21f3af8025
22 lines
656 B
Python
22 lines
656 B
Python
# $Id$
|
|
# routines for lazy people.
|
|
import Base
|
|
|
|
def revlookup(name):
|
|
"convenience routine for doing a reverse lookup of an address"
|
|
a = name.split('.')
|
|
a.reverse()
|
|
b = '.'.join(a)+'.in-addr.arpa'
|
|
# this will only return one of any records returned.
|
|
return Base.DnsRequest(b, qtype = 'ptr').req().answers[0]['data']
|
|
|
|
def mxlookup(name, protocol="tcp"):
|
|
"""
|
|
convenience routine for doing an MX lookup of a name. returns a
|
|
sorted list of (preference, mail exchanger) records
|
|
"""
|
|
a = Base.DnsRequest(name, qtype='mx', protocol=protocol).req().answers
|
|
l = map(lambda x:x['data'], a)
|
|
l.sort()
|
|
return l
|
|
|