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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f574db872855ffbfa72d6a22daaf59fdc1aec3b5
4
- data.tar.gz: 414c3b45e8a4fe46e6afc31fc3d02c591a27c485
2
+ SHA256:
3
+ metadata.gz: 7ecaa53b9df142ebd216e7dc88de56ab2f811c4339e9f075c4088f26d5cecd83
4
+ data.tar.gz: af818b3b4a62989a1a4b4f8379601ca184461ad6483361070ac22a021ad83b18
5
5
  SHA512:
6
- metadata.gz: 2eedd1a0b3a0226000664e4c9268874ac1886d7d940668f79826348cfbc285609be465c280a727f332297514ef5138eac095c91ed376881d406713962f8fa438
7
- data.tar.gz: 93bd001ca3321104020bb7a0d1c48324c571cc97e81fc130d114958865eac35e378461b69c9e5e582070100686f9c99c89c74b02a64fada2c48a532bd22f100f
6
+ metadata.gz: 035ad570ca83474c8a2256ca0107507322aacdd7987cdde9c63332158e2cb59f1c2e100d30e384648b711a2e73e77a3d3a36a1e6e65789de74a4154557e23610
7
+ data.tar.gz: 3d10ed8e6f05f03b7d6b2124e831e30e7684a7b505791265db4170ad117f574e4a53977aa8e0ed1abd97fef7f33cdee8f819ac620eaba06e1d4e3adb6a908047
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011,2012,2013,2014 American Registry for Internet Numbers
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
@@ -22,7 +22,7 @@ require 'nicinfo/data_tree'
22
22
  module NicInfo
23
23
 
24
24
  def NicInfo.display_autnum json_data, config, data_tree
25
- autnum = Autnum.new( config ).process( json_data )
25
+ autnum = config.factory.new_autnum.process( json_data )
26
26
  NicInfo::display_object_with_entities( autnum, config, data_tree )
27
27
  end
28
28
 
@@ -47,15 +47,15 @@ module NicInfo
47
47
  def display
48
48
  @config.logger.start_data_item
49
49
  @config.logger.data_title "[ AS NUMBER ]"
50
- @config.logger.terse "Handle", NicInfo::get_handle( @objectclass )
51
- @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass )
50
+ @config.logger.terse "Handle", NicInfo::get_handle( @objectclass ), NicInfo::AttentionType::SUCCESS
51
+ @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass, "autnum", @config )
52
52
  endNum = NicInfo.get_endAutnum @objectclass
53
53
  startNum = NicInfo.get_startAutnum @objectclass
54
54
  if endNum
55
- @config.logger.terse "Start AS Number", startNum
56
- @config.logger.terse "End AS Number", endNum
55
+ @config.logger.terse "Start AS Number", startNum, NicInfo::AttentionType::SUCCESS
56
+ @config.logger.terse "End AS Number", endNum, NicInfo::AttentionType::SUCCESS
57
57
  else
58
- @config.logger.terse "AS Number", startNum
58
+ @config.logger.terse "AS Number", startNum, NicInfo::AttentionType::SUCCESS
59
59
  end
60
60
  @config.logger.extra "Name", NicInfo.get_name( @objectclass )
61
61
  @config.logger.terse "Country", NicInfo.get_country( @objectclass )
data/lib/nicinfo/cache.rb CHANGED
@@ -106,36 +106,6 @@ module NicInfo
106
106
  return count
107
107
  end
108
108
 
109
- def get_last
110
- cache_files = Dir::entries(@config.rdap_cache_dir)
111
- last_file = nil
112
- last_file_mtime = nil
113
- cache_files.each do |file|
114
- full_file_name = File.join(@config.rdap_cache_dir, file)
115
- if !file.start_with?(".")
116
- mtime = File.mtime(full_file_name)
117
- if last_file == nil
118
- last_file = full_file_name
119
- last_file_mtime = mtime
120
- elsif mtime > last_file_mtime
121
- last_file = full_file_name
122
- last_file_mtime = mtime
123
- end
124
- end
125
- end
126
- if last_file
127
- f = File.open(last_file, "r")
128
- data = ''
129
- f.each_line do |line|
130
- data += line
131
- end
132
- f.close
133
- return [last_file, last_file_mtime, data]
134
- end
135
- #else
136
- return nil
137
- end
138
-
139
109
  end
140
110
 
141
111
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011,2012,2013,2014 American Registry for Internet Numbers
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
@@ -67,7 +67,7 @@ module NicInfo
67
67
  entities = Array.new
