本文整理汇总了Python中models.Service.from_ip_only方法的典型用法代码示例。如果您正苦于以下问题:Python Service.from_ip_only方法的具体用法?Python Service.from_ip_only怎么用?Python Service.from_ip_only使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Service
的用法示例。
在下文中一共展示了Service.from_ip_only方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_service
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import from_ip_only [as 别名]
def search_service(self, pkg):
"""For HTTP, a service if not found by conventional method,
the 'host' header can be used to determine destiny URL.
The Service from 'host' header is searched the same way as a DNS cache answered.
"""
service = super().search_service(pkg)
if service:
return service
if hasattr(pkg.http, 'host'):
# When header host is IP addr, create service 'Unknown (IP)'.
# If not, service will have name of the IP
# The name must have info of the IP for the equals btw services
if is_ipaddress(pkg.http.host):
return Service.from_ip_only(pkg.http.host)
else:
name = get_significant_name_from_url(pkg.http.host)
service = self.environment.service_analyzer.find_service_from_absolute_url(
pkg.http.host
) or self.environment.service_analyzer.find_service_from_url(
pkg.http.host) or Service.from_name(name)
service.hosts.add(pkg.http.host)
return service
else:
return None