whitequark / ipaddr.js

IP address manipulation library in JavaScript
MIT License
576 stars 92 forks source link

Having issue with Windows IPV6 in IPV4 compatible format #180

Closed alberk8 closed 2 months ago

alberk8 commented 3 months ago

The original IPV6 is ::ffff:192.168.1.10 but the convert to bytearray and then back to ipaddr format does not get back the original format Instead I am getting ::ffff:c0a8:10a

Is this a bug?

var myip = ipaddr.parse("::ffff:192.168.1.10");
var myip_byte = myip.toByteArray();
var convert_back = ipaddr.fromByteArray(myip_byte).toString();

console.log(convert_back);
whitequark commented 2 months ago

These are the same IP addresses, even if the representation is a little different. You will get a similar effect if you expand the :: and roundtrip the address.