68
68
  json_entities = NicInfo::get_entitites( objectclass )
69
69
  json_entities.each do |json_entity|
70
- entity = Entity.new( @config )
70
+ entity = @config.factory.new_entity
71
71
  entity.process( json_entity )
72
72
  entities << entity
73
73
  end if json_entities
@@ -76,14 +76,15 @@ module NicInfo
76
76
 
77
77
  def display_remarks objectclass
78
78
  remarks = objectclass[ "remarks" ]
79
- if (Notices::is_excessive_notice(remarks, @config)) && (@config.logger.data_amount != NicInfo::DataAmount::EXTRA_DATA)
80
- @config.logger.datum "Excessive Remarks", "Use \"-V\" or \"--data extra\" to see them."
81
- else
82
- if remarks
83
- if remarks.instance_of?( Array )
79
+ if remarks
80
+ excessive_notice = @config.factory.new_notices.is_excessive_notice(remarks)
81
+ if (excessive_notice && (@config.logger.data_amount != NicInfo::DataAmount::EXTRA_DATA))
82
+ @config.logger.datum "Excessive Remarks", "Use \"-V\" or \"--data extra\" to see them."
83
+ else
84
+ if remarks.instance_of?(Array)
84
85
  remarks.each do |remark|
85
- if remark.instance_of?( Hash )
86
- title = remark[ "title" ]
86
+ if remark.instance_of?(Hash)
87
+ title = remark["title"]
87
88
  @config.logger.datum "Remarks", "-- #{title} --" if title
88
89
  descriptions = NicInfo::get_descriptions remark, @config
89
90
  i = 1
@@ -97,11 +98,11 @@ module NicInfo
97
98
  end if descriptions
98
99
  links = NicInfo::get_links remark, @config
99
100
  if links
100
- @config.logger.datum "More", NicInfo::get_alternate_link( links )
101
- @config.logger.datum "About", NicInfo::get_about_link( links )
102
- @config.logger.datum "TOS", NicInfo::get_tos_link( links )
103
- @config.logger.datum "(C)", NicInfo::get_copyright_link( links )
104
- @config.logger.datum "License", NicInfo::get_license_link( links )
101
+ @config.logger.datum "More", NicInfo::get_alternate_link(links)
102
+ @config.logger.datum "About", NicInfo::get_about_link(links)
103
+ @config.logger.datum "TOS", NicInfo::get_tos_link(links)
104
+ @config.logger.datum "(C)", NicInfo::get_copyright_link(links)
105
+ @config.logger.datum "License", NicInfo::get_license_link(links)
105
106
  end
106
107
  else
107
108
  @config.conf_msgs << "remark is not an object."
@@ -203,6 +204,25 @@ module NicInfo
203
204
  end
204
205
  end
205
206
 
207
+ def display_simple_links links
208
+ if links
209
+ if links.instance_of?( Array )
210
+ alternate = NicInfo.get_alternate_link links
211
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "More", alternate, NicInfo::AttentionType::SECONDARY if alternate
212
+ about = NicInfo.get_about_link links
213
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "About", about, NicInfo::AttentionType::SECONDARY if about
214
+ tos = NicInfo.get_tos_link links
215
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "TOS", tos, NicInfo::AttentionType::SECONDARY if tos
216
+ copyright = NicInfo.get_copyright_link links
217
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "(C)", copyright, NicInfo::AttentionType::SECONDARY if copyright
218
+ license = NicInfo.get_license_link links
219
+ @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "License", license, NicInfo::AttentionType::SECONDARY if license
220
+ else
221
+ @config.conf_msgs << "'links' is not an array."
222
+ end
223
+ end
224
+ end
225
+
206
226
  end
207
227
 
208
228
  class EventActor
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011,2012,2013,2014,2015 American Registry for Internet Numbers
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,9 +15,10 @@
15
15
 
16
16
  require 'fileutils'
17
17
  require 'time'
18
- require 'nicinfo/nicinfo_logger'
19
18
  require 'yaml'
20
19
  require 'ostruct'
20
+ require 'nicinfo/nicinfo_logger'
21
+ require 'nicinfo/factory'
21
22
  require 'nicinfo/constants'
22
23
 
23
24
  module NicInfo
@@ -25,7 +26,7 @@ module NicInfo
25
26
  # Handles configuration of the application
26
27
  class Config
27
28
 
