nicinfo 0.2.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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/bin/nicinfo +22 -0
  3. data/lib/autnum.rb +90 -0
  4. data/lib/bootstrap.rb +198 -0
  5. data/lib/bsfiles/asn.json +2326 -0
  6. data/lib/bsfiles/dns.json +25 -0
  7. data/lib/bsfiles/entity.json +52 -0
  8. data/lib/bsfiles/ipv4.json +244 -0
  9. data/lib/bsfiles/ipv6.json +97 -0
  10. data/lib/cache.rb +141 -0
  11. data/lib/common_json.rb +263 -0
  12. data/lib/common_names.rb +49 -0
  13. data/lib/config.rb +260 -0
  14. data/lib/constants.rb +113 -0
  15. data/lib/data_tree.rb +205 -0
  16. data/lib/demo/autnum.json +228 -0
  17. data/lib/demo/domain-dnr.json +695 -0
  18. data/lib/demo/domain-rir.json +569 -0
  19. data/lib/demo/domains.json +625 -0
  20. data/lib/demo/entities.json +545 -0
  21. data/lib/demo/entity-dnr.json +143 -0
  22. data/lib/demo/entity-rir.json +394 -0
  23. data/lib/demo/error-code.json +31 -0
  24. data/lib/demo/help.json +58 -0
  25. data/lib/demo/ip.json +306 -0
  26. data/lib/demo/nameservers.json +434 -0
  27. data/lib/demo/ns-simple.json +210 -0
  28. data/lib/demo/ns-very-simple.json +41 -0
  29. data/lib/demo/ns.json +63 -0
  30. data/lib/demo/simple-ip.json +41 -0
  31. data/lib/demo/simple.json +13 -0
  32. data/lib/domain.rb +203 -0
  33. data/lib/ds_data.rb +70 -0
  34. data/lib/entity.rb +372 -0
  35. data/lib/enum.rb +47 -0
  36. data/lib/error_code.rb +56 -0
  37. data/lib/female-first-names.txt +4275 -0
  38. data/lib/ip.rb +86 -0
  39. data/lib/key_data.rb +70 -0
  40. data/lib/last-names.txt +88799 -0
  41. data/lib/male-first-names.txt +1219 -0
  42. data/lib/nicinfo_logger.rb +370 -0
  43. data/lib/nicinfo_main.rb +1013 -0
  44. data/lib/notices.rb +110 -0
  45. data/lib/ns.rb +108 -0
  46. data/lib/utils.rb +189 -0
  47. metadata +90 -0
