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

new_from_integer does not work properly for IPv6 integer strings #13

Open
oschwald opened this issue Apr 15, 2015 · 2 comments
Open

new_from_integer does not work properly for IPv6 integer strings #13

oschwald opened this issue Apr 15, 2015 · 2 comments
Labels

Comments

@oschwald
Copy link
Member

Net::Works::Address->new_from_integer(integer => '42540766416916187176308156905784606720') returns the address for 255.255.255.255 rather than 2001:db8:1234::

@autarch
Copy link
Contributor

autarch commented Apr 15, 2015

We discussed a few possible fixes in chat:

  • Make the passed value a uint128() and then check if it's in the IPv4 or IPv6 range - we still need need to make sure it's a valid uint128 - the uint128() sub appears to return 0 on an invalid number, so we can check the uint128()'d number against the original string version for equality. If they're not equal it's not valid.
  • Require an explicit version param

Either way, the current code's method of determining whether something is an IPv4 or IPv6 number is not very smart.

@oschwald
Copy link
Member Author

@2shortplanks ran into a related problem with trying to pass in a Math::UInt128 integer for an IPv4 network, causing much confusion. Either of these solutions would also fix that issue.

@oschwald oschwald added the bug label Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants