vterron / public-ip

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

ValueError: tie between ipv6 and ipv4 #1

Closed choesy closed 2 months ago

choesy commented 1 year ago

I get an error if I run the public_ip.get() function multiple times in a row:

ValueError: tie between ipv6 and ipv4 among the responses ({first_votes} occurrences each)

the problem is that it is returning ipv6 ips. I only want ipv4. Can this be fixed?

choesy commented 1 year ago

Found out that https://ifconfig.co/ip and https://icanhazip.com/ return ipv6. So i am removing them from the list in my script.

vterron commented 1 year ago

Thanks for reporting this. However, I cannot reproduce this error: both sides show an IPv4 for me. We'd need to determine first why you're seeing different formats being returned by these websites.

vterron commented 1 year ago

Furthermore: it those two sites are returning IPv6, that would still leave four votes for the IPv4. A tie implies that at least two of the requests to the other servers failed.

choesy commented 1 year ago

I discovered that the problem occurred in a house with a router where ipv6 was supported. In that case, I guess the two links I mentioned in my first comment return the ipv6 instead of ipv4. Besides that, I do not know why, but I get three different ips when I run the .get() function successively. First I get an IP that looks like xxx.xxx.0.xxx, then I get xxx.xxx.100.xxx (0 changed to 100, rest of the IP is same), and then after more tries, the error that includes ipv6 in the message occurs (the one in the issue). Maybe the error is specific to where I live. Because now on public wifi, the .get() function runs just fine.