@@ -15,6 +15,9 @@ address = (ip) ->
15
15
i = new ipv6.v6.Address (ip)
16
16
else
17
17
i = new ipv6.v4.Address (ip)
18
+ subnetMask = 96 + i .subnetMask
19
+ ip = ' ::ffff:' + i .toV6Group () + " /" + subnetMask
20
+ i = new ipv6.v6.Address (ip)
18
21
19
22
ipToInt = (ip ) ->
20
23
i = address (ip)
@@ -35,12 +38,6 @@ isIpInRange = (ip, block) ->
35
38
else
36
39
a = address (ip)
37
40
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)
44
41
a .isInSubnet (b)
45
42
46
43
isIpInAnyRange = (ip , blocks ) ->
@@ -61,7 +58,6 @@ loadJson = (path) ->
61
58
require path
62
59
63
60
getStatusLength = (edit , name , template ) ->
64
- # returns length of the tweet based on shortened url
65
61
# https://support.twitter.com/articles/78124-posting-links-in-a-tweet
66
62
fakeUrl = ' http://t.co/BzHLWr31Ce'
67
63
status = Mustache .render template, name : name, url : fakeUrl, page : edit .page
@@ -118,7 +114,8 @@ main = ->
118
114
if require .main == module
119
115
main ()
120
116
121
- # export these for testing
117
+ # for testing
118
+ exports .address = address
122
119
exports .compareIps = compareIps
123
120
exports .isIpInRange = isIpInRange
124
121
exports .isIpInAnyRange = isIpInAnyRange
0 commit comments