subnets 1.0.0pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+ require 'subnets'
3
+
4
+ class SubnetsTest < Minitest::Test
5
+ def test_parse_net4
6
+ assert_instance_of Subnets::Net4, Subnets.parse('192.168.1.1/24')
7
+ assert_raises(Subnets::ParseError) { Subnets.parse('192.168.1.256/24') }
8
+ end
9
+
10
+ def test_parse_net6
11
+ assert_instance_of Subnets::Net6, Subnets.parse('1::1/2')
12
+ assert_raises(Subnets::ParseError) { Subnets.parse(':1::') }
13
+ end
14
+
15
+ def test_include?
16
+ nets = %w(
17
+ 192.168.5.0/24
18
+ 10.1.0.0/16
19
+ 11:22::/16
20
+ ).map{|n| Subnets.parse(n)}
21
+
22
+ nets << /^192\./
23
+ nets << /someregex/
24
+
25
+ assert Subnets.include?(nets, '192.168.5.4')
26
+ assert Subnets.include?(nets, '10.1.1.1')
27
+ assert Subnets.include?(nets, '11:22::33')
28
+ assert Subnets.include?(nets, '11:22:33::')
29
+ assert Subnets.include?(nets, 'someregex')
30
+
31
+ refute Subnets.include?(nets, '1.2.3.4')
32
+ refute Subnets.include?(nets, '::1')
33
+ refute Subnets.include?(nets, '33::')
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/reporters'
3
+
4
+ class JUnitReporterWithSuitePrefix < Minitest::Reporters::JUnitReporter
5
+ def initialize(prefix, *args)
6
+ super(*args)
7
+ @prefix = prefix
8
+ end
9
+
10
+ def parse_xml_for(xml, suite, tests)
11
+ super(xml, "#{@prefix}#{suite}", tests)
12
+ end
13
+ end
14
+
15
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new,
16
+ JUnitReporterWithSuitePrefix.new("ruby-#{RUBY_VERSION}/")]
17
+
18
+ require 'subnets'
19
+ require 'well_known_subnets'
20
+ require 'eql_and_hash'
21
+
22
+ TIMED_TEST_DURATION = (ENV['TIMED_TEST_DURATION'] || 1).to_i
23
+
24
+ def assert_include(obj, val)
25
+ assert obj.include?(val), "#{obj} should include #{val}"
26
+ end
27
+
28
+ def refute_include(obj, val)
29
+ refute obj.include?(val), "#{obj} should not include #{val}"
30
+ end
@@ -0,0 +1,68 @@
1
+ PRIVATE_SUBNETS = %w(
2
+ 127.0.0.1/32
3
+ 10.0.0.0/8
4
+ 172.16.0.0/12
5
+ 192.168.0.0/16
6
+ ::1/128
7
+ fc00::/7
8
+ )
9
+
10
+ PRIVATE_SUBNETS_IPV4 = %w(
11
+ 10.0.0.0/8
12
+ 172.16.0.0/12
13
+ 192.168.0.0/16
14
+ )
15
+
16
+ # only ipv4 included
17
+ # fetched on 2018-04-10
18
+ # https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html#aws-ip-download
19
+ CLOUDFRONT_SUBNETS = %w(
20
+ 13.32.0.0/15
21
+ 13.35.0.0/16
22
+ 13.54.63.128/26
23
+ 13.59.250.0/26
24
+ 13.113.203.0/24
25
+ 13.124.199.0/24
26
+ 13.228.69.0/24
27
+ 18.216.170.128/25
28
+ 34.195.252.0/24
29
+ 34.216.51.0/25
30
+ 34.226.14.0/24
31
+ 34.232.163.208/29
32
+ 35.158.136.0/24
33
+ 35.162.63.192/26
34
+ 35.167.191.128/26
35
+ 52.15.127.128/26
36
+ 52.46.0.0/18
37
+ 52.47.139.0/24
38
+ 52.52.191.128/26
39
+ 52.56.127.0/25
40
+ 52.57.254.0/24
41
+ 52.66.194.128/26
42
+ 52.78.247.128/26
43
+ 52.84.0.0/15
44
+ 52.199.127.192/26
45
+ 52.212.248.0/26
46
+ 52.220.191.0/26
47
+ 52.222.128.0/17
48
+ 54.182.0.0/16
49
+ 54.192.0.0/16
50
+ 54.230.0.0/16
51
+ 54.233.255.128/26
52
+ 54.239.128.0/18
53
+ 54.239.192.0/19
54
+ 54.240.128.0/18
55
+ 70.132.0.0/18
56
+ 71.152.0.0/17
57
+ 143.204.0.0/16
58
+ 204.246.164.0/22
59
+ 204.246.168.0/22
60
+ 204.246.174.0/23
61
+ 204.246.176.0/20
62
+ 205.251.192.0/19
63
+ 205.251.249.0/24
64
+ 205.251.250.0/23
65
+ 205.251.252.0/23
66
+ 205.251.254.0/24
67
+ 216.137.32.0/19
68
+ )
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subnets
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0pre
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Mahoney
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest-reporters
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ipaddr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ipaddress
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: netaddr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rack
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: actionpack
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: |
154
+ C implementation of IPv4, IPv6 address and network parser with
155
+ fast determination of IP membership within a given subnet.
156
+ email: patrick.mahoney@raise.com
157
+ executables: []
158
+ extensions:
159
+ - ext/subnets/extconf.rb
160
+ extra_rdoc_files:
161
+ - README.md
162
+ - COPYING
163
+ files:
164
+ - COPYING
165
+ - README.md
166
+ - ext/subnets/ext.c
167
+ - ext/subnets/extconf.rb
168
+ - ext/subnets/ipaddr.c
169
+ - ext/subnets/ipaddr.h
170
+ - test/benchmark_helper.rb
171
+ - test/eql_and_hash.rb
172
+ - test/private_networks_benchmark.rb
173
+ - test/rack_ip_benchmark.rb
174
+ - test/rails_remote_ip_benchmark.rb
175
+ - test/subnets/net4_test.rb
176
+ - test/subnets/net6_test.rb
177
+ - test/subnets_test.rb
178
+ - test/test_helper.rb
179
+ - test/well_known_subnets.rb
180
+ homepage: https://github.com/raisemarketplace/subnets
181
+ licenses:
182
+ - MIT
183
+ metadata: {}
184
+ post_install_message:
185
+ rdoc_options: []
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ">"
196
+ - !ruby/object:Gem::Version
197
+ version: 1.3.1
198
+ requirements: []
199
+ rubyforge_project:
200
+ rubygems_version: 2.7.6
201
+ signing_key:
202
+ specification_version: 4
203
+ summary: C-extension for dealing with IP addresses and subnets
204
+ test_files: []