vpndetection 5.5.0 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vpndetection/bogon.rb +12 -3
- data/lib/vpndetection/bogons.rb +29 -3
- data/lib/vpndetection/client.rb +7 -2
- data/lib/vpndetection/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f1b1aeb8a3c63721e409832879f7e12383b9ab81b50448dd1ae961efc2e68c5
|
|
4
|
+
data.tar.gz: a2478e011ccc7b22d7ae8a267dc3561a4bad18bc8f768dccb3aa8d2e8d24988a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0153bf1aabac68578a6951e9f00568ac8059d3030ac8427b1745c23ae474d90188360a87139cfaee3d9acbfb6dbaff4d233844c7cd8e4ccd2894a77d0b068832
|
|
7
|
+
data.tar.gz: aa3f85f7db3f517447a65b5d20f7e1134c030a7e1ea6b330021290e51502fd31b4a38b4cfb477eaeef63636e16ea74afd79ca5526a03d33a3e46b4870b0b37d7
|
data/lib/vpndetection/bogon.rb
CHANGED
|
@@ -16,12 +16,21 @@ module VPNDetection
|
|
|
16
16
|
addr = parse(ip)
|
|
17
17
|
return false if addr.nil?
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
# canonical ranges put ::ffff:0:0/96. Unmapping it first would match it
|
|
21
|
-
# against the v4 table and disagree with every other SDK.
|
|
19
|
+
addr = addr.native if addr.ipv4_mapped?
|
|
22
20
|
(addr.ipv4? ? v4 : v6).any? { |range| range.include?(addr) }
|
|
23
21
|
end
|
|
24
22
|
|
|
23
|
+
# The IPv4 address an IPv4-mapped IPv6 address (::ffff:a.b.c.d, in any
|
|
24
|
+
# spelling) carries, dotted, and any other address as given. A server
|
|
25
|
+
# listening on :: sees every IPv4 visitor in that form, which read whole is
|
|
26
|
+
# inside ::ffff:0:0/96, so judging it whole would answer every such visitor
|
|
27
|
+
# locally as a bogon. ::a.b.c.d is IPv4-compatible rather than mapped, and
|
|
28
|
+
# stays IPv6: IPAddr#native alone would unwrap that too.
|
|
29
|
+
def unmapped(ip)
|
|
30
|
+
addr = ip.to_s.include?(':') ? parse(ip) : nil
|
|
31
|
+
addr&.ipv4_mapped? ? addr.native.to_s : ip
|
|
32
|
+
end
|
|
33
|
+
|
|
25
34
|
# The answer a bogon gets, in the full shape the API serves at its widest
|
|
26
35
|
# plan: every flag present and false, every detail object present and empty.
|
|
27
36
|
#
|
data/lib/vpndetection/bogons.rb
CHANGED
|
@@ -13,13 +13,14 @@ module VPNDetection
|
|
|
13
13
|
'172.16.0.0/12',
|
|
14
14
|
'192.0.0.0/24',
|
|
15
15
|
'192.0.2.0/24',
|
|
16
|
+
'192.88.99.2/32',
|
|
16
17
|
'192.168.0.0/16',
|
|
17
18
|
'198.18.0.0/15',
|
|
18
19
|
'198.51.100.0/24',
|
|
19
20
|
'203.0.113.0/24',
|
|
20
21
|
'224.0.0.0/4',
|
|
21
|
-
'240.0.0.0/4',
|
|
22
22
|
'255.255.255.255/32',
|
|
23
|
+
'240.0.0.0/4',
|
|
23
24
|
].freeze
|
|
24
25
|
|
|
25
26
|
V6 = [
|
|
@@ -27,41 +28,66 @@ module VPNDetection
|
|
|
27
28
|
'::1/128',
|
|
28
29
|
'::ffff:0:0/96',
|
|
29
30
|
'::/96',
|
|
31
|
+
'64:ff9b::/96',
|
|
32
|
+
'64:ff9b:1::/48',
|
|
30
33
|
'100::/64',
|
|
34
|
+
'100:0:0:1::/64',
|
|
35
|
+
'2001:2::/48',
|
|
31
36
|
'2001:10::/28',
|
|
32
37
|
'2001:db8::/32',
|
|
38
|
+
'3fff::/20',
|
|
39
|
+
'5f00::/16',
|
|
33
40
|
'fc00::/7',
|
|
34
41
|
'fe80::/10',
|
|
35
42
|
'fec0::/10',
|
|
36
43
|
'ff00::/8',
|
|
37
44
|
'2002::/24',
|
|
38
45
|
'2002:a00::/24',
|
|
46
|
+
'2002:6440::/26',
|
|
39
47
|
'2002:7f00::/24',
|
|
40
48
|
'2002:a9fe::/32',
|
|
41
49
|
'2002:ac10::/28',
|
|
42
50
|
'2002:c000::/40',
|
|
43
51
|
'2002:c000:200::/40',
|
|
52
|
+
'2002:c058:6302::/48',
|
|
44
53
|
'2002:c0a8::/32',
|
|
45
54
|
'2002:c612::/31',
|
|
46
55
|
'2002:c633:6400::/40',
|
|
47
56
|
'2002:cb00:7100::/40',
|
|
48
57
|
'2002:e000::/20',
|
|
49
|
-
'2002:f000::/20',
|
|
50
58
|
'2002:ffff:ffff::/48',
|
|
59
|
+
'2002:f000::/20',
|
|
51
60
|
'2001::/40',
|
|
52
61
|
'2001:0:a00::/40',
|
|
62
|
+
'2001:0:6440::/42',
|
|
53
63
|
'2001:0:7f00::/40',
|
|
54
64
|
'2001:0:a9fe::/48',
|
|
55
65
|
'2001:0:ac10::/44',
|
|
56
66
|
'2001:0:c000::/56',
|
|
57
67
|
'2001:0:c000:200::/56',
|
|
68
|
+
'2001:0:c058:6302::/64',
|
|
58
69
|
'2001:0:c0a8::/48',
|
|
59
70
|
'2001:0:c612::/47',
|
|
60
71
|
'2001:0:c633:6400::/56',
|
|
61
72
|
'2001:0:cb00:7100::/56',
|
|
62
73
|
'2001:0:e000::/36',
|
|
63
|
-
'2001:0:f000::/36',
|
|
64
74
|
'2001:0:ffff:ffff::/64',
|
|
75
|
+
'2001:0:f000::/36',
|
|
76
|
+
'2001:1::/32',
|
|
77
|
+
'2001:2::/31',
|
|
78
|
+
'2001:4::/30',
|
|
79
|
+
'2001:8::/29',
|
|
80
|
+
'2001:20::/27',
|
|
81
|
+
'2001:40::/26',
|
|
82
|
+
'2001:80::/25',
|
|
83
|
+
'2001:100::/24',
|
|
84
|
+
'::/3',
|
|
85
|
+
'4000::/3',
|
|
86
|
+
'6000::/3',
|
|
87
|
+
'8000::/3',
|
|
88
|
+
'a000::/3',
|
|
89
|
+
'c000::/3',
|
|
90
|
+
'e000::/3',
|
|
65
91
|
].freeze
|
|
66
92
|
end
|
|
67
93
|
end
|
data/lib/vpndetection/client.rb
CHANGED
|
@@ -79,6 +79,8 @@ module VPNDetection
|
|
|
79
79
|
def lookup(ip, retries: nil, timeout: nil)
|
|
80
80
|
# Here as well as in the transport: a bogon or a cached answer returns before any request.
|
|
81
81
|
Transport.checked_timeout(timeout) unless timeout.nil?
|
|
82
|
+
# Judged, cached and sent as the IPv4 address it carries, if it is mapped.
|
|
83
|
+
ip = Bogon.unmapped(ip)
|
|
82
84
|
return Bogon.result(ip) if Bogon.bogon?(ip)
|
|
83
85
|
|
|
84
86
|
loop do
|
|
@@ -167,7 +169,10 @@ module VPNDetection
|
|
|
167
169
|
end
|
|
168
170
|
Transport.checked_timeout(timeout) unless timeout.nil?
|
|
169
171
|
|
|
170
|
-
|
|
172
|
+
# An IPv4-mapped address is sent as the address it carries, once however
|
|
173
|
+
# many of its spellings were asked, and answered under each one asked.
|
|
174
|
+
asked = ips.to_a.uniq
|
|
175
|
+
addresses = asked.map { |ip| Bogon.unmapped(ip) }.uniq
|
|
171
176
|
answers = {}
|
|
172
177
|
pending = []
|
|
173
178
|
|
|
@@ -199,7 +204,7 @@ module VPNDetection
|
|
|
199
204
|
|
|
200
205
|
# Reinstated in input order: a hydra settles in completion order, and a
|
|
201
206
|
# caller iterating the hash should see what they passed in.
|
|
202
|
-
|
|
207
|
+
asked.to_h { |ip| [ip, answers[Bogon.unmapped(ip)]] }
|
|
203
208
|
end
|
|
204
209
|
|
|
205
210
|
private
|
data/lib/vpndetection/version.rb
CHANGED