28
- attr_accessor :logger, :config, :rdap_cache_dir, :options, :conf_msgs, :rdap_bootstrap_dir
29
+ attr_accessor :logger, :config, :rdap_cache_dir, :options, :conf_msgs, :rdap_bootstrap_dir, :factory
29
30
 
30
31
  # Intializes the configuration with a place to look for the config file
31
32
  # If the file doesn't exist, a default is used.
@@ -36,6 +37,7 @@ module NicInfo
36
37
  @app_data = app_data
37
38
  @logger = NicInfo::Logger.new
38
39
  @conf_msgs = Array.new
40
+ @factory = NicInfo::Factory.new( self )
39
41
 
40
42
  config_file_name = Config.formulate_config_file_name( @app_data )
41
43
  if File.exist?( config_file_name )
@@ -99,7 +101,7 @@ module NicInfo
99
101
  if config_version == nil || config_version < NicInfo::CONFIG_VERSION
100
102
  # if a reset hasn't been asked for
101
103
  if !@options.reset_config
102
- @logger.mesg( "Your configuration is old. Use --reset to create a new one.")
104
+ @logger.mesg( "Your configuration is old. Use --reset to create a new one.", NicInfo::AttentionType::ERROR )
103
105
  end
104
106
  end
105
107
  end
@@ -222,6 +224,9 @@ module NicInfo
222
224
  @logger.auto_wrap=output[ NicInfo::AUTO_WRAP ]
223
225
  @logger.default_width=output[ NicInfo::DEFAULT_WIDTH ]
224
226
  @logger.detect_width=output[ NicInfo::DETECT_WIDTH ]
227
+
228
+ @logger.color_scheme = output[ NicInfo::COLOR_SCHEME ]
229
+ @logger.validate_color_scheme
225
230
  end
226
231
 
227
232
  def self.clean
@@ -231,7 +236,7 @@ module NicInfo
231
236
  end
232
237
 
233
238
  def self.formulate_app_data_dir
234
- if RUBY_PLATFORM =~ /win32/
239
+ if Gem.win_platform?
235
240
  data_dir = File.join(ENV['APPDATA'], "NicInfo")
236
241
  elsif RUBY_PLATFORM =~ /linux/
237
242
  data_dir = File.join(ENV['HOME'], ".NicInfo")
@@ -282,6 +287,13 @@ output:
282
287
  # or cannot be detected
283
288
  default_width: 80
284
289
 
290
+ # The color scheme to use. Possible values are
291
+ # - DARK for terminals with dark background
292
+ # - LIGHT for terminals with light background
293
+ # - NONE for no color
294
+ # color is turned off automatically if a pager is used and the pager is not 'less'.
295
+ color_scheme: DARK
296
+
285
297
  cache:
286
298
 
287
299
  # The maximum age an item from the cache will be used.
@@ -303,9 +315,9 @@ cache:
303
315
  bootstrap:
304
316
 
305
317
  # The base or bootstrap URL. Specifying this will bypass all built-in bootstrapping.
306
- #base_url: https://rdap.arin.net/bootstrap
318
+ #base_url: https://rdap-bootstrap.arin.net/bootstrap
307
319
 
308
- help_root_url: https://rdap.arin.net/bootstrap
320
+ help_root_url: https://rdap-bootstrap.arin.net/bootstrap
309
321
 
310
322
  entity_root_url: https://rdap.arin.net/registry
311
323
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  module NicInfo
20
20
 
21
- VERSION = "1.3.0-alpha1"
21
+ VERSION = "1.5.0"
22
22
  VERSION_LABEL = "NicInfo v." + VERSION
23
23
  COPYRIGHT = "Copyright (c) 2011-2017 American Registry for Internet Numbers (ARIN)"
24
24
  CONFIG_VERSION = 4