data/lib/data_tree.rb ADDED
@@ -0,0 +1,205 @@
1
+ # Copyright (C) 2011,2012,2013,2014 American Registry for Internet Numbers
2
+ #
3
+ # Permission to use, copy, modify, and/or distribute this software for any
4
+ # purpose with or without fee is hereby granted, provided that the above
5
+ # copyright notice and this permission notice appear in all copies.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
13
+ # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+
15
+
16
+ require 'yaml'
17
+ require 'nicinfo_logger'
18
+
19
+ module NicInfo
20
+
21
+ class DataNode
22
+
23
+ attr_accessor :alert, :handle, :rest_ref, :data, :children, :data_type
24
+
25
+ def initialize name, handle = nil, rest_ref = nil, data = nil, data_type = nil
26
+ @name = name
27
+ @children = []
28
+ @data = data
29
+ @handle = handle
30
+ @rest_ref = rest_ref
31
+ @data_type = data_type
32
+ end
33
+
34
+ def add_child node
35
+ @children << node if node
36
+ end
37
+
38
+ def to_s
39
+ @name
40
+ end
41
+
42
+ def empty?
43
+ @children.empty?
44
+ end
45
+
46
+ def <=> x
47
+ @name <=> x.to_s
48
+ end
49
+
50
+ def has_meta_info
51
+ return true if @handle
52
+ return true if @rest_ref
53
+ return true if @data
54
+ return false
55
+ end
56
+
57
+ end
58
+
59
+ class DataTree
60
+
61
+ def initialize
62
+ @roots = []
63
+ end
64
+
65
+ def add_root node
66
+ @roots << node if node
67
+ end
68
+
69
+ def add_child node
70
+ add_root( node )
71
+ end
72
+
73
+ def add_children_as_root node
74
+ node.children.each do |child|
75
+ add_root( child )
76
+ end if node
77
+ end
78
+
79
+ def roots
80
+ @roots
81
+ end
82
+
83
+ def empty?
84
+ @roots.empty?
85
+ end
86
+
87
+ def find_data data_address
88
+ node = find_node data_address
89
+ return node.data if node
90
+ return nil
91
+ end
92
+
93
+ def find_handle data_address
94
+ node = find_node data_address
95
+ return node.handle if node
96
+ return nil
97
+ end
98
+
99
+ def find_rest_ref data_address
100
+ node = find_node data_address
101
+ return node.rest_ref if node
102
+ return nil
103
+ end
104
+
105
+ def find_node data_address
106
+ node = NicInfo::DataNode.new( "fakeroot" )
107
+ node.children=roots
108
+ data_address.split( /\D/ ).each do |index_str|
109
+ index = index_str.to_i - 1
110
+ node = node.children[ index ] if node
111
+ end
112
+ if node != nil
113
+ return node
114
+ end
115
+ #else
116
+ return nil
117
+ end
118
+
119
+ def to_terse_log logger, annotate = false
120
+ @logger = logger
121
+ @data_amount = DataAmount::TERSE_DATA
122
+ to_log( annotate )
123
+ end
124
+
125
+ def to_normal_log logger, annotate = false
126
+ @logger = logger
127
+ @data_amount = DataAmount::NORMAL_DATA
128
+ to_log( annotate )
129
+ end
130
+
131
+ def to_extra_log logger, annotate = false
132
+ @logger = logger
133
+ @data_amount = DataAmount::EXTRA_DATA
134
+ to_log( annotate )
135
+ end
136
+
137
+ private
138
+
139
+ def to_log annotate
140
+ retval = false
141
+ print_tree = false
142
+ @roots.each do |root|
143
+ print_tree = true unless root.children.empty?
144
+ end
145
+ num_count = 1
146
+ @roots.each do |root|
147
+ @logger.start_data_item if print_tree
148
+ @logger.prose( @data_amount, "[ RESPONSE DATA ]", " ")
149
+ if annotate
150
+ if root.alert
151
+ s = format( " # %s", root.to_s )
152
+ elsif root.has_meta_info
153
+ s = format( "%3d= %s", num_count, root.to_s )
154
+ else
155
+ s = format( "%3d. %s", num_count, root.to_s )
156
+ end
157
+ else
158
+ s = root.to_s
159
+ end
160
+ retval = @logger.log_tree_item( @data_amount, s )
161
+ if annotate
162
+ prefix = " "
163
+ child_num = 1
164
+ else
165
+ prefix = ""
166
+ child_num = 0
167
+ end
168
+ root.children.each do |child|
169
+ rprint( child_num, root, child, prefix )
170
+ child_num += 1 if child_num > 0
171
+ end if root.children() != nil
172
+ num_count += 1
173
+ @logger.end_data_item
174
+ end if print_tree
175
+ return retval
176
+ end
177
+
178
+ def rprint( num, parent, node, prefix )
179
+ if( num > 0 )
180
+ spacer = " "
181
+ if node.alert
182
+ num_str = format( " # ", num )
183
+ elsif node.has_meta_info
184
+ num_str = format( " %d= ", num )
185
+ else
186
+ num_str = format( " %d. ", num )
187
+ end
188
+ num_str = num_str.rjust( 7, "-" )
189
+ child_num = 1
190
+ else
191
+ spacer = " "
192
+ num_str = "- "
193
+ child_num = 0
194
+ end
195
+ prefix = prefix.tr( "`", " ") + spacer + ( node == parent.children.last ? "`" : "|" )
196
+ @logger.log_tree_item( @data_amount, prefix + num_str + node.to_s )
197
+ node.children.each do |child|
198
+ rprint( child_num, node, child, prefix )
199
+ child_num += 1 if child_num > 0
200
+ end if node.children() != nil
201
+ end
202
+
203
+ end
204
+
205
+ end
@@ -0,0 +1,228 @@
1
+ {
2
+ "nicInfo_demoUrl":"http://rdappilot.arin.net/restfulwhois/rdap/autnum/10",
3
+ "nicInfo_demoHint":"nicinfo as10",
4
+ "rdapConformance":[
5
+ "rdap_level_0"
6
+ ],
7
+ "notices":[
8
+ {
9
+ "title":"ARIN's RDAP Service",
10
+ "description":[
11
+ "ARIN has been a leader in RESTful Whois technologies and is proud to offer the Registration Data Access Protocol service.",
12
+ "ARIN's RDAP server is complaint with RDAP Level 0."
13
+ ]
14
+ },
15
+ {
16
+ "title":"Terms of Use",
17
+ "description":[
18
+ "ARIN WHOIS data and services are subject to the Terms of Use available at: https://www.arin.net/whois_tou.html"
19
+ ],
20
+ "links":[
21
+ {
22
+ "value":"http://whois.apnic.net/ip/2001:db8::0",
23
+ "rel":"terms-of-service",
24
+ "type":"text/html",
25
+ "href":"https://www.arin.net/whois_tou.html"
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "handle":"AS10-RIR",
31
+ "objectClassName":"autnum",
32
+ "startAutnum":10,
33
+ "endAutnum":15,
34
+ "name":"AS-RTR-1",
35
+ "description":[ "AS for Exchange" ],
36
+ "type":"DIRECT ALLOCATION",
37
+ "country":"AU",
38
+ "remarks":[
39
+ {
40
+ "description":[
41
+ "She sells sea shells down by the sea shore.",
42
+ "Originally written by Terry Sullivan."
43
+ ]
44
+ }
45
+ ],
46
+ "links":[
47
+ {
48
+ "value":"http://rdappilot.arin.net/restfulwhois/rdap/autnum/10",
49
+ "rel":"self",
50
+ "href":"http://rdappilot.arin.net/restfulwhois/rdap/autnum/10"
51
+ }
52
+ ],
53
+ "events":[
54
+ {
55
+ "eventAction":"registration",
56
+ "eventDate":"1990-12-31T23:59:60Z"
57
+ },
58
+ {
59
+ "eventAction":"last changed",
60
+ "eventDate":"1991-12-31T23:59:60Z"
61
+ }
62
+ ],
63
+ "entities":[
64
+ {
65
+ "handle":"MATTR-ARIN",
66
+ "objectClassName":"entity",
67
+ "vcardArray":[
68
+ "vcard",
69
+ [
70
+ ["version", {}, "text", "4.0"],
71
+ ["fn", {}, "text", "Matt Rowley"],
72
+ ["kind", {}, "text", "individual"],
73
+ ["org", {
74
+ "type":"work"
75
+ }, "text", "American Registry for Internet Numbers"],
76
+ ["title", {}, "text", "Operations Manager"],
77
+ ["role", {}, "text", "Project Lead"],
78
+ ["adr",
79
+ {
80
+ "type":"work"
81
+ },
82
+ "text",
83
+ [
84
+ "",
85
+ "Suite 200",
86
+ "3635 Concorde Parkway",
87
+ "Chantilly",
88
+ "VA",
89
+ "20151",
90
+ "United States"
91
+ ]
92
+ ],
93
+ ["tel",
94
+ {
95
+ "type":["work", "voice"],
96
+ "pref":"1"
97
+ },
98
+ "uri",
99
+ "tel:+1-703-227-9840"
100
+ ],
101
+ ["email",
102
+ {
103
+ "type":"work"
104
+ },
105
+ "text",
106
+ "info@arin.net"
107
+ ]
108
+ ]
109
+ ],
110
+ "roles":[ "administrative" ],
111
+ "remarks":[
112
+ {
113
+ "title": "No Solicitations",
114
+ "description":[
115
+ "Absolutely no solicitations are accepted at by this contact. If you wish to offer services or products to the American Registry for Internet Numbers, contact Pete Toscano at +1-703-227-9840."
116
+ ]
117
+ }
118
+ ],
119
+ "links":[
120
+ {
121
+ "value":"http://example.net/entity/MATTR-ARIN",
122
+ "rel":"self",
123
+ "href":"http://example.net/entity/MATTR-ARIN"
124
+ }
125
+ ],
126
+ "events":[
127
+ {
128
+ "eventAction":"registration",
129
+ "eventDate":"2012-12-31T23:59:60Z",
130
+ "eventActor": "mattr@arin.net"
131
+ },
132
+ {
133
+ "eventAction":"last changed",
134
+ "eventDate":"2013-12-31T23:59:60Z",
135
+ "eventActor": "mattr@arin.net"
136
+ }
137
+ ],
138
+ "asEventActor":[
139
+ {
140
+ "eventAction":"last changed",
141
+ "eventDate":"2013-12-31T23:59:60Z"
142
+ }
143
+ ]
144
+ },
145
+ {
146
+ "handle":"MAK21-ARIN",
147
+ "objectClassName":"entity",
148
+ "vcardArray":[
149
+ "vcard",
150
+ [
151
+ ["version", {}, "text", "4.0"],
152
+ ["fn", {}, "text", "Mark Kosters"],
153
+ ["kind", {}, "text", "individual"],
154
+ ["org", {
155
+ "type":"work"
156
+ }, "text", "American Registry for Internet Numbers"],
157
+ ["title", {}, "text", "Chief Technical Officer"],
158
+ ["role", {}, "text", "Pointy Haired Boss"],
159
+ ["adr",
160
+ {
161
+ "type":"work",
162
+ "label" : "3635 Concorde Parkway\nSuite200\nChantilly\nVA\n20151"
163
+ },
164
+ "text",
165
+ [
166
+ "",
167
+ "",
168
+ "",
169
+ "",
170
+ "",
171
+ "",
172
+ ""
173
+ ]
174
+ ],
175
+ ["tel",
176
+ {
177
+ "type":["work", "voice"],
178
+ "pref":"1"
179
+ },
180
+ "uri",
181
+ "tel:+1-703-227-9840"
182
+ ],
183
+ ["email",
184
+ {
185
+ "type":"work"
186
+ },
187
+ "text",
188
+ "info@arin.net"
189
+ ]
190
+ ]
191
+ ],
192
+ "roles":[ "technical" ],
193
+ "remarks":[
194
+ {
195
+ "title": "No Solicitations",
196
+ "description":[
197
+ "Absolutely no solicitations are accepted at by this contact. If you wish to offer services or products to the American Registry for Internet Numbers, contact Pete Toscano at +1-703-227-9840."
198
+ ]
199
+ }
200
+ ],
201
+ "links":[
202
+ {
203
+ "value":"http://example.net/entity/MAK21-ARIN",
204
+ "rel":"self",
205
+ "href":"http://example.net/entity/MAK21-ARIN"
206
+ }
207
+ ],
208
+ "events":[
209
+ {
210
+ "eventAction":"registration",
211
+ "eventDate":"2012-12-31T23:59:60Z",
212
+ "eventActor": "markk@arin.net"
213
+ },
214
+ {
215
+ "eventAction":"last changed",
216
+ "eventDate":"2013-12-31T23:59:60Z",
217
+ "eventActor": "markkb@arin.net"
218
+ }
219
+ ],
220
+ "asEventActor":[
221
+ {
222
+ "eventAction":"reregistration",
223
+ "eventDate":"2012-12-31T23:59:60Z"
224
+ }
225
+ ]
226
+ }
227
+ ]
228
+ }