In modules\http.py:
lines 803-808:
try:
self.server_ipv4 = urllib.request.urlopen("https://api.ipify.org").read().decode()
self.server_ipv6 = urllib.request.urlopen("https://api64.ipify.org").read().decode()
except:
self.server_ipv4 = None
self.server_ipv6 = None
And then lines 946-952:
def _censor_ip(self, text: str) -> str:
"""Replaces IPv4 and IPv6 addresses with [CENSORED_IP]."""
if not isinstance(text, str):
return text
text = text.replace(self.server_ipv4, "[CENSORED_IP]")
text = text.replace(self.server_ipv6, "[CENSORED_IP]")
return text
If there's an exception getting the IPv4/IPv6 addresses, they get set to None, which causes the text.replace() to fail when invoking _censor_ip.
Updating the second block by wrapping the text replacements in if statements like this fixes the issue:
def _censor_ip(self, text: str) -> str:
"""Replaces IPv4 and IPv6 addresses with [CENSORED_IP]."""
if not isinstance(text, str):
return text
if self.server_ipv4 is not None:
text = text.replace(self.server_ipv4, "[CENSORED_IP]")
if self.server_ipv6 is not None:
text = text.replace(self.server_ipv6, "[CENSORED_IP]")
return text
In modules\http.py:
lines 803-808:
And then lines 946-952:
If there's an exception getting the IPv4/IPv6 addresses, they get set to None, which causes the text.replace() to fail when invoking _censor_ip.
Updating the second block by wrapping the text replacements in if statements like this fixes the issue: