Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/public_ip/_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import threading
import typing
from queue import Queue
from ipaddress import ip_address, IPv4Address

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -56,7 +57,10 @@ def get(nurls: int = len(URLS), timeout: float = 1) -> str:

ips = []
while not queue.empty():
ips.append(queue.get())
# Fix error comparing IPv6 and IPv4 (if first_votes == second_votes)
ipx = queue.get()
if type(ip_address(ipx)) is IPv4Address:
ips.append(ipx)

if not ips:
raise IOError("all server queries failed")
Expand Down