'is_localhost()' -> 'host_permitted()'
This commit is contained in:
parent
b9c64b7cf1
commit
f306213cb8
2 changed files with 6 additions and 6 deletions
|
@ -21,8 +21,8 @@ class Module(ModuleManager.BaseModule):
|
|||
url = "http://%s" % url
|
||||
|
||||
hostname = urllib.parse.urlparse(url).hostname
|
||||
if utils.http.is_localhost(hostname):
|
||||
self.log.warn("tried to get title of localhost: %s", [url])
|
||||
if not utils.http.host_permitted(hostname):
|
||||
self.log.warn("Attempted to get forbidden host: %s", [url])
|
||||
return -1, None
|
||||
|
||||
try:
|
||||
|
|
|
@ -287,7 +287,7 @@ def is_ip(addr: str) -> bool:
|
|||
return False
|
||||
return True
|
||||
|
||||
def is_localhost(hostname: str) -> bool:
|
||||
def host_permitted(hostname: str) -> bool:
|
||||
if is_ip(hostname):
|
||||
ips = [ipaddress.ip_address(hostname)]
|
||||
else:
|
||||
|
@ -300,7 +300,7 @@ def is_localhost(hostname: str) -> bool:
|
|||
)+links.get(netifaces.AF_INET6, []):
|
||||
address = ipaddress.ip_address(link["addr"].split("%", 1)[0])
|
||||
if address in ips:
|
||||
return True
|
||||
return False
|
||||
for ip in ips:
|
||||
if ip.version == 6 and ip.ipv4_mapped:
|
||||
ip = ip.ipv4_mapped
|
||||
|
@ -309,6 +309,6 @@ def is_localhost(hostname: str) -> bool:
|
|||
ip.is_link_local or
|
||||
ip.is_multicast or
|
||||
ip.is_private):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue