grs-search 1.0.0 → 2.0.0
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/VERSION +1 -1
- data/grs-search.gemspec +4 -4
- data/lib/grs-search/response.rb +21 -13
- data/spec/grs-search_spec.rb +14 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0493d89a4af2f4c4e227b55728f6eeab1c54784
|
4
|
+
data.tar.gz: 83f87e4ce30f5e80f031247a95bc355e74cffd8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730f1aecc25ae3cd8747f6c60ef94411accd2c20dda8190a0afb4ae3521554365b120a6d03cce442eaf2a4d4e9449e752fb95be76383b362df943f61951a151c
|
7
|
+
data.tar.gz: 6f948acfb31aa77496b153128104259ff7e2980e9a1ed4b4152a88e19f8abb9e55575e225f00c3f744b94668d5cca917e601deb76699fdd7f20169705a31417c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/grs-search.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: grs-search
|
5
|
+
# stub: grs-search 2.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "grs-search"
|
9
|
-
s.version = "
|
9
|
+
s.version = "2.0.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Tobias Begalke"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2016-04-12"
|
15
15
|
s.description = "This Ruby library looks up GRS data via the Ripe API (http://rest.db.ripe.net)"
|
16
16
|
s.email = "tob@spyz.org"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
]
|
35
35
|
s.homepage = "http://github.com/elcamino/grs-search"
|
36
36
|
s.licenses = ["BSD"]
|
37
|
-
s.rubygems_version = "2.
|
37
|
+
s.rubygems_version = "2.4.6"
|
38
38
|
s.summary = "Look up GRS data via the RIPE API"
|
39
39
|
|
40
40
|
if s.respond_to? :specification_version then
|
data/lib/grs-search/response.rb
CHANGED
@@ -7,58 +7,66 @@ class GRSSearch
|
|
7
7
|
|
8
8
|
|
9
9
|
def initialize(json_data)
|
10
|
-
json_data['objects']['object'].find_all { |data| data['type']
|
10
|
+
json_data['objects']['object'].find_all { |data| data['type'] =~ /inet6?num/ }.each do |i|
|
11
11
|
@source ||= i['source']['id']
|
12
12
|
|
13
13
|
# IP address range
|
14
14
|
#
|
15
|
-
if item = i['attributes']['attribute'].detect { |a| a['name']
|
15
|
+
if item = i['attributes']['attribute'].detect { |a| a['name'] =~ /inet6?num/ }
|
16
16
|
_ip_from, _ip_to = item['value'].split(/\s+-\s+/).map { |ip| ip.strip }
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
if ! _ip_to
|
19
|
+
_ipaddr = IPAddr.new item['value'].strip
|
20
|
+
_range = _ipaddr.to_range
|
21
|
+
@ip_from = _range.first
|
22
|
+
@ip_to = _range.last
|
23
|
+
else
|
24
|
+
@ip_from ||= IPAddr.new _ip_from
|
25
|
+
@ip_to ||= IPAddr.new _ip_to
|
26
|
+
end
|
19
27
|
end
|
20
|
-
|
28
|
+
|
21
29
|
# net name
|
22
30
|
#
|
23
31
|
if item = i['attributes']['attribute'].detect { |a| a['name'] == 'netname' }
|
24
32
|
@name ||= item['value']
|
25
33
|
end
|
26
|
-
|
34
|
+
|
27
35
|
# net description
|
28
36
|
#
|
29
37
|
if item = i['attributes']['attribute'].detect { |a| a['name'] == 'descr' }
|
30
38
|
@description ||= item['value']
|
31
39
|
end
|
32
|
-
|
40
|
+
|
33
41
|
# country
|
34
42
|
#
|
35
43
|
if item = i['attributes']['attribute'].detect { |a| a['name'] == 'country' }
|
36
44
|
@country ||= item['value']
|
37
45
|
end
|
38
|
-
|
46
|
+
|
39
47
|
# status
|
40
48
|
#
|
41
49
|
if item = i['attributes']['attribute'].detect { |a| a['name'] == 'status' }
|
42
50
|
@status ||= item['value']
|
43
51
|
end
|
44
|
-
|
52
|
+
|
45
53
|
# organization
|
46
54
|
#
|
47
55
|
if item = i['attributes']['attribute'].detect { |a| a['name'] == 'org' }
|
48
56
|
@org ||= item['value']
|
49
57
|
end
|
50
|
-
|
58
|
+
|
51
59
|
end
|
52
|
-
|
60
|
+
|
53
61
|
json_data['objects']['object'].find_all { |data| data['type'] == 'route' }.each do |i|
|
54
|
-
|
62
|
+
|
55
63
|
# network CIDR notation
|
56
64
|
#
|
57
65
|
if item = i['attributes']['attribute'].detect { |a| a['name'] == 'route' }
|
58
66
|
@cidr = item['value']
|
59
67
|
end
|
60
68
|
end
|
61
|
-
|
69
|
+
|
62
70
|
def inspect
|
63
71
|
"GRSSearch::Response\##{self.object_id} - source:#{source} ip_from:#{ip_from} ip_to:#{ip_to} name:#{name} description:#{description} country:#{country} status:#{status} cidr:#{cidr} org:#{org}"
|
64
72
|
end
|
data/spec/grs-search_spec.rb
CHANGED
@@ -4,6 +4,7 @@ describe GRSSearch do
|
|
4
4
|
let(:res_afrinic) { GRSSearch.lookup('41.206.1.10') }
|
5
5
|
let(:res_google) { GRSSearch.lookup('66.249.64.0') }
|
6
6
|
let(:res_kabel) { GRSSearch.lookup('178.27.236.214') }
|
7
|
+
let(:res_ipv6) { GRSSearch.lookup('2804:14c:8793:89b5:add7:e834:9d29:5f75') }
|
7
8
|
|
8
9
|
it "is able to fetch data from the API endpoint" do
|
9
10
|
expect(res_google.class).to eq GRSSearch::Response
|
@@ -15,7 +16,7 @@ describe GRSSearch do
|
|
15
16
|
expect(res_google.org).to eq 'GOGL'
|
16
17
|
expect(res_google.name).to eq 'GOOGLE'
|
17
18
|
expect(res_google.description).not_to be
|
18
|
-
expect(res_google.status).to eq 'allocation'
|
19
|
+
expect(res_google.status.downcase).to eq 'allocation'
|
19
20
|
expect(res_google.country).not_to be
|
20
21
|
expect(res_google.cidr).to eq '66.249.64.0/24'
|
21
22
|
|
@@ -43,5 +44,17 @@ describe GRSSearch do
|
|
43
44
|
expect(res_kabel.country).to eq 'DE'
|
44
45
|
expect(res_kabel.cidr).to eq '178.27.128.0/17'
|
45
46
|
|
47
|
+
|
48
|
+
expect(res_ipv6.class).to eq GRSSearch::Response
|
49
|
+
expect(res_ipv6.source).to eq 'lacnic-grs'
|
50
|
+
expect(res_ipv6.ip_from.to_s).to eq "2804:14c::"
|
51
|
+
expect(res_ipv6.ip_to.to_s).to eq "2804:14d:ffff:ffff:ffff:ffff:ffff:ffff"
|
52
|
+
expect(res_ipv6.ip_from.to_i).to eq 53189915322580728962426485453122174976
|
53
|
+
expect(res_ipv6.ip_to.to_i).to eq 53189915481037053990955160640210075647
|
54
|
+
expect(res_ipv6.org).not_to be
|
55
|
+
expect(res_ipv6.name).not_to be
|
56
|
+
expect(res_ipv6.status).to eq 'ALLOCATED'
|
57
|
+
expect(res_ipv6.country).to eq 'BR'
|
58
|
+
expect(res_ipv6.cidr).to eq 'CLATO S.A.'
|
46
59
|
end
|
47
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grs-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Begalke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.4.6
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Look up GRS data via the RIPE API
|