本文整理汇总了Python中dns.resolver.Resolver.use_edns方法的典型用法代码示例。如果您正苦于以下问题:Python Resolver.use_edns方法的具体用法?Python Resolver.use_edns怎么用?Python Resolver.use_edns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dns.resolver.Resolver
的用法示例。
在下文中一共展示了Resolver.use_edns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CustomResolver
# 需要导入模块: from dns.resolver import Resolver [as 别名]
# 或者: from dns.resolver.Resolver import use_edns [as 别名]
class CustomResolver(object):
def __init__(self):
self.resolver = Resolver()
self.resolver.use_edns(0, 0, 4096)
self.resolver.set_flags(flags.AD + flags.RD)
self.degraded = Resolver()
self.degraded.use_edns(0, 0, 4096)
self.degraded.set_flags(flags.CD + flags.RD)
def query(self, fqdn, rdatatype=rdt.A, degraded=False):
log.debug('Query %s %s', fqdn, rdatatype)
try:
return self.resolver.query(fqdn, rdatatype)
except NoNameservers:
if degraded:
return self.degraded.query(fqdn, rdatatype)
raise
except NXDOMAIN:
if degraded:
return self.degraded.query(fqdn, rdatatype)
return None
def srv(self, name, domainname, proto='tcp'):
fqdn = '_{}._{}.{}'.format(name, proto, domainname)
return self.query(fqdn, rdt.SRV)
def tlsa(self, hostname, port, proto='tcp'):
fqdn = '_{}._{}.{}'.format(port, proto, hostname)
return self.query(fqdn, rdt.TLSA)
def mx(self, domainname):
return self.query(domainname, rdt.MX)
示例2: get_nsset
# 需要导入模块: from dns.resolver import Resolver [as 别名]
# 或者: from dns.resolver.Resolver import use_edns [as 别名]
def get_nsset(zone, server, bufsize):
nsset = { 'RRSIG' : False }
resolver = Resolver()
resolver.nameservers = [server]
resolver.use_edns(edns=True, ednsflags=dns.flags.DO, payload=bufsize)
response = resolver.query(zone, 'NS', dns.rdataclass.IN, True).response
for answer in response.answer:
for ans in answer.items:
if ans.rdtype == dns.rdatatype.NS:
nsset[ans.to_text()] = { 'A' : None, 'AAAA' : None, 'RRSIG' : None }
elif ans.rdtype == dns.rdatatype.RRSIG:
nsset['RRSIG'] = True
return nsset