irrc 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +195 -0
- data/Rakefile +8 -0
- data/bin/irrc +5 -0
- data/irrc.gemspec +23 -0
- data/lib/irrc.rb +2 -0
- data/lib/irrc/cli.rb +1 -0
- data/lib/irrc/cli/client.rb +108 -0
- data/lib/irrc/cli/yaml_printer.rb +13 -0
- data/lib/irrc/client.rb +109 -0
- data/lib/irrc/connecting.rb +39 -0
- data/lib/irrc/irr.rb +123 -0
- data/lib/irrc/irrd.rb +1 -0
- data/lib/irrc/irrd/api.rb +69 -0
- data/lib/irrc/irrd/client.rb +90 -0
- data/lib/irrc/logging.rb +13 -0
- data/lib/irrc/parameter.rb +37 -0
- data/lib/irrc/prefix.rb +19 -0
- data/lib/irrc/query.rb +78 -0
- data/lib/irrc/query_status.rb +19 -0
- data/lib/irrc/runner.rb +37 -0
- data/lib/irrc/socket.rb +5 -0
- data/lib/irrc/subquery.rb +24 -0
- data/lib/irrc/version.rb +3 -0
- data/lib/irrc/whoisd.rb +1 -0
- data/lib/irrc/whoisd/api.rb +54 -0
- data/lib/irrc/whoisd/client.rb +88 -0
- data/spec/features/irr_as_set_resolution_spec.rb +193 -0
- data/spec/features/irr_invalid_object_resolution_spec.rb +32 -0
- data/spec/features/whois_as_set_resolution_spec.rb +193 -0
- data/spec/features/whois_invalid_object_resolution_spec.rb +32 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/contexts.rb +12 -0
- data/spec/support/query.rb +7 -0
- metadata +123 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Whois as-set resolution' do
|
4
|
+
include_context 'whois queries'
|
5
|
+
|
6
|
+
context 'When FQDN specified for Whois server' do
|
7
|
+
subject { send_query(whois_fqdn, 'AS-JPNIC') }
|
8
|
+
|
9
|
+
it 'returns ipv4 and ipv6 prefixes by default' do
|
10
|
+
expect(subject['AS-JPNIC'][:ipv4]['AS2515']).to include '192.41.192.0/24', '202.12.30.0/24',
|
11
|
+
'211.120.240.0/21', '211.120.248.0/24'
|
12
|
+
expect(subject['AS-JPNIC'][:ipv6]['AS2515']).to include '2001:dc2::/32', '2001:0fa0::/32'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'When a name specified for Whois server' do
|
17
|
+
subject { send_query(whois, as_set) }
|
18
|
+
|
19
|
+
it 'returns the same result as if the FQDN specified' do
|
20
|
+
expect(subject).to eq send_query(whois_fqdn, as_set)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'gently closes connections to Whois server' do
|
25
|
+
expect_any_instance_of(Irrc::Whoisd::Client).to receive(:close)
|
26
|
+
send_query(whois_fqdn, as_set)
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'Fintering by Authoritative Whois server' do
|
30
|
+
subject { send_query(:jpirr, 'AS-JPNIC', source: :apnic) }
|
31
|
+
|
32
|
+
it 'returns nothing' do
|
33
|
+
expect(subject).to eq({})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'When as-set resolution is done but something wrong while further processes' do
|
38
|
+
subject { send_query(whois, as_set) }
|
39
|
+
before do
|
40
|
+
allow_any_instance_of(Irrc::Whoisd::Client).to receive(:resolve_prefixes_from_aut_nums){ raise }
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'ignores a halfway result' do
|
44
|
+
expect(subject).to eq({})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'When only ipv4 is specified for protocol' do
|
49
|
+
subject { send_query(whois, as_set, protocol: :ipv4) }
|
50
|
+
|
51
|
+
it 'returns nothing about ipv6' do
|
52
|
+
expect(subject[as_set][:ipv6]).to be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'When nil specified for protocol' do
|
57
|
+
subject { send_query(whois, as_set, protocol: nil) }
|
58
|
+
|
59
|
+
it 'returns nothing about the as-set' do
|
60
|
+
expect(subject[as_set]).to eq({})
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'When blank protocol specified' do
|
65
|
+
subject { send_query(whois, as_set, protocol: []) }
|
66
|
+
|
67
|
+
it 'returns nothing about the as-set' do
|
68
|
+
expect(subject[as_set]).to eq({})
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'When an invalid protocol specified' do
|
73
|
+
subject { send_query(whois, as_set, protocol: :invalid) }
|
74
|
+
|
75
|
+
it 'reports an ArgumentError' do
|
76
|
+
expect { subject }.to raise_error ArgumentError
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'When a non-mirrored server specified for authoritative Whois server' do
|
81
|
+
subject { send_query(whois, as_set, source: :outsider) }
|
82
|
+
|
83
|
+
it 'returns nothing' do
|
84
|
+
expect(subject).to eq({})
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'When nil specified for authoritative Whois server' do
|
89
|
+
subject { send_query(whois, as_set, source: nil) }
|
90
|
+
|
91
|
+
it 'returns a result without any filter of authoritative Whois server' do
|
92
|
+
expect(subject).to eq send_query(whois, as_set)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'When blank authoritative Whois server specified' do
|
97
|
+
subject { send_query(whois, as_set, source: []) }
|
98
|
+
|
99
|
+
it 'returns a result without any filter of authoritative Whois server' do
|
100
|
+
expect(subject).to eq send_query(whois, as_set)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'When non-existent Whois object specified' do
|
105
|
+
subject { send_query(whois, 'AS-NON-EXISTENT') }
|
106
|
+
|
107
|
+
it 'ignores the Whois error' do
|
108
|
+
expect(subject).to eq({})
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'When invalid Whois server name specified' do
|
113
|
+
subject { send_query(:invalid, as_set) }
|
114
|
+
|
115
|
+
it 'reports an error' do
|
116
|
+
expect { subject }.to raise_error
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'When non-resolvable Whois server fqdn specified' do
|
121
|
+
subject { send_query('non-resolvable.localdomain', as_set) }
|
122
|
+
|
123
|
+
it 'reports an error' do
|
124
|
+
expect { subject }.to raise_error
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'When unreachable Whois server specified' do
|
129
|
+
subject { send_query('192.0.2.1', as_set) }
|
130
|
+
|
131
|
+
it 'reports an error' do
|
132
|
+
expect { subject }.to raise_error
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'When specifing an Whois server out of service' do
|
137
|
+
subject { send_query('127.0.0.1', as_set) }
|
138
|
+
|
139
|
+
it 'reports an error' do
|
140
|
+
expect { subject }.to raise_error
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'NOTE: These may fail due to Whois database changes, not code. Check Whois database if fails.' do
|
145
|
+
describe 'route-set' do
|
146
|
+
subject { send_query(whois, 'RS-RC-26462') }
|
147
|
+
|
148
|
+
it 'returns the same result as Whois database' do
|
149
|
+
expect(subject['RS-RC-26462']).to eq(
|
150
|
+
{:ipv4=>{nil=>["137.238.0.0/16"]}, :ipv6=>{nil=>["2620:0:5080::/48"]}}
|
151
|
+
)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe 'nested as-set' do
|
156
|
+
subject { send_query(whois, 'AS-PDOXUPLINKS', source: :apnic) }
|
157
|
+
|
158
|
+
it 'returns the same result as Whois database' do
|
159
|
+
expect(subject['AS-PDOXUPLINKS']).to eq(
|
160
|
+
{:ipv4=>
|
161
|
+
{"AS703"=>[],
|
162
|
+
"AS1221"=>["155.143.128.0/17", "203.92.26.0/24"],
|
163
|
+
"AS2764"=>[],
|
164
|
+
"AS7474"=>[],
|
165
|
+
"AS7657"=>[],
|
166
|
+
"AS4565"=>[],
|
167
|
+
"AS5650"=>[],
|
168
|
+
"AS6461"=>[]},
|
169
|
+
:ipv6=>
|
170
|
+
{"AS703"=>[],
|
171
|
+
"AS1221"=>[],
|
172
|
+
"AS2764"=>[],
|
173
|
+
"AS7474"=>[],
|
174
|
+
"AS7657"=>[],
|
175
|
+
"AS4565"=>[],
|
176
|
+
"AS5650"=>[],
|
177
|
+
"AS6461"=>[]}}
|
178
|
+
)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe 'nested route-set' do
|
183
|
+
subject { send_query(whois, 'RS-RR-COUDERSPORT') }
|
184
|
+
|
185
|
+
it 'returns the same result as Whois database' do
|
186
|
+
expect(subject['RS-RR-COUDERSPORT']).to eq(
|
187
|
+
{:ipv4=>{nil=>["71.74.32.0/20", "75.180.128.0/19", "107.14.160.0/20"]},
|
188
|
+
:ipv6=>{nil=>[]}}
|
189
|
+
)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Whois Invalid object resolution' do
|
4
|
+
include_context 'whois queries'
|
5
|
+
|
6
|
+
describe 'Try as-jpnic with JPIRR' do
|
7
|
+
context 'When invalid object specified' do
|
8
|
+
subject { send_query(whois, 'INVALID') }
|
9
|
+
|
10
|
+
it "doesn't report an error" do
|
11
|
+
expect(subject['INVALID']).to eq({})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'When a blank String given for IRR object to resolve' do
|
16
|
+
subject { send_query(whois, '') }
|
17
|
+
|
18
|
+
it "doesn't report an error" do
|
19
|
+
expect(subject['']).to eq({})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'When nil given for IRR object to resolve' do
|
24
|
+
subject { send_query(whois, nil) }
|
25
|
+
|
26
|
+
it 'does nothing even reporting the error' do
|
27
|
+
expect_any_instance_of(Irrc::Whoisd::Client).not_to receive(:connect)
|
28
|
+
expect(subject).to eq({})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
shared_context 'irr queries' do
|
2
|
+
let(:irr) { :jpirr }
|
3
|
+
let(:irr_fqdn) { 'jpirr.nic.ad.jp' }
|
4
|
+
let(:as_set) { 'AS-JPNIC' }
|
5
|
+
end
|
6
|
+
|
7
|
+
shared_context 'whois queries' do
|
8
|
+
let(:whois) { :apnic }
|
9
|
+
let(:whois_fqdn) { 'whois.apnic.net' }
|
10
|
+
let(:as_set) { 'AS-JPNIC' }
|
11
|
+
end
|
12
|
+
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: irrc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shintaro Kojima
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
description: irrc is a lightweight and flexible client of IRR / Whois Database to
|
42
|
+
expand arbitrary as-set and route-set objects into a list of origin ASs and prefixes
|
43
|
+
belonging to the ASs. It allows concurrent queries to IRR / Whois Databases for
|
44
|
+
performance.
|
45
|
+
email:
|
46
|
+
- goodies@codeout.net
|
47
|
+
executables:
|
48
|
+
- irrc
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- ".rspec"
|
54
|
+
- ".travis.yml"
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/irrc
|
60
|
+
- irrc.gemspec
|
61
|
+
- lib/irrc.rb
|
62
|
+
- lib/irrc/cli.rb
|
63
|
+
- lib/irrc/cli/client.rb
|
64
|
+
- lib/irrc/cli/yaml_printer.rb
|
65
|
+
- lib/irrc/client.rb
|
66
|
+
- lib/irrc/connecting.rb
|
67
|
+
- lib/irrc/irr.rb
|
68
|
+
- lib/irrc/irrd.rb
|
69
|
+
- lib/irrc/irrd/api.rb
|
70
|
+
- lib/irrc/irrd/client.rb
|
71
|
+
- lib/irrc/logging.rb
|
72
|
+
- lib/irrc/parameter.rb
|
73
|
+
- lib/irrc/prefix.rb
|
74
|
+
- lib/irrc/query.rb
|
75
|
+
- lib/irrc/query_status.rb
|
76
|
+
- lib/irrc/runner.rb
|
77
|
+
- lib/irrc/socket.rb
|
78
|
+
- lib/irrc/subquery.rb
|
79
|
+
- lib/irrc/version.rb
|
80
|
+
- lib/irrc/whoisd.rb
|
81
|
+
- lib/irrc/whoisd/api.rb
|
82
|
+
- lib/irrc/whoisd/client.rb
|
83
|
+
- spec/features/irr_as_set_resolution_spec.rb
|
84
|
+
- spec/features/irr_invalid_object_resolution_spec.rb
|
85
|
+
- spec/features/whois_as_set_resolution_spec.rb
|
86
|
+
- spec/features/whois_invalid_object_resolution_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/support/contexts.rb
|
89
|
+
- spec/support/query.rb
|
90
|
+
homepage: https://github.com/codeout/irrc
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: IRR / Whois client to expand as-set and route-set into a list of origin ASs
|
114
|
+
and prefixes
|
115
|
+
test_files:
|
116
|
+
- spec/features/irr_as_set_resolution_spec.rb
|
117
|
+
- spec/features/irr_invalid_object_resolution_spec.rb
|
118
|
+
- spec/features/whois_as_set_resolution_spec.rb
|
119
|
+
- spec/features/whois_invalid_object_resolution_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/support/contexts.rb
|
122
|
+
- spec/support/query.rb
|
123
|
+
has_rdoc:
|