本文整理匯總了Python中scapy.as_resolvers.AS_resolver_riswhois._resolve_one方法的典型用法代碼示例。如果您正苦於以下問題:Python AS_resolver_riswhois._resolve_one方法的具體用法?Python AS_resolver_riswhois._resolve_one怎麽用?Python AS_resolver_riswhois._resolve_one使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scapy.as_resolvers.AS_resolver_riswhois
的用法示例。
在下文中一共展示了AS_resolver_riswhois._resolve_one方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _resolve_one
# 需要導入模塊: from scapy.as_resolvers import AS_resolver_riswhois [as 別名]
# 或者: from scapy.as_resolvers.AS_resolver_riswhois import _resolve_one [as 別名]
def _resolve_one(self, ip):
"""
overloaded version to provide a Whois resolution on the
embedded IPv4 address if the address is 6to4 or Teredo.
Otherwise, the native IPv6 address is passed.
"""
if in6_isaddr6to4(ip): # for 6to4, use embedded @
tmp = inet_pton(socket.AF_INET6, ip)
addr = inet_ntop(socket.AF_INET, tmp[2:6])
elif in6_isaddrTeredo(ip): # for Teredo, use mapped address
addr = teredoAddrExtractInfo(ip)[2]
else:
addr = ip
_, asn, desc = AS_resolver_riswhois._resolve_one(self, addr)
return ip,asn,desc
示例2: _resolve_one
# 需要導入模塊: from scapy.as_resolvers import AS_resolver_riswhois [as 別名]
# 或者: from scapy.as_resolvers.AS_resolver_riswhois import _resolve_one [as 別名]
def _resolve_one(self, ip):
"""
overloaded version to provide a Whois resolution on the
embedded IPv4 address if the address is 6to4 or Teredo.
Otherwise, the native IPv6 address is passed.
"""
if in6_isaddr6to4(ip): # for 6to4, use embedded @
tmp = inet_pton(socket.AF_INET6, ip)
addr = inet_ntop(socket.AF_INET, tmp[2:6])
elif in6_isaddrTeredo(ip): # for Teredo, use mapped address
addr = teredoAddrExtractInfo(ip)[2]
else:
addr = ip
_, asn, desc = AS_resolver_riswhois._resolve_one(self, addr)
if asn.startswith("AS"):
try:
asn = int(asn[2:])
except ValueError:
pass
return ip, asn, desc