@@ -43,7 +43,7 @@ module NicInfo
43
43
  IPV6_REGEX = /\A(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\z/
44
44
  IPV6_HEXCOMPRESS_REGEX = /\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\z/
45
45
 
46
- #File Name Constants
46
+ # File Name Constants
47
47
  LASTTREE_YAML = "lasttree.yaml"
48
48
  DEMO_DIR = "demo"
49
49
  BOOTSTRAP_FILE_DIR = "bsfiles"
@@ -53,6 +53,21 @@ module NicInfo
53
53
  IPV4_BOOTSTRAP = "ipv4.json"
54
54
  IPV6_BOOTSTRAP = "ipv6.json"
55
55
 
56
+ # JCR Constants
57
+ JCR_DIR = "jcr"
58
+ RDAP_JCR = "rdap.jcr"
59
+ STRICT_RDAP_JCR = "strict.jcr"
60
+ JCR_ROOT_ENTITY = "entity_response"
61
+ JCR_ROOT_NAMESERVER = "nameserver_response"
62
+ JCR_ROOT_DOMAIN = "domain_response"
63
+ JCR_ROOT_NETWORK = "network_response"
64
+ JCR_ROOT_AUTNUM = "autnum_response"
65
+ JCR_ROOT_ERROR = "error_response"
66
+ JCR_ROOT_HELP = "help_response"
67
+ JCR_ROOT_DOMAIN_SEARCH = "domainSearch_response"
68
+ JCR_ROOT_NAMESERVER_SEARCH = "nameserverSearch_response"
69
+ JCR_ROOT_ENTITY_SEARCH = "entitySearch_response"
70
+
56
71
  # Config constants
57
72
  OUTPUT = "output"
58
73
  MESSAGES = "messages"
@@ -63,6 +78,7 @@ module NicInfo
63
78
  AUTO_WRAP = "auto_wrap"
64
79
  DETECT_WIDTH = "detect_width"
65
80
  DEFAULT_WIDTH = "default_width"
81
+ COLOR_SCHEME = "color_scheme"
66
82
  CACHE = "cache"
67
83
  CACHE_EXPIRY = "cache_expiry"
68
84
  CACHE_EVICTION = "cache_eviction"
@@ -144,7 +144,7 @@ module NicInfo
144
144
  end
145
145
  num_count = 1
146
146
  @logger.start_data_item if print_tree
147
- @logger.prose( @data_amount, "[ RESPONSE DATA ]", " ")
147
+ @logger.prose( @data_amount, "[ RESPONSE DATA ]", " ", NicInfo::AttentionType::SUCCESS )
148
148
  @roots.each do |root|
149
149
  if annotate
150
150
  if root.alert
@@ -157,7 +157,7 @@ module NicInfo
157
157
  else
158
158
  s = root.to_s
159
159
  end
160
- retval = @logger.log_tree_item( @data_amount, s )
160
+ retval = @logger.log_tree_item( @data_amount, s, NicInfo::AttentionType::SUCCESS )
161
161
  if annotate
162
162
  prefix = " "
163
163
  child_num = 1
@@ -193,7 +193,7 @@ module NicInfo
193
193
  child_num = 0
194
194
  end
195
195
  prefix = prefix.tr( "`", " ") + spacer + ( node == parent.children.last ? "`" : "|" )
196
- @logger.log_tree_item( @data_amount, prefix + num_str + node.to_s )
196
+ @logger.log_tree_item( @data_amount, prefix + num_str + node.to_s, NicInfo::AttentionType::SUCCESS )
197
197
  node.children.each do |child|
198
198
  rprint( child_num, node, child, prefix )
199
199
  child_num += 1 if child_num > 0
@@ -506,9 +506,9 @@
506
506
  ],
507
507
  "links":[
508
508
  {
509
- "value":"https://rdap.arin.net/bootstrap/domain/xn--fo-5ja.example",
509
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/domain/xn--fo-5ja.example",
510
510
  "rel":"self",
511
- "href":"https://rdap.arin.net/bootstrap/domain/xn--fo-5ja.example"
511
+ "href":"https://rdap-bootstrap.arin.net/bootstrap/domain/xn--fo-5ja.example"
512
512
  }
513
513
  ],
514
514
  "port43":"whois.example.net",
@@ -147,9 +147,9 @@
147
147
  ],
148
148
  "links": [
149
149
  {
150
- "value": "https://rdap.arin.net/bootstrap/entity/entity-dnr",
150
+ "value": "https://rdap-bootstrap.arin.net/bootstrap/entity/entity-dnr",
151
151
  "rel": "self",
152
- "href": "https://rdap.arin.net/bootstrap/entity/entity-dnr"
152
+ "href": "https://rdap-bootstrap.arin.net/bootstrap/entity/entity-dnr"
153
153
  }
154
154
  ],
155
155
  "port43": "whois.example.net",
@@ -286,9 +286,9 @@
286
286
  ],
287
287
  "links": [
288
288
  {
289
- "value": "https://rdap.arin.net/bootstrap/entity/foo1",
289
+ "value": "https://rdap-bootstrap.arin.net/bootstrap/entity/foo1",
290
290
  "rel": "self",
291
- "href": "https://rdap.arin.net/bootstrap/entity/foo1"
291
+ "href": "https://rdap-bootstrap.arin.net/bootstrap/entity/foo1"
292
292
  }
293
293
  ],
