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

Invalid IPv6 handling #98

Open
traxanos opened this issue Dec 4, 2017 · 1 comment
Open

Invalid IPv6 handling #98

traxanos opened this issue Dec 4, 2017 · 1 comment

Comments

@traxanos
Copy link

traxanos commented Dec 4, 2017

Hi guys,

i have found a bug.

It is allowed to use dot notation in ipv6. The following address is not a mapped ipv6 address.

IPAddress.parse('abcd:9234::1.2.3.4/96').to_string

I got a wrong output
=> ::ffff:9.2.3.4/96

But the correct output must be:
=> abcd:9234::102:304/96

Same problem here:

IPAddress.parse('::1.2.3.4/120').to_string
=> "::ffff:1.2.3.4/120"

Correct output is
=> ::102:304/120

Only
IPAddress.parse('::ffff:1.2.3.4/120') is a mapped ipv6 value!
Only here it is allowed to handle it as an Mapped IPv6 Object with the following output:
=> "::ffff:1.2.3.4/120"

@traxanos
Copy link
Author

traxanos commented Dec 4, 2017

I have create a workaround for me

if value =~ /:/
converted = value.gsub(/([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})/) { |a| IPAddr.new("::#{a}").to_string.slice(-9, 9) }
else
converted = value
end
IPAddress.parse(converted)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant