diff options
| -rw-r--r-- | modules/title.py | 4 | ||||
| -rw-r--r-- | src/utils/http.py | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/modules/title.py b/modules/title.py index ab4c3b45..614d0bbf 100644 --- a/modules/title.py +++ b/modules/title.py @@ -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: diff --git a/src/utils/http.py b/src/utils/http.py index 00066033..4df01dfc 100644 --- a/src/utils/http.py +++ b/src/utils/http.py @@ -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 False + return True |