294
294
  "events": [
@@ -123,9 +123,9 @@
123
123
  ],
124
124
  "links":[
125
125
  {
126
- "value":"https://rdap.arin.net/bootstrap/entity/entity-dnr",
126
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/entity/entity-dnr",
127
127
  "rel":"self",
128
- "href":"https://rdap.arin.net/bootstrap/entity/entity-dnr"
128
+ "href":"https://rdap-bootstrap.arin.net/bootstrap/entity/entity-dnr"
129
129
  }
130
130
  ],
131
131
  "port43":"whois.example.net",
@@ -132,9 +132,9 @@
132
132
  ],
133
133
  "links":[
134
134
  {
135
- "value":"https://rdap.arin.net/bootstrap/entity/foo1",
135
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/entity/foo1",
136
136
  "rel":"self",
137
- "href":"https://rdap.arin.net/bootstrap/entity/foo1"
137
+ "href":"https://rdap-bootstrap.arin.net/bootstrap/entity/foo1"
138
138
  }
139
139
  ],
140
140
  "events":[
@@ -14,12 +14,41 @@
14
14
  ],
15
15
  "links":[
16
16
  {
17
- "value":"https://rdap.arin.net/bootstrap/entity/restricted",
17
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/entity/restricted",
18
18
  "rel":"terms-of-service",
19
19
  "type":"text/html",
20
20
  "href":"http://www.example.com/tos.html"
21
21
  }
22
22
  ]
23
+ },
24
+ {
25
+ "title":"Copyright",
26
+ "description":[
27
+ "This test data is Copyright (C) 2015-2018 ARIN."
28
+ ],
29
+ "links":[
30
+ {
31
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/entity/restricted",
32
+ "rel":"copyright",
33
+ "type":"text/html",
34
+ "href":"http://www.example.com/copyright.html"
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "title":"About",
40
+ "description":[
41
+ "Questions regarding ARIN's RDAP service should be sent to arin-tech-discuss@arin.net.",
42
+ "See our mailing list for more info."
43
+ ],
44
+ "links":[
45
+ {
46
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/entity/restricted",
47
+ "rel":"about",
48
+ "type":"text/html",
49
+ "href":"https://lists.arin.net/mailman/listinfo/arin-tech-discuss"
50
+ }
51
+ ]
23
52
  }
24
53
  ],
25
54
  "errorCode":418,
@@ -27,8 +27,9 @@
27
27
  "nameserverSearchResults": [
28
28
  {
29
29
  "handle":"XXXX",
30
+ "objectClassName" : "nameserver",
30
31
  "ldhName":"ns1.xn--fo-5ja.example",
31
- "unicodeName":"foo.example",
32
+ "unicodeName":"ns1.foo.example",
32
33
  "status":[ "active" ],
33
34
  "ipAddresses":{
34
35
  "v4":[ "192.0.2.1", "192.0.2.2" ],
@@ -44,9 +45,9 @@
44
45
  ],
45
46
  "links":[
46
47
  {
47
- "value":"https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
48
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
48
49
  "rel":"self",
49
- "href":"https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example"
50
+ "href":"https://rdap-bootstrap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example"
50
51
  }
51
52
  ],
52
53
  "port43":"whois.example.net",
@@ -229,9 +230,9 @@
229
230
  },
230
231
  {
231
232
  "handle":"XXXX2",
232
- "objectClassName":"domain",
233
+ "objectClassName":"nameserver",
233
234
  "ldhName":"ns1.xn--fo-5ja.example",
234
- "unicodeName":"foo.example",
235
+ "unicodeName":"ns1.foo.example",
235
236
  "status":[ "active" ],
236
237
  "ipAddresses":{
237
238
  "v4":[ "192.0.2.1", "192.0.2.2" ],
@@ -247,9 +248,9 @@
247
248
  ],
248
249
  "links":[
249
250
  {
250
- "value":"https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
251
+ "value":"https://rdap-bootstrap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example",
251
252
  "rel":"self",
252
- "href":"https://rdap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example"
253
+ "href":"https://rdap-bootstrap.arin.net/bootstrap/nameserver/ns1.xn--fo-5ja.example"
253
254
  }
254
255
  ],
255
256
  "port43":"whois.example.net",