Skip to content

Commit

Permalink
Fix from getting "ValueError: '{IP}\n' does not appear to be an IPv4 …
Browse files Browse the repository at this point in the history
…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()".
  • Loading branch information
Kryvochyi authored Sep 19, 2024
1 parent 5e2dcc0 commit ff78512
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions porkbun_ddns/porkbun_ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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()))
Expand Down

0 comments on commit ff78512

Please sign in to comment.