nicinfo 1.2.2 → 1.3.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nicinfo/config.rb +57 -1
- data/lib/nicinfo/constants.rb +7 -2
- data/lib/nicinfo/nicinfo_main.rb +20 -8
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f574db872855ffbfa72d6a22daaf59fdc1aec3b5
|
4
|
+
data.tar.gz: 414c3b45e8a4fe46e6afc31fc3d02c591a27c485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eedd1a0b3a0226000664e4c9268874ac1886d7d940668f79826348cfbc285609be465c280a727f332297514ef5138eac095c91ed376881d406713962f8fa438
|
7
|
+
data.tar.gz: 93bd001ca3321104020bb7a0d1c48324c571cc97e81fc130d114958865eac35e378461b69c9e5e582070100686f9c99c89c74b02a64fada2c48a532bd22f100f
|
data/lib/nicinfo/config.rb
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
require 'fileutils'
|
17
|
+
require 'time'
|
17
18
|
require 'nicinfo/nicinfo_logger'
|
18
19
|
require 'yaml'
|
19
20
|
require 'ostruct'
|
@@ -119,6 +120,47 @@ module NicInfo
|
|
119
120
|
FileUtils::cp_r( src_dir, @rdap_bootstrap_dir )
|
120
121
|
end
|
121
122
|
|
123
|
+
def set_bsfiles_last_update_time t = Time.now
|
124
|
+
f = File.open(bsfiles_last_update_filename, "w" )
|
125
|
+
f.write t.strftime( "%Y-%m-%d %H:%M:%S")
|
126
|
+
f.close
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_bsfiles_last_update_time
|
130
|
+
retval = nil
|
131
|
+
fname = bsfiles_last_update_filename
|
132
|
+
if File.exists?( fname )
|
133
|
+
f = File.open( fname, "r" )
|
134
|
+
data = f.read
|
135
|
+
f.close
|
136
|
+
retval = Time.parse( data )
|
137
|
+
end
|
138
|
+
return retval
|
139
|
+
end
|
140
|
+
|
141
|
+
def bsfiles_last_update_filename
|
142
|
+
File.join(@rdap_bootstrap_dir, NicInfo::BSFILE_LAST_CHECK_FILENAME)
|
143
|
+
end
|
144
|
+
|
145
|
+
def check_bsfiles_age?
|
146
|
+
retval = false
|
147
|
+
if @config[ NicInfo::BOOTSTRAP ][ NicInfo::CHECK_BSFILES_AGE ]
|
148
|
+
t = get_bsfiles_last_update_time
|
149
|
+
if t != nil
|
150
|
+
configed_age = @config[ NicInfo::BOOTSTRAP ][ NicInfo::BSFILES_AGE ]
|
151
|
+
age = t + configed_age
|
152
|
+
retval = true if age < Time.now
|
153
|
+
else
|
154
|
+
retval = true
|
155
|
+
end
|
156
|
+
end
|
157
|
+
return retval
|
158
|
+
end
|
159
|
+
|
160
|
+
def update_bsfiles? aged
|
161
|
+
return aged && @config[ NicInfo::BOOTSTRAP ][ NicInfo::UPDATE_BSFILES ]
|
162
|
+
end
|
163
|
+
|
122
164
|
def save name, data
|
123
165
|
data_file = File.open( File.join( @app_data, name ), "w" )
|
124
166
|
data_file.write data
|
@@ -275,6 +317,20 @@ bootstrap:
|
|
275
317
|
|
276
318
|
ns_root_url: https://rdap.arin.net/registry
|
277
319
|
|
320
|
+
# Check for updates of the IANA RDAP bootstrap files
|
321
|
+
# If true, check for IANA bootstrap files once they have aged past bsfiles_age
|
322
|
+
# Values are true or false
|
323
|
+
check_bsfiles_age: true
|
324
|
+
|
325
|
+
# The age at which IANA RDAP bootstrap files are to be checked if check_bsfiles is true
|
326
|
+
# This value is in seconds
|
327
|
+
bsfiles_age: 604800
|
328
|
+
|
329
|
+
# If the age of the IANA RDAP bootstrap files are considered old according to bsfiles_age
|
330
|
+
# and check_bsfiles is true, then this value will cause a fetch of new files if true.
|
331
|
+
# Values are true or false
|
332
|
+
update_bsfiles: true
|
333
|
+
|
278
334
|
search:
|
279
335
|
|
280
336
|
# Substring matching
|
@@ -288,7 +344,7 @@ security:
|
|
288
344
|
|
289
345
|
config:
|
290
346
|
# This should not be altered.
|
291
|
-
version:
|
347
|
+
version: 4
|
292
348
|
|
293
349
|
YAML_CONFIG
|
294
350
|
|
data/lib/nicinfo/constants.rb
CHANGED
@@ -18,10 +18,10 @@
|
|
18
18
|
|
19
19
|
module NicInfo
|
20
20
|
|
21
|
-
VERSION = "1.
|
21
|
+
VERSION = "1.3.0-alpha1"
|
22
22
|
VERSION_LABEL = "NicInfo v." + VERSION
|
23
23
|
COPYRIGHT = "Copyright (c) 2011-2017 American Registry for Internet Numbers (ARIN)"
|
24
|
-
CONFIG_VERSION =
|
24
|
+
CONFIG_VERSION = 4
|
25
25
|
|
26
26
|
# regular expressions
|
27
27
|
NET_HANDLE_REGEX = /^NET-.*/i
|
@@ -75,6 +75,9 @@ module NicInfo
|
|
75
75
|
IP_ROOT_URL = "ip_root_url"
|
76
76
|
AS_ROOT_URL = "as_root_url"
|
77
77
|
DOMAIN_ROOT_URL = "domain_root_url"
|
78
|
+
CHECK_BSFILES_AGE = "check_bsfiles_age"
|
79
|
+
BSFILES_AGE = "bsfiles_age"
|
80
|
+
UPDATE_BSFILES = "update_bsfiles"
|
78
81
|
SEARCH = "search"
|
79
82
|
SUBSTRING = "substring"
|
80
83
|
CONFIG = "config"
|
@@ -104,4 +107,6 @@ module NicInfo
|
|
104
107
|
255 => "reserved"
|
105
108
|
}
|
106
109
|
|
110
|
+
BSFILE_LAST_CHECK_FILENAME = "_last_check_time.txt"
|
111
|
+
|
107
112
|
end
|
data/lib/nicinfo/nicinfo_main.rb
CHANGED
@@ -390,10 +390,16 @@ module NicInfo
|
|
390
390
|
end
|
391
391
|
|
392
392
|
if @config.options.get_iana_files
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
393
|
+
get_iana_files
|
394
|
+
else
|
395
|
+
check_bsfiles_age = @config.check_bsfiles_age?
|
396
|
+
update_bsfiles = @config.update_bsfiles?( check_bsfiles_age )
|
397
|
+
if update_bsfiles
|
398
|
+
@config.logger.mesg( "IANA RDAP bootstrap files are old and need to be updated." )
|
399
|
+
get_iana_files
|
400
|
+
elsif check_bsfiles_age
|
401
|
+
@config.logger.mesg( "IANA RDAP bootstrap files are old. Update them with --iana option" )
|
402
|
+
end
|
397
403
|
end
|
398
404
|
|
399
405
|
if @config.options.demo
|
@@ -500,14 +506,21 @@ module NicInfo
|
|
500
506
|
end
|
501
507
|
else
|
502
508
|
json_data = do_rdap_query
|
503
|
-
display_rdap_query( json_data, true )
|
509
|
+
display_rdap_query( json_data, true )
|
504
510
|
end
|
505
511
|
|
506
512
|
|
507
513
|
end
|
508
514
|
|
515
|
+
def get_iana_files
|
516
|
+
get_file_via_http("http://data.iana.org/rdap/asn.json", File.join(@config.rdap_bootstrap_dir, "asn.json"), 0)
|
517
|
+
get_file_via_http("http://data.iana.org/rdap/ipv4.json", File.join(@config.rdap_bootstrap_dir, "ipv4.json"), 0)
|
518
|
+
get_file_via_http("http://data.iana.org/rdap/ipv6.json", File.join(@config.rdap_bootstrap_dir, "ipv6.json"), 0)
|
519
|
+
get_file_via_http("http://data.iana.org/rdap/dns.json", File.join(@config.rdap_bootstrap_dir, "dns.json"), 0)
|
520
|
+
@config.set_bsfiles_last_update_time
|
521
|
+
end
|
522
|
+
|
509
523
|
def do_rdap_query
|
510
|
-
retval = nil
|
511
524
|
if @config.config[ NicInfo::BOOTSTRAP ][ NicInfo::BOOTSTRAP_URL ] == nil && !@config.options.url
|
512
525
|
bootstrap = Bootstrap.new( @config )
|
513
526
|
qtype = @config.options.query_type
|
@@ -565,7 +578,7 @@ module NicInfo
|
|
565
578
|
end
|
566
579
|
inspect_rdap_compliance json_data
|
567
580
|
cache_self_references json_data
|
568
|
-
|
581
|
+
json_data
|
569
582
|
rescue JSON::ParserError => a
|
570
583
|
@config.logger.mesg( "Server returned invalid JSON!" )
|
571
584
|
rescue SocketError => a
|
@@ -604,7 +617,6 @@ module NicInfo
|
|
604
617
|
end
|
605
618
|
@config.logger.trace("Server response code was " + e.response.code)
|
606
619
|
end
|
607
|
-
return retval
|
608
620
|
end
|
609
621
|
|
610
622
|
def display_rdap_query json_data, show_help = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nicinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0.pre.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netaddr
|
@@ -100,12 +100,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - ">"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 1.3.1
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.6.
|
108
|
+
rubygems_version: 2.6.11
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: RDAP Client
|