本文整理匯總了Python中twisted.names.dns.PTR屬性的典型用法代碼示例。如果您正苦於以下問題:Python dns.PTR屬性的具體用法?Python dns.PTR怎麽用?Python dns.PTR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類twisted.names.dns
的用法示例。
在下文中一共展示了dns.PTR屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: lookupPointer
# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import PTR [as 別名]
def lookupPointer(self, name, timeout=None):
return self._lookup(name, dns.IN, dns.PTR, timeout)
示例2: test_lookupPointer
# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import PTR [as 別名]
def test_lookupPointer(self):
"""
See L{test_lookupAddress}
"""
d = client.lookupPointer(self.hostname)
d.addCallback(self.checkResult, dns.PTR)
return d
示例3: lookupPointer
# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import PTR [as 別名]
def lookupPointer(self, name, timeout = None):
"""
@see: twisted.names.client.lookupPointer
"""
return self._lookup(name, dns.IN, dns.PTR, timeout)
示例4: lookupPointer
# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import PTR [as 別名]
def lookupPointer(self, name, timeout = None):
return self._lookup(name, dns.IN, dns.PTR, timeout)
示例5: ipToHostname
# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import PTR [as 別名]
def ipToHostname(self, ad):
# Try to determine the hostname of the provided address.
# Returns a deferred, which will callback but never errback.
# If successful, the callback argument is a hostname string,
# None otherwise.
revip = '.'.join(str(ord(o)) for o in ad.getRawIP()[::-1])
host = "%s.in-addr.arpa" % revip
def cb(result):
try:
hostname = result[0][0].payload.name.name
if not hostname:
return None
except:
return None
return hostname
def eb(failure):
return None
d = self.resolver.query(dns.Query(host, type=dns.PTR))
d.addCallbacks(cb, eb)
return d
# Simplified lookup interface