node-maxmind-db icon indicating copy to clipboard operation
node-maxmind-db copied to clipboard

IPParser doesn't handle IPv4-Mapped IPv6 Address

Open brbaker opened this issue 10 years ago • 4 comments

The code doesn't properly handle IPv4 addresses that are mapped into the IPv6 address space. http://tools.ietf.org/html/rfc4291#section-2.5.5.2

Code currently passes off to the IPv4 parser when it finds a '.', however the IPv4 parser doesn't handle it. Probably best to extract the IPv4 mapped address and then pass it into the ipv4 parser.

brbaker avatar Jun 12 '15 17:06 brbaker

@brbaker I have a pull request pending usage of 'ip-address' module. I think this handles all the IPv4 mapped types. I would like you to review and see if this fits the bill and we can make the switch easily going forward.

ip-address: https://www.npmjs.com/package/ip-address

Pull Request: https://github.com/PaddeK/node-maxmind-db/pull/17

rajeshsegu avatar Jul 13 '15 17:07 rajeshsegu

I'm having the same problem. Just to be sure, I took the latest version to include the pull request #17. But the issue still seems to be present. When testing with '::ffff:192.168.0.1', the Error 'Invalid IPv4 address' is thrown. Breaking this down, I found that the ip-address module doesn't validate the address as a proper IPv4 address (here)

ipv4

What would be best way to tackle this problem? Manually extracting the IPv4 address before sending it to getGeoData, as @brbaker suggested?

jtpio avatar Aug 28 '15 11:08 jtpio

Same issue. Error: Invalid IPv4 address is thrown for ::ffff:127.0.0.1.

akoskm avatar Sep 15 '15 05:09 akoskm

https://github.com/runk/node-maxmind

knoxcard avatar Dec 28 '18 05:12 knoxcard