PaddeK / node-maxmind-db

This is the pure Node API for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).
GNU Lesser General Public License v2.1
88 stars 25 forks source link

IPParser doesn't handle IPv4-Mapped IPv6 Address #14

Open brbaker opened 9 years ago

brbaker commented 9 years ago

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.

rajeshsegu commented 9 years ago

@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

jtpio commented 9 years ago

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?

akoskm commented 8 years ago

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

knoxcard commented 5 years ago

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