@@ -15,6 +15,9 @@ address = (ip) ->
1515 i = new ipv6.v6.Address (ip)
1616 else
1717 i = new ipv6.v4.Address (ip)
18+ subnetMask = 96 + i .subnetMask
19+ ip = ' ::ffff:' + i .toV6Group () + " /" + subnetMask
20+ i = new ipv6.v6.Address (ip)
1821
1922ipToInt = (ip ) ->
2023 i = address (ip)
@@ -35,12 +38,6 @@ isIpInRange = (ip, block) ->
3538 else
3639 a = address (ip)
3740 b = address (block)
38- # if we are comparing a v6 address to an v4 cidr range we need to
39- # convert the v4 cidr to a v6 cidr
40- if not a .v4 and b .v4
41- subnetMask = 96 + b .subnetMask
42- block = ' ::' + b .toV6Group () + " /" + subnetMask
43- b = new ipv6.v6.Address (block)
4441 a .isInSubnet (b)
4542
4643isIpInAnyRange = (ip , blocks ) ->
@@ -61,7 +58,6 @@ loadJson = (path) ->
6158 require path
6259
6360getStatusLength = (edit , name , template ) ->
64- # returns length of the tweet based on shortened url
6561 # https://support.twitter.com/articles/78124-posting-links-in-a-tweet
6662 fakeUrl = ' http://t.co/BzHLWr31Ce'
6763 status = Mustache .render template, name : name, url : fakeUrl, page : edit .page
@@ -118,7 +114,8 @@ main = ->
118114if require .main == module
119115 main ()
120116
121- # export these for testing
117+ # for testing
118+ exports .address = address
122119exports .compareIps = compareIps
123120exports .isIpInRange = isIpInRange
124121exports .isIpInAnyRange = isIpInAnyRange
0 commit comments