nicinfo 1.3.0.pre.alpha1 → 1.5.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 +5 -5
- data/lib/nicinfo/autnum.rb +7 -7
- data/lib/nicinfo/cache.rb +0 -30
- data/lib/nicinfo/common_json.rb +34 -14
- data/lib/nicinfo/config.rb +19 -7
- data/lib/nicinfo/constants.rb +18 -2
- data/lib/nicinfo/data_tree.rb +3 -3
- data/lib/nicinfo/demo/domain-dnr.json +2 -2
- data/lib/nicinfo/demo/entities.json +4 -4
- data/lib/nicinfo/demo/entity-dnr.json +2 -2
- data/lib/nicinfo/demo/entity-rir.json +2 -2
- data/lib/nicinfo/demo/error-code.json +30 -1
- data/lib/nicinfo/demo/nameservers.json +8 -7
- data/lib/nicinfo/demo/ns-simple.json +2 -2
- data/lib/nicinfo/demo/ns-very-simple.json +2 -2
- data/lib/nicinfo/demo/ns.json +5 -5
- data/lib/nicinfo/domain.rb +7 -7
- data/lib/nicinfo/entity.rb +98 -87
- data/lib/nicinfo/error_code.rb +15 -18
- data/lib/nicinfo/factory.rb +56 -0
- data/lib/nicinfo/ip.rb +14 -6
- data/lib/nicinfo/jcr/rdap.jcr +807 -0
- data/lib/nicinfo/jcr/strict.jcr +238 -0
- data/lib/nicinfo/nicinfo_logger.rb +145 -46
- data/lib/nicinfo/nicinfo_main.rb +154 -45
- data/lib/nicinfo/notices.rb +30 -37
- data/lib/nicinfo/ns.rb +8 -8
- data/lib/nicinfo/utils.rb +8 -2
- metadata +36 -12
data/lib/nicinfo/notices.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011
|
1
|
+
# Copyright (C) 2011-2017 American Registry for Internet Numbers
|
2
2
|
#
|
3
3
|
# Permission to use, copy, modify, and/or distribute this software for any
|
4
4
|
# purpose with or without fee is hereby granted, provided that the above
|
@@ -15,20 +15,28 @@
|
|
15
15
|
require 'nicinfo/config'
|
16
16
|
require 'nicinfo/nicinfo_logger'
|
17
17
|
require 'nicinfo/utils'
|
18
|
+
require 'nicinfo/common_json'
|
18
19
|
|
19
20
|
module NicInfo
|
20
21
|
|
21
22
|
# deals with RDAP notices structures
|
22
23
|
class Notices
|
23
24
|
|
24
|
-
|
25
|
+
attr_accessor :config
|
26
|
+
|
27
|
+
def initialize( config )
|
28
|
+
@config = config
|
29
|
+
@common = CommonJson.new( config )
|
30
|
+
end
|
31
|
+
|
32
|
+
def is_excessive_notice notices
|
25
33
|
return false if !notices
|
26
34
|
return false if notices.length == 0
|
27
35
|
return true if notices.length > 2
|
28
36
|
word_count = 0
|
29
37
|
line_count = 0
|
30
38
|
notices.each do |notice|
|
31
|
-
descriptions = NicInfo::get_descriptions notice, config
|
39
|
+
descriptions = NicInfo::get_descriptions notice, @config
|
32
40
|
descriptions.each do |line|
|
33
41
|
line_count = line_count + 1
|
34
42
|
word_count = word_count + line.length
|
@@ -40,69 +48,54 @@ module NicInfo
|
|
40
48
|
return false
|
41
49
|
end
|
42
50
|
|
43
|
-
def display_notices json_response,
|
51
|
+
def display_notices json_response, ignore_excessive
|
44
52
|
|
45
53
|
notices = json_response[ "notices" ]
|
46
54
|
return if notices == nil
|
47
|
-
if (
|
48
|
-
config.logger.start_data_item
|
49
|
-
config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "Excessive Notices"
|
50
|
-
config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "-----------------"
|
51
|
-
config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "Response contains excessive notices."
|
52
|
-
config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "Use the \"-V\" or \"--data extra\" options to see them."
|
53
|
-
config.logger.end_data_item
|
55
|
+
if (is_excessive_notice(notices) ) && (@config.logger.data_amount != NicInfo::DataAmount::EXTRA_DATA) && !ignore_excessive
|
56
|
+
@config.logger.start_data_item
|
57
|
+
@config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "Excessive Notices", NicInfo::AttentionType::INFO
|
58
|
+
@config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "-----------------", NicInfo::AttentionType::INFO
|
59
|
+
@config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "Response contains excessive notices.", NicInfo::AttentionType::INFO
|
60
|
+
@config.logger.raw NicInfo::DataAmount::NORMAL_DATA, "Use the \"-V\" or \"--data extra\" options to see them.", NicInfo::AttentionType::INFO
|
61
|
+
@config.logger.end_data_item
|
54
62
|
else
|
55
63
|
notices.each do |notice|
|
56
|
-
display_single_notice notice
|
64
|
+
display_single_notice notice
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
60
68
|
end
|
61
69
|
|
62
|
-
def display_single_notice notice
|
63
|
-
config.logger.start_data_item
|
70
|
+
def display_single_notice notice
|
71
|
+
@config.logger.start_data_item
|
64
72
|
title = notice[ "title" ]
|
65
73
|
if title == nil
|
66
74
|
title = ""
|
67
75
|
end
|
68
|
-
config.conf_msgs << "'title' in 'notice' is not a string." unless title.instance_of?( String )
|
69
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "[ NOTICE ]", title
|
76
|
+
@config.conf_msgs << "'title' in 'notice' is not a string." unless title.instance_of?( String )
|
77
|
+
@config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "[ NOTICE ]", title, NicInfo::AttentionType::SECONDARY
|
70
78
|
type = notice[ "type" ]
|
71
79
|
if type != nil
|
72
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "Type", NicInfo.capitalize( type )
|
80
|
+
@config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "Type", NicInfo.capitalize( type ), NicInfo::AttentionType::SECONDARY
|
73
81
|
end
|
74
82
|
description = notice[ "description" ]
|
75
83
|
i = 1
|
76
84
|
if description.instance_of?( Array )
|
77
85
|
description.each do |line|
|
78
86
|
if line.instance_of?( String )
|
79
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, i.to_s, line
|
87
|
+
@config.logger.prose NicInfo::DataAmount::NORMAL_DATA, i.to_s, line, NicInfo::AttentionType::SECONDARY
|
80
88
|
i = i + 1
|
81
89
|
else
|
82
|
-
config.conf_msgs << "eleemnt of 'description' in 'notice' is not a string."
|
90
|
+
@config.conf_msgs << "eleemnt of 'description' in 'notice' is not a string."
|
83
91
|
end
|
84
92
|
end
|
85
93
|
else
|
86
|
-
config.conf_msgs << "'description' in 'notice' is not an array."
|
94
|
+
@config.conf_msgs << "'description' in 'notice' is not an array."
|
87
95
|
end
|
88
96
|
links = notice[ "links" ]
|
89
|
-
|
90
|
-
|
91
|
-
alternate = NicInfo.get_alternate_link links
|
92
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "More", alternate if alternate
|
93
|
-
about = NicInfo.get_about_link links
|
94
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "About", about if about
|
95
|
-
tos = NicInfo.get_tos_link links
|
96
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "TOS", tos if tos
|
97
|
-
copyright = NicInfo.get_copyright_link links
|
98
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "(C)", copyright if copyright
|
99
|
-
license = NicInfo.get_license_link links
|
100
|
-
config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "License", license if license
|
101
|
-
else
|
102
|
-
config.conf_msgs << "'links' is not an array."
|
103
|
-
end
|
104
|
-
end
|
105
|
-
config.logger.end_data_item
|
97
|
+
@common.display_simple_links( links )
|
98
|
+
@config.logger.end_data_item
|
106
99
|
end
|
107
100
|
|
108
101
|
end
|
data/lib/nicinfo/ns.rb
CHANGED
@@ -22,7 +22,7 @@ require 'nicinfo/data_tree'
|
|
22
22
|
module NicInfo
|
23
23
|
|
24
24
|
def NicInfo.display_ns json_data, config, data_node
|
25
|
-
ns =
|
25
|
+
ns = config.factory.new_ns.process( json_data )
|
26
26
|
NicInfo::display_object_with_entities( ns, config, data_node )
|
27
27
|
end
|
28
28
|
|
@@ -32,7 +32,7 @@ module NicInfo
|
|
32
32
|
if ns_array.instance_of? Array
|
33
33
|
display_array = Array.new
|
34
34
|
ns_array.each do |ea|
|
35
|
-
ns =
|
35
|
+
ns = config.factory.new_ns.process( ea )
|
36
36
|
display_array << ns
|
37
37
|
end
|
38
38
|
NicInfo::display_object_with_entities( display_array, config, data_node )
|
@@ -65,19 +65,19 @@ module NicInfo
|
|
65
65
|
def display
|
66
66
|
@config.logger.start_data_item
|
67
67
|
@config.logger.data_title "[ NAME SERVER ]"
|
68
|
-
@config.logger.terse "Handle", NicInfo::get_handle( @objectclass )
|
69
|
-
@config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass )
|
70
|
-
@config.logger.terse "Host Name", NicInfo::get_ldhName( @objectclass )
|
71
|
-
@config.logger.terse "IDN Host Name", NicInfo::get_unicodeName( @objectclass )
|
68
|
+
@config.logger.terse "Handle", NicInfo::get_handle( @objectclass ), NicInfo::AttentionType::SUCCESS
|
69
|
+
@config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass, "nameserver", @config )
|
70
|
+
@config.logger.terse "Host Name", NicInfo::get_ldhName( @objectclass ), NicInfo::AttentionType::SUCCESS
|
71
|
+
@config.logger.terse "IDN Host Name", NicInfo::get_unicodeName( @objectclass ), NicInfo::AttentionType::SUCCESS
|
72
72
|
ipAddrs = @objectclass[ "ipAddresses" ]
|
73
73
|
if ipAddrs
|
74
74
|
v6Addrs = ipAddrs[ "v6" ]
|
75
75
|
v6Addrs.each do |v6|
|
76
|
-
@config.logger.terse "IPv6 Address", v6
|
76
|
+
@config.logger.terse "IPv6 Address", v6, NicInfo::AttentionType::SUCCESS
|
77
77
|
end if v6Addrs
|
78
78
|
v4Addrs = ipAddrs[ "v4" ]
|
79
79
|
v4Addrs.each do |v4|
|
80
|
-
@config.logger.terse "IPv4 Address", v4
|
80
|
+
@config.logger.terse "IPv4 Address", v4, NicInfo::AttentionType::SUCCESS
|
81
81
|
end if v4Addrs
|
82
82
|
end
|
83
83
|
@common.display_status @objectclass
|
data/lib/nicinfo/utils.rb
CHANGED
@@ -55,8 +55,14 @@ module NicInfo
|
|
55
55
|
return json_data[ "handle" ]
|
56
56
|
end
|
57
57
|
|
58
|
-
def NicInfo.get_object_class_name json_data
|
59
|
-
|
58
|
+
def NicInfo.get_object_class_name json_data, expected, config
|
59
|
+
objectClassName = json_data[ "objectClassName" ]
|
60
|
+
if objectClassName == nil
|
61
|
+
config.conf_msgs << "Expected 'objectClassName' is not present."
|
62
|
+
elsif objectClassName != expected
|
63
|
+
config.conf_msgs << "Expected 'objectClassName' to be '#{expected}' but it is '#{objectClassName}'."
|
64
|
+
end
|
65
|
+
return objectClassName
|
60
66
|
end
|
61
67
|
|
62
68
|
def NicInfo.get_ldhName json_data
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netaddr
|
@@ -16,20 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
|
19
|
+
version: 2.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rainbow
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
21
32
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
33
|
+
version: '3.0'
|
23
34
|
type: :runtime
|
24
35
|
prerelease: false
|
25
36
|
version_requirements: !ruby/object:Gem::Requirement
|
26
37
|
requirements:
|
27
38
|
- - "~>"
|
28
39
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jcrvalidator
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
31
53
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
54
|
+
version: 0.8.3
|
33
55
|
description: A command-line RDAP client.
|
34
56
|
email: andy@arin.net
|
35
57
|
executables:
|
@@ -74,8 +96,11 @@ files:
|
|
74
96
|
- lib/nicinfo/entity.rb
|
75
97
|
- lib/nicinfo/enum.rb
|
76
98
|
- lib/nicinfo/error_code.rb
|
99
|
+
- lib/nicinfo/factory.rb
|
77
100
|
- lib/nicinfo/female-first-names.txt
|
78
101
|
- lib/nicinfo/ip.rb
|
102
|
+
- lib/nicinfo/jcr/rdap.jcr
|
103
|
+
- lib/nicinfo/jcr/strict.jcr
|
79
104
|
- lib/nicinfo/key_data.rb
|
80
105
|
- lib/nicinfo/last-names.txt
|
81
106
|
- lib/nicinfo/male-first-names.txt
|
@@ -100,12 +125,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
125
|
version: '0'
|
101
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
127
|
requirements:
|
103
|
-
- - "
|
128
|
+
- - ">="
|
104
129
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
130
|
+
version: '0'
|
106
131
|
requirements: []
|
107
|
-
|
108
|
-
rubygems_version: 2.6.11
|
132
|
+
rubygems_version: 3.0.3
|
109
133
|
signing_key:
|
110
134
|
specification_version: 4
|
111
135
|
summary: RDAP Client
|