vterron / public-ip

A Python function to get your public IP address
MIT License
13 stars 6 forks source link

fix error comparing IPv6 and IPv4 #7

Open phanhai27 opened 1 month ago

phanhai27 commented 1 month ago

I get the following error: path\site-packages\public_ip\_ip.py", line 74, in get raise ValueError(ValueError: tie between IPv6 and IPv4 among the responses ({first_votes} occurrences each)

I fixed it for IPv4 only like this:

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