Doesn't work for some IPv6 addresses
cbrunnkvist opened this issue · comments
Conny Brunnkvist commented
> TRUSTED_ADDRESSES = ["127.0.0.1/8", "::1", "10.0.0.0/8", "fc00::/7"]
> isInSubnet('1.2.3.4', TRUSTED_ADDRESSES)
results in:
Error: not a valid IPv4 subnet: ::1
at isInSubnet (./is-in-subnet/build/src/ipv4.js:35:15)
Ref: https://en.wikipedia.org/wiki/IPv6_address#Representation
Nate Silva commented
Thank you. It wasn’t dealing with a mixed list of IPv4/IPv6 subnets. This will be fixed when I publish the next release today, but you’ll still need to specify a subnet: ::1/128
instead of just ::1
.
Nate Silva commented
Version 1.7.0 is released with this fix.