本文整理汇总了Python中twisted.names.dns.AAAA属性的典型用法代码示例。如果您正苦于以下问题:Python dns.AAAA属性的具体用法?Python dns.AAAA怎么用?Python dns.AAAA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类twisted.names.dns
的用法示例。
在下文中一共展示了dns.AAAA属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_messageReceivedLogging2
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def test_messageReceivedLogging2(self):
"""
L{server.DNSServerFactory.messageReceived} logs the repr of all queries
in the message if C{verbose} is set to C{2}.
"""
m = dns.Message()
m.addQuery(name='example.com', type=dns.MX)
m.addQuery(name='example.com', type=dns.AAAA)
f = NoResponseDNSServerFactory(verbose=2)
assertLogMessage(
self,
["<Query example.com MX IN> "
"<Query example.com AAAA IN> query from ('192.0.2.100', 53)"],
f.messageReceived,
message=m, proto=None, address=('192.0.2.100', 53))
示例2: lookupIPV6Address
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def lookupIPV6Address(self, name, timeout=None):
return self._lookup(name, dns.IN, dns.AAAA, timeout)
示例3: extractRecord
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def extractRecord(resolver, name, answers, level=10):
if not level:
return None
if hasattr(socket, 'inet_ntop'):
for r in answers:
if r.name == name and r.type == dns.A6:
return socket.inet_ntop(socket.AF_INET6, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.AAAA:
return socket.inet_ntop(socket.AF_INET6, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.A:
return socket.inet_ntop(socket.AF_INET, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.CNAME:
result = extractRecord(
resolver, r.payload.name, answers, level - 1)
if not result:
return resolver.getHostByName(
str(r.payload.name), effort=level - 1)
return result
# No answers, but maybe there's a hint at who we should be asking about
# this
for r in answers:
if r.type == dns.NS:
from twisted.names import client
r = client.Resolver(servers=[(str(r.payload.name), dns.PORT)])
return r.lookupAddress(str(name)
).addCallback(
lambda records: extractRecord(
r, name,
records[_ANS] + records[_AUTH] + records[_ADD],
level - 1))
示例4: test_messageReceivedLogging1
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def test_messageReceivedLogging1(self):
"""
L{server.DNSServerFactory.messageReceived} logs the query types of all
queries in the message if C{verbose} is set to C{1}.
"""
m = dns.Message()
m.addQuery(name='example.com', type=dns.MX)
m.addQuery(name='example.com', type=dns.AAAA)
f = NoResponseDNSServerFactory(verbose=1)
assertLogMessage(
self,
["MX AAAA query from ('192.0.2.100', 53)"],
f.messageReceived,
message=m, proto=None, address=('192.0.2.100', 53))
示例5: test_lookupIPV6Address
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def test_lookupIPV6Address(self):
"""
See L{test_lookupAddress}
"""
d = client.lookupIPV6Address(self.hostname)
d.addCallback(self.checkResult, dns.AAAA)
return d
示例6: lookupIPV6Address
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def lookupIPV6Address(self, name, timeout = None):
"""
@see: twisted.names.client.lookupIPV6Address
"""
return self._lookup(name, dns.IN, dns.AAAA, timeout)
示例7: extractRecord
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def extractRecord(resolver, name, answers, level=10):
if not level:
return None
if hasattr(socket, 'inet_ntop'):
for r in answers:
if r.name == name and r.type == dns.A6:
return socket.inet_ntop(socket.AF_INET6, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.AAAA:
return socket.inet_ntop(socket.AF_INET6, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.A:
return socket.inet_ntop(socket.AF_INET, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.CNAME:
result = extractRecord(
resolver, r.payload.name, answers, level - 1)
if not result:
return resolver.getHostByName(
str(r.payload.name), effort=level - 1)
return result
# No answers, but maybe there's a hint at who we should be asking about
# this
for r in answers:
if r.type == dns.NS:
from twisted.names import client
r = client.Resolver(servers=[(str(r.payload.name), dns.PORT)])
return r.lookupAddress(str(name)
).addCallback(
lambda (ans, auth, add):
extractRecord(r, name, ans + auth + add, level - 1))
示例8: lookupIPV6Address
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def lookupIPV6Address(self, name, timeout = None):
return self._lookup(name, dns.IN, dns.AAAA, timeout)
示例9: extractRecord
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def extractRecord(resolver, name, answers, level = 10):
if not level:
return None
if hasattr(socket, 'inet_ntop'):
for r in answers:
if r.name == name and r.type == dns.A6:
return socket.inet_ntop(socket.AF_INET6, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.AAAA:
return socket.inet_ntop(socket.AF_INET6, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.A:
return socket.inet_ntop(socket.AF_INET, r.payload.address)
for r in answers:
if r.name == name and r.type == dns.CNAME:
result = extractRecord(resolver, r.payload.name, answers, level - 1)
if not result:
return resolver.getHostByName(str(r.payload.name), effort=level-1)
return result
# No answers, but maybe there's a hint at who we should be asking about this
for r in answers:
if r.type == dns.NS:
from twisted.names import client
r = client.Resolver(servers=[(str(r.payload.name), dns.PORT)])
return r.lookupAddress(str(name)
).addCallback(lambda (ans, auth, add): extractRecord(r, name, ans + auth + add, level - 1)
).addBoth(lambda passthrough: (r.protocol.transport.stopListening(), passthrough)[1])
示例10: _aaaaRecords
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def _aaaaRecords(self, name, address):
return tuple([dns.RRHeader(name, dns.AAAA, dns.IN, self.minTTL,
dns.Record_AAAA(address, self.minTTL))])
示例11: lookupIPV6Address
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import AAAA [as 别名]
def lookupIPV6Address(self, name, timeout=None):
r = self._matchAddress(name, self._aaaaRecords)
if r:
return self._respond(name, r)
else:
return self._lookup(name, dns.IN, dns.AAAA, timeout)