Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed is_valid_public_ipv4 not working correctly when ipv6 is given as address #2892

Merged
merged 6 commits into from
Jun 2, 2020

Conversation

endes0
Copy link
Contributor

@endes0 endes0 commented Mar 29, 2020

When UPnP gives an ipv6 address to the function is_valid_public_ipv4, instead of return False, it throws an error:

Traceback (most recent call last):
  File "lbry/extras/daemon/component.py", line 63, in _setup
  File "lbry/extras/daemon/component.py", line 55, in _setup
  File "lbry/extras/daemon/components.py", line 493, in start
  File "lbry/extras/daemon/components.py", line 430, in _maintain_redirects
  File "lbry/dht/peer.py", line 39, in is_valid_public_ipv4
  File "ipaddress.py", line 79, in ip_network
  File "ipaddress.py", line 2178, in __init__
ValueError: <redacted ipv6>/32 has host bits set

This is because the checks doesn't stop when parsed_ip.version != 4, but CARRIER_GRADE_NAT_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32")) and IPV4_TO_6_RELAY_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32"))) needs a valid IPv4 address.

@tzarebczan
Copy link
Contributor

Thanks so much for finding this and opening a PR! Can we show you some appreciation?

@endes0
Copy link
Contributor Author

endes0 commented Apr 19, 2020

Just a small fix, I don't want appreciation. Also, sorry for responding late.

@jackrobison jackrobison merged commit 8d079bf into lbryio:master Jun 2, 2020
@eukreign eukreign added area: DHT type: bug Existing functionality is wrong or broken labels Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DHT type: bug Existing functionality is wrong or broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants