handle UnicodeDecodeError on non-utf-8 check_website

This commit is contained in:
monosans
2025-03-06 09:57:26 +03:00
parent c9bd28057f
commit 6a6e05e531
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ class Proxy:
self.exit_ip = parse_ipv4(orjson.loads(content)["origin"])
elif settings.check_website_type == CheckWebsiteType.PLAIN_IP:
self.exit_ip = parse_ipv4(
content.decode(response.get_encoding(), errors="replace")
content.decode(response.get_encoding())
)
else:
self.exit_ip = None
+3 -1
View File
@@ -158,8 +158,10 @@ async def _get_check_website_type_and_real_ip(
except orjson.JSONDecodeError:
try:
return CheckWebsiteType.PLAIN_IP, parse_ipv4(
content.decode(response.get_encoding(), errors="replace")
content.decode(response.get_encoding())
)
except UnicodeDecodeError:
_logger.error("Error when decoding check_website response as utf-8")
except ValueError:
pass
else: