     i = new ipv6.v6.Address(ip)
   else
     i = new ipv6.v4.Address(ip)
+    subnetMask = 96 + i.subnetMask
+    ip = '::ffff:' + i.toV6Group() + "/" + subnetMask
+    i = new ipv6.v6.Address(ip)
 
 ipToInt = (ip) ->
   i = address(ip)

  else
    a = address(ip)
    b = address(block)
    # if we are comparing a v6 address to an v4 cidr range we need to 
    # convert the v4 cidr to a v6 cidr
    if not a.v4 and b.v4
      subnetMask = 96 + b.subnetMask
      block = '::' + b.toV6Group() + "/" + subnetMask
      b = new ipv6.v6.Address(block)
    a.isInSubnet(b)

isIpInAnyRange = (ip, blocks) ->

if require.main == module
  main()

# for testing
exports.address = address
exports.compareIps = compareIps
exports.isIpInRange = isIpInRange
exports.isIpInAnyRange = isIpInAnyRange
