本文整理汇总了Python中Base.DnsRequest方法的典型用法代码示例。如果您正苦于以下问题:Python Base.DnsRequest方法的具体用法?Python Base.DnsRequest怎么用?Python Base.DnsRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base.DnsRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: revlookup
# 需要导入模块: import Base [as 别名]
# 或者: from Base import DnsRequest [as 别名]
def revlookup(name):
"convenience routine for doing a reverse lookup of an address"
if Base.defaults['server'] == []:
Base.DiscoverNameServers()
a = string.split(name, '.')
a.reverse()
b = string.join(a, '.') + '.in-addr.arpa'
# this will only return one of any records returned.
return Base.DnsRequest(b, qtype='ptr').req().answers[0]['data']
示例2: mxlookup
# 需要导入模块: import Base [as 别名]
# 或者: from Base import DnsRequest [as 别名]
def mxlookup(name):
"""
convenience routine for doing an MX lookup of a name. returns a
sorted list of (preference, mail exchanger) records
"""
if Base.defaults['server'] == []:
Base.DiscoverNameServers()
a = Base.DnsRequest(name, qtype='mx').req().answers
l = sorted(map(lambda x: x['data'], a))
return l
#
# $Log: lazy.py,v $
# Revision 1.5.2.1 2007/05/22 20:23:38 customdesigned
# Lazy call to DiscoverNameServers
#
# Revision 1.5 2002/05/06 06:14:38 anthonybaxter
# reformat, move import to top of file.
#
# Revision 1.4 2002/03/19 12:41:33 anthonybaxter
# tabnannied and reindented everything. 4 space indent, no tabs.
# yay.
#
# Revision 1.3 2001/08/09 09:08:55 anthonybaxter
# added identifying header to top of each file
#
# Revision 1.2 2001/07/19 06:57:07 anthony
# cvs keywords added
#
#
示例3: dnslookup
# 需要导入模块: import Base [as 别名]
# 或者: from Base import DnsRequest [as 别名]
def dnslookup(name,qtype):
"convenience routine to return just answer data for any query type"
if Base.defaults['server'] == []: Base.DiscoverNameServers()
result = Base.DnsRequest(name=name, qtype=qtype).req()
if result.header['status'] != 'NOERROR':
raise ServerError("DNS query status: %s" % result.header['status'],
result.header['rcode'])
elif len(result.answers) == 0 and Base.defaults['server_rotate']:
# check with next DNS server
result = Base.DnsRequest(name=name, qtype=qtype).req()
if result.header['status'] != 'NOERROR':
raise ServerError("DNS query status: %s" % result.header['status'],
result.header['rcode'])
return [x['data'] for x in result.answers]
示例4: revlookup
# 需要导入模块: import Base [as 别名]
# 或者: from Base import DnsRequest [as 别名]
def revlookup(name):
"convenience routine for doing a reverse lookup of an address"
if Base.defaults['server'] == []: Base.DiscoverNameServers()
a = string.split(name, '.')
a.reverse()
b = string.join(a, '.')+'.in-addr.arpa'
# this will only return one of any records returned.
return Base.DnsRequest(b, qtype = 'ptr').req().answers[0]['data']
示例5: mxlookup
# 需要导入模块: import Base [as 别名]
# 或者: from Base import DnsRequest [as 别名]
def mxlookup(name):
"""
convenience routine for doing an MX lookup of a name. returns a
sorted list of (preference, mail exchanger) records
"""
if Base.defaults['server'] == []: Base.DiscoverNameServers()
a = Base.DnsRequest(name, qtype = 'mx').req().answers
l = map(lambda x:x['data'], a)
l.sort()
return l
#
# $Log: lazy.py,v $
# Revision 1.5.2.1 2007/05/22 20:23:38 customdesigned
# Lazy call to DiscoverNameServers
#
# Revision 1.5 2002/05/06 06:14:38 anthonybaxter
# reformat, move import to top of file.
#
# Revision 1.4 2002/03/19 12:41:33 anthonybaxter
# tabnannied and reindented everything. 4 space indent, no tabs.
# yay.
#
# Revision 1.3 2001/08/09 09:08:55 anthonybaxter
# added identifying header to top of each file
#
# Revision 1.2 2001/07/19 06:57:07 anthony
# cvs keywords added
#
#