From ff785124c0bfc12219388a25affe8ce779e88ad2 Mon Sep 17 00:00:00 2001 From: Kryvochyi <47377764+Kryvochyi@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:49:26 -0400 Subject: [PATCH] Fix from getting "ValueError: '{IP}\n' does not appear to be an IPv4 or IPv6 address" error The script was not working and I was getting the error mentioned in the message. It seemed that the IP strings the script was receiving had new line characters at their ends, strange. Fixed by changing lines 72 and 88 in porkbun_ddns.py from "response.read().decode("utf-8"))" to "response.read().decode("utf-8")).strip()". --- porkbun_ddns/porkbun_ddns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/porkbun_ddns/porkbun_ddns.py b/porkbun_ddns/porkbun_ddns.py index a88b016..7d64481 100644 --- a/porkbun_ddns/porkbun_ddns.py +++ b/porkbun_ddns/porkbun_ddns.py @@ -69,7 +69,7 @@ def get_public_ips(self) -> list: with urllib.request.urlopen(url, timeout=10) as response: if response.getcode() == 200: public_ips.append( - response.read().decode("utf-8")) + response.read().decode("utf-8")).strip() break logger.warning( "Failed to retrieve IPv4 Address from %s! HTTP status code: %s", url, str(response.code())) @@ -85,7 +85,7 @@ def get_public_ips(self) -> list: with urllib.request.urlopen(url, timeout=10) as response: if response.getcode() == 200: public_ips.append( - response.read().decode("utf-8")) + response.read().decode("utf-8")).strip() break logger.warning( "Failed to retrieve IPv6 Address from %s! HTTP status code: %s", url, str(response.code()))