Module: NicInfo
- Defined in:
- lib/nicinfo/enum.rb,
lib/nicinfo/ip.rb,
lib/nicinfo/ns.rb,
lib/nicinfo/cache.rb,
lib/nicinfo/utils.rb,
lib/nicinfo/autnum.rb,
lib/nicinfo/config.rb,
lib/nicinfo/domain.rb,
lib/nicinfo/entity.rb,
lib/nicinfo/ds_data.rb,
lib/nicinfo/factory.rb,
lib/nicinfo/notices.rb,
lib/nicinfo/key_data.rb,
lib/nicinfo/bootstrap.rb,
lib/nicinfo/constants.rb,
lib/nicinfo/data_tree.rb,
lib/nicinfo/error_code.rb,
lib/nicinfo/traceroute.rb,
lib/nicinfo/common_json.rb,
lib/nicinfo/common_names.rb,
lib/nicinfo/nicinfo_main.rb,
lib/nicinfo/nicinfo_logger.rb
Overview
IPv4 and IPv6 regular expressions are credited to Mike Poulson and are found here:
http://blogs.msdn.com/b/mpoulson/archive/2005/01/10/350037.aspx
Defined Under Namespace
Classes: Adr, AttentionType, Autnum, Bootstrap, Cache, ColorScheme, CommonJson, Config, DataAmount, DataNode, DataTree, Domain, DsData, Email, Entity, Enum, ErrorCode, EventActor, Factory, Ip, JCard, JcrMode, KeyData, Logger, Main, MessageLevel, MyHTTPResponse, Notices, Ns, Org, QueryType, ResponseObjSet, Tel
Constant Summary
collapse
- VERSION =
"1.5.0"
- VERSION_LABEL =
"NicInfo v." + VERSION
- COPYRIGHT =
"Copyright (c) 2011-2017 American Registry for Internet Numbers (ARIN)"
- CONFIG_VERSION =
4
- NET_HANDLE_REGEX =
/^NET-.*/i
- NET6_HANDLE_REGEX =
/^NET6-.*/i
- AS_REGEX =
/^[0-9]{1,10}$/
- ASN_REGEX =
/^AS[0-9]{1,20}$/i
- IP4_ARPA =
/\.in-addr\.arpa[\.]?/i
- IP6_ARPA =
/\.ip6\.arpa[\.]?/i
- DATA_TREE_ADDR_REGEX =
/\d=$/
- DOMAIN_REGEX =
/^([\S\-]+\.?)+\.([a-z][a-z0\-]+)\.?$/i
- DOMAIN_SRCH_REGEX =
/^([\S\-]+\.?)+\.([a-z][a-z0\-\*]+)\.?$/i
- NS_REGEX =
/^ns[0-9]\.([\S\-]+\.?)+\.([a-z][a-z0\-]+)\.?$/i
- URL_REGEX =
/^(http|https):\/\/.*/
- ENTITY_REGEX =
/^.*\-.*/
- IPV4_REGEX =
IPv4 and IPv6 regular expressions are credited to Mike Poulson and are found here:
http://blogs.msdn.com/b/mpoulson/archive/2005/01/10/350037.aspx
/\A(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\z/
- IPV6_REGEX =
/\A(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\z/
- 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/
- LASTTREE_YAML =
"lasttree.yaml"
- DEMO_DIR =
"demo"
- BOOTSTRAP_FILE_DIR =
"bsfiles"
- ASN_BOOTSTRAP =
"asn.json"
- DNS_BOOTSTRAP =
"dns.json"
- ENTITY_BOOTSTRAP =
"entity.json"
- IPV4_BOOTSTRAP =
"ipv4.json"
- IPV6_BOOTSTRAP =
"ipv6.json"
- JCR_DIR =
"jcr"
- RDAP_JCR =
"rdap.jcr"
- STRICT_RDAP_JCR =
"strict.jcr"
- JCR_ROOT_ENTITY =
"entity_response"
- JCR_ROOT_NAMESERVER =
"nameserver_response"
- JCR_ROOT_DOMAIN =
"domain_response"
- JCR_ROOT_NETWORK =
"network_response"
- JCR_ROOT_AUTNUM =
"autnum_response"
- JCR_ROOT_ERROR =
"error_response"
- JCR_ROOT_HELP =
"help_response"
- JCR_ROOT_DOMAIN_SEARCH =
"domainSearch_response"
- JCR_ROOT_NAMESERVER_SEARCH =
"nameserverSearch_response"
- JCR_ROOT_ENTITY_SEARCH =
"entitySearch_response"
- OUTPUT =
"output"
- MESSAGES =
"messages"
- MESSAGES_FILE =
"messages_file"
- DATA =
"data"
- DATA_FILE =
"data_file"
"pager"
- AUTO_WRAP =
"auto_wrap"
- DETECT_WIDTH =
"detect_width"
- DEFAULT_WIDTH =
"default_width"
- COLOR_SCHEME =
"color_scheme"
- CACHE =
"cache"
- CACHE_EXPIRY =
"cache_expiry"
- CACHE_EVICTION =
"cache_eviction"
- USE_CACHE =
"use_cache"
- CLEAN_CACHE =
"clean_cache"
- BOOTSTRAP =
"bootstrap"
- BOOTSTRAP_URL =
"bootstrap_url"
- HELP_ROOT_URL =
"help_root_url"
- ENTITY_ROOT_URL =
"entity_root_url"
- IP_ROOT_URL =
"ip_root_url"
- AS_ROOT_URL =
"as_root_url"
- DOMAIN_ROOT_URL =
"domain_root_url"
- CHECK_BSFILES_AGE =
"check_bsfiles_age"
- BSFILES_AGE =
"bsfiles_age"
- UPDATE_BSFILES =
"update_bsfiles"
- SEARCH =
"search"
- SUBSTRING =
"substring"
- CONFIG =
"config"
- VERSION_CONFIG =
"version"
- SECURITY =
"security"
- TRY_INSECURE =
"try_insecure"
- NICINFO_DEMO_URL =
"nicInfo_demoUrl"
- NICINFO_DEMO_HINT =
"nicInfo_demoHint"
- NICINFO_DEMO_ERROR =
"nicInfo_demoError"
- RDAP_CONTENT_TYPE =
"application/rdap+json"
- JSON_CONTENT_TYPE =
"application/json"
- DNSSEC_ALGORITHMS =
{
0 => "reserved",
1 => "RSA/MD5",
2 => "Diffie-Hellman",
3 => "DSA/SHA-1",
4 => "Elliptic Curve",
5 => "RSA/SHA-1",
252 => "Indirect",
253 => "Private DNS",
254 => "Private OID",
255 => "reserved"
}
- BSFILE_LAST_CHECK_FILENAME =
"_last_check_time.txt"
- EXTENDED_HELP =
<<EXTENDED_HELP
QUERIES
For most query values, the query type is inferred. However, some types of queries
cannot be inferred and so the -t parameter must be used. The domain search by name
(dsbyname) and entity search by name (esbyname) queries can take wildcards ('*'),
but these must be quoted or escaped to avoid processing by the invoking OS shell
on Unix-like operating systems.
CONFIGURATION
When this program is run for the first time, it creates a directory called .NicInfo
(on Unix style platforms) or NicInfo (on Windows) in the users home directory. The
home directory is determined by the $HOME environment variable on Unix style platforms
and $APPDATA on Windows.
A configuration file is created in this directory called config.yaml. This is a YAML
file and contains a means for specifying most of the features of this program (instead
of needing to specify them on the command line as options). To set the configuration
back to the installation defaults, use the --reset option. This maybe desirable when
updating versions of this program.
A directory called rdap_cache is also created inside this directory. It holds cached
values from previously executed queries.
CACHING
This program will write query responses to a cache. By default, answers are pulled
from the cache if present. This can be turned on or off with the --cache parameter or
using the cache/use_cache value in the configuration file.
Expiration of items in the cache and eviction of items from the cache can also be
controlled. The cache can be manually emptied using the --empty-cache parameter.
BOOTSTRAPPING
Bootstrapping is the process of finding an appropriate RDAP server in which to send
queries. This program has a three tier bootstrapping process.
The first tier looks up the most appropriate server using internal tables compiled
from IANA registries. If an appropriate server cannot be found, bootstrapping falls
to the second tier.
The second tier has a default server for each type of RDAP query (domain, ip, autnum,
nameserver, and entity). If this program cannot determine the type of query, bootstrapping
falls to the third tier.
The third tier is a default server for all queries.
All bootstrap URLs are specified in the configuration file. Bootstrapping maybe
bypassed using the -b or --base option (or by setting the bootstrap/base_url in the
configuration file).
USAGE FOR SCRIPTING
For usage with shell scripting, there are a couple of useful command line parameters.
The --json parameter suppresses the human-readable output and instead emits the JSON
returned by the server. When not writing to an output file, this options should be
used with the -Q option to suppress the pager and program runtime messages so that
the JSON maybe run through a JSON parser.
The --jv parameter instructs this program to parse the JSON and emit specific JSON
values. This parameter is also useful in combination with the -Q option to feed the
JSON values into other programs. The syntax for specifying a JSON value is a
list of JSON object member names or integers signifying JSON array indexes separated
by a period, such as name1.name2.3.name4.5. For example, "entities.0.handle" would
be useful for getting at the "handle" value from the following JSON:
{ "entities" : [ { "handle": "foo" } ] }
Multiple --jv parameters may be specified.
DEMONSTRATION QUERIES
There are several built-in demonstration queries that may be exercised to show the
utility of RDAP. To use these queries, the --demo parameter must be used to populate
the query answers into the cache. If the cache is already populated with items, it
may be necessary to clean the cache using the --empty-cache parameter.
When the --demo parameter is given, the list of demonstration queries will be printed
out.
RDAP VALIDATION
This program has built-in checks for verifying the validity of RDAP responses.
Beyond these normal built-in checks, it can also JSON Content Rules to check
the validity of the responses using the --jcr parameter, which requires either
the standard (i.e. --jcr standard) or strict (i.e. --jcr strict) parameter
options.
MORE INFORMATION
More information about this program may be found at
https://github.com/arineng/nicinfo/wiki
EXTENDED_HELP
Class Method Summary
collapse
-
.add_entity_nodes(entities, node) ⇒ Object
-
.add_entity_respobjs(entities, respobjs) ⇒ Object
-
.capitalize(str) ⇒ Object
-
.display_autnum(json_data, config, data_tree) ⇒ Object
-
.display_domain(json_data, config, data_node) ⇒ Object
-
.display_domains(json_data, config, data_tree) ⇒ Object
-
.display_ds_data(json_data, config, data_node) ⇒ Object
-
.display_entities(json_data, config, data_tree) ⇒ Object
-
.display_entity(json_data, config, data_tree) ⇒ Object
-
.display_ip(json_data, config, data_tree) ⇒ Object
-
.display_key_data(json_data, config, data_node) ⇒ Object
-
.display_nameservers(json_data, config, data_node) ⇒ Object
-
.display_ns(json_data, config, data_node) ⇒ Object
-
.display_object_with_entities(object, config, data_node) ⇒ Object
-
.get_about_link(links) ⇒ Object
-
.get_algorithm(json_data) ⇒ Object
-
.get_alternate_link(links) ⇒ Object
-
.get_autnums(json_data) ⇒ Object
-
.get_copyright_link(links) ⇒ Object
-
.get_country(json_data) ⇒ Object
-
.get_descriptions(json_data, config) ⇒ Object
-
.get_ds_data_objs(json_data) ⇒ Object
-
.get_endAddress(json_data) ⇒ Object
-
.get_endAutnum(json_data) ⇒ Object
-
.get_entitites(json_data) ⇒ Object
-
.get_handle(json_data) ⇒ Object
-
.get_key_data_objs(json_data) ⇒ Object
-
.get_ldhName(json_data) ⇒ Object
-
.get_license_link(links) ⇒ Object
-
.get_link(rel, links) ⇒ Object
-
.get_links(json_data, config) ⇒ Object
-
.get_name(json_data) ⇒ Object
-
.get_nameservers(json_data) ⇒ Object
-
.get_network(json_data) ⇒ Object
-
.get_networks(json_data) ⇒ Object
-
.get_object_class_name(json_data, expected, config) ⇒ Object
-
.get_related_link(links) ⇒ Object
-
.get_secure_dns(json_data) ⇒ Object
-
.get_self_link(links) ⇒ Object
-
.get_startAddress(json_data) ⇒ Object
-
.get_startAutnum(json_data) ⇒ Object
-
.get_tos_link(links) ⇒ Object
-
.get_type(json_data) ⇒ Object
-
.get_unicodeName(json_data) ⇒ Object
-
.is_female_name(name) ⇒ Object
-
.is_last_name(name) ⇒ Object
-
.is_male_name(name) ⇒ Object
-
.is_name(file_name, name) ⇒ Object
-
.make_safe(url) ⇒ Object
-
.random_port ⇒ Object
-
.traceroute(host, config) ⇒ Object
Class Method Details
.add_entity_nodes(entities, node) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/nicinfo/common_json.rb', line 44
def NicInfo.add_entity_nodes entities, node
entities.each do |entity|
entity_node = entity.to_node
node.add_child( entity_node )
NicInfo::add_entity_nodes( entity.entities, entity_node )
end if entities
end
|
.add_entity_respobjs(entities, respobjs) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/nicinfo/common_json.rb', line 52
def NicInfo.add_entity_respobjs entities, respobjs
entities.each do |entity|
respobjs.add( entity )
NicInfo::add_entity_respobjs( entity.entities, respobjs )
end if entities
end
|
.capitalize(str) ⇒ Object
187
188
189
190
191
192
193
|
# File 'lib/nicinfo/utils.rb', line 187
def NicInfo.capitalize str
words = str.split( /\s/ )
words.each do |word|
word.capitalize!
end
return words.join( " " )
end
|
.display_autnum(json_data, config, data_tree) ⇒ Object
24
25
26
27
|
# File 'lib/nicinfo/autnum.rb', line 24
def NicInfo.display_autnum json_data, config, data_tree
autnum = config.factory.new_autnum.process( json_data )
NicInfo::display_object_with_entities( autnum, config, data_tree )
end
|
.display_domain(json_data, config, data_node) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/nicinfo/domain.rb', line 27
def NicInfo.display_domain json_data, config, data_node
obj_array = json_data
unless json_data.instance_of? Array
obj_array = Array.new
obj_array << json_data
end
respObjs = ResponseObjSet.new config
obj_array.each do |array_object|
domain = config.factory.new_domain.process( array_object )
root = domain.to_node
data_node.add_root( root )
if !domain.entities.empty? or !domain.nameservers.empty?
domain.ds_data_objs.each do |ds|
ds_node = ds.to_node
root.add_child( ds_node )
end
domain.key_data_objs.each do |key|
key_node = key.to_node
root.add_child( key_node )
end
NicInfo::add_entity_nodes( domain.entities, root )
domain.nameservers.each do |ns|
ns_node = ns.to_node
root.add_child( ns_node )
NicInfo::add_entity_nodes( ns.entities, ns_node )
end
end
if domain.network
net_node = domain.network.to_node
root.add_child net_node
NicInfo::add_entity_nodes( domain.network.entities, net_node )
end
respObjs.add domain
domain.ds_data_objs.each do |ds|
respObjs.add ds
end
domain.key_data_objs.each do |key|
respObjs.add key
end
NicInfo::add_entity_respobjs( domain.entities, respObjs )
respObjs.associateEntities domain.entities
domain.nameservers.each do |ns|
respObjs.add ns
NicInfo::add_entity_respobjs( ns.entities, respObjs )
respObjs.associateEntities ns.entities
end
if domain.network
respObjs.add domain.network
NicInfo::add_entity_respobjs( domain.network.entities, respObjs )
end
end
data_node.to_normal_log( config.logger, true )
respObjs.display
end
|
.display_domains(json_data, config, data_tree) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/nicinfo/domain.rb', line 82
def NicInfo.display_domains json_data, config, data_tree
domain_array = json_data[ "domainSearchResults" ]
if domain_array != nil
if domain_array.instance_of? Array
NicInfo.display_domain( domain_array, config, data_tree )
else
config.conf_msgs << "'domainSearchResults' is not an array"
end
else
config.conf_msgs << "'domainSearchResults' is not present"
end
end
|
.display_ds_data(json_data, config, data_node) ⇒ Object
23
24
25
|
# File 'lib/nicinfo/ds_data.rb', line 23
def NicInfo.display_ds_data json_data, config, data_node
ds_data = DsData.new( config ).process( json_data ).display
end
|
.display_entities(json_data, config, data_tree) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/nicinfo/entity.rb', line 61
def NicInfo.display_entities json_data, config, data_tree
entity_array = json_data[ "entitySearchResults" ]
if entity_array != nil
if entity_array.instance_of? Array
display_array = Array.new
entity_array.each do |ea|
entity = config.factory.new_entity.process( ea )
display_array << entity
end
NicInfo.display_object_with_entities( display_array, config, data_tree )
else
config.conf_msgs << "'entitySearchResults' is not an array"
end
else
config.conf_msgs << "'entitySearchResults' is not present"
end
end
|
.display_entity(json_data, config, data_tree) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/nicinfo/entity.rb', line 23
def NicInfo.display_entity json_data, config, data_tree
entity = config.factory.new_entity.process( json_data )
respobjs = ResponseObjSet.new config
root = entity.to_node
data_tree.add_root( root )
if !entity.entities.empty?
NicInfo::add_entity_nodes( entity.entities, root )
end
entity.networks.each do |network|
net_node = network.to_node
root.add_child( net_node )
NicInfo::add_entity_nodes( network.entities, net_node )
end
entity.autnums.each do |autnum|
as_node = autnum.to_node
root.add_child( as_node )
NicInfo::add_entity_nodes( autnum.entities, as_node )
end
respobjs.add entity
NicInfo::add_entity_respobjs( entity.entities, respobjs )
respobjs.associateEntities entity.entities
entity.networks.each do |network|
respobjs.add network
NicInfo::add_entity_respobjs( network.entities, respobjs )
respobjs.associateEntities network.entities
end
entity.autnums.each do |autnum|
respobjs.add autnum
NicInfo::add_entity_respobjs( autnum.entities, respobjs )
respobjs.associateEntities autnum.entities
end
data_tree.to_normal_log( config.logger, true )
respobjs.display
end
|
.display_ip(json_data, config, data_tree) ⇒ Object
27
28
29
30
|
# File 'lib/nicinfo/ip.rb', line 27
def NicInfo.display_ip json_data, config, data_tree
ip = config.factory.new_ip.process( json_data )
NicInfo::display_object_with_entities( ip, config, data_tree )
end
|
.display_key_data(json_data, config, data_node) ⇒ Object
23
24
25
|
# File 'lib/nicinfo/key_data.rb', line 23
def NicInfo.display_key_data json_data, config, data_node
key_data = KeyData.new( config ).process( json_data ).display
end
|
.display_nameservers(json_data, config, data_node) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/nicinfo/ns.rb', line 29
def NicInfo.display_nameservers json_data, config, data_node
ns_array = json_data[ "nameserverSearchResults" ]
if ns_array != nil
if ns_array.instance_of? Array
display_array = Array.new
ns_array.each do |ea|
ns = config.factory.new_ns.process( ea )
display_array << ns
end
NicInfo::display_object_with_entities( display_array, config, data_node )
else
config.conf_msgs << "'nameserverSearchResults' is not an array"
end
else
config.conf_msgs << "'nameserverSearchResults' is not present"
end
end
|
.display_ns(json_data, config, data_node) ⇒ Object
24
25
26
27
|
# File 'lib/nicinfo/ns.rb', line 24
def NicInfo.display_ns json_data, config, data_node
ns = config.factory.new_ns.process( json_data )
NicInfo::display_object_with_entities( ns, config, data_node )
end
|
.display_object_with_entities(object, config, data_node) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/nicinfo/common_json.rb', line 23
def NicInfo.display_object_with_entities object, config, data_node
obj_array = object
unless object.instance_of? Array
obj_array = Array.new
obj_array << object
end
respobjs = ResponseObjSet.new config
obj_array.each do |array_object|
root = array_object.to_node
data_node.add_root( root )
if !array_object.entities.empty?
NicInfo::add_entity_nodes( array_object.entities, root )
end
respobjs.add array_object
NicInfo::add_entity_respobjs( array_object.entities, respobjs )
respobjs.associateEntities array_object.entities
end
data_node.to_normal_log( config.logger, true )
respobjs.display
end
|
.get_about_link(links) ⇒ Object
169
170
171
|
# File 'lib/nicinfo/utils.rb', line 169
def NicInfo.get_about_link links
get_link "about", links
end
|
.get_algorithm(json_data) ⇒ Object
50
51
52
|
# File 'lib/nicinfo/utils.rb', line 50
def NicInfo.get_algorithm json_data
return json_data[ "algorithm" ]
end
|
.get_alternate_link(links) ⇒ Object
153
154
155
|
# File 'lib/nicinfo/utils.rb', line 153
def NicInfo.get_alternate_link links
get_link "alternate", links
end
|
.get_autnums(json_data) ⇒ Object
103
104
105
|
# File 'lib/nicinfo/utils.rb', line 103
def NicInfo.get_autnums json_data
return json_data[ "autnums" ]
end
|
.get_copyright_link(links) ⇒ Object
165
166
167
|
# File 'lib/nicinfo/utils.rb', line 165
def NicInfo.get_copyright_link links
get_link "copyright", links
end
|
.get_country(json_data) ⇒ Object
135
136
137
|
# File 'lib/nicinfo/utils.rb', line 135
def NicInfo.get_country json_data
return json_data[ "country" ]
end
|
.get_descriptions(json_data, config) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/nicinfo/utils.rb', line 76
def NicInfo.get_descriptions json_data, config
return if !json_data
if json_data.instance_of?( Hash )
retval = json_data[ "description" ]
unless retval.instance_of?( Array )
config.conf_msgs << "'description' is not an array."
retval = nil
end
else
config.conf_msgs << "expected object for 'remarks' or 'notices'."
retval = nil
end
return retval
end
|
.get_ds_data_objs(json_data) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/nicinfo/utils.rb', line 32
def NicInfo.get_ds_data_objs json_data
secure_dns = NicInfo::get_secure_dns json_data
if secure_dns.instance_of? Array
secure_dns = secure_dns[ 0 ]
end
return secure_dns[ "dsData" ] if secure_dns
return nil
end
|
.get_endAddress(json_data) ⇒ Object
115
116
117
|
# File 'lib/nicinfo/utils.rb', line 115
def NicInfo.get_endAddress json_data
return json_data[ "endAddress" ]
end
|
.get_endAutnum(json_data) ⇒ Object
123
124
125
|
# File 'lib/nicinfo/utils.rb', line 123
def NicInfo.get_endAutnum json_data
return json_data[ "endAutnum" ]
end
|
.get_entitites(json_data) ⇒ Object
91
92
93
|
# File 'lib/nicinfo/utils.rb', line 91
def NicInfo.get_entitites json_data
return json_data[ "entities" ]
end
|
.get_handle(json_data) ⇒ Object
54
55
56
|
# File 'lib/nicinfo/utils.rb', line 54
def NicInfo.get_handle json_data
return json_data[ "handle" ]
end
|
.get_key_data_objs(json_data) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/nicinfo/utils.rb', line 41
def NicInfo.get_key_data_objs json_data
secure_dns = NicInfo::get_secure_dns json_data
if secure_dns.instance_of? Array
secure_dns = secure_dns[ 0 ]
end
return secure_dns[ "keyData" ] if secure_dns
return nil
end
|
.get_ldhName(json_data) ⇒ Object
68
69
70
|
# File 'lib/nicinfo/utils.rb', line 68
def NicInfo.get_ldhName json_data
return json_data[ "ldhName" ]
end
|
.get_license_link(links) ⇒ Object
161
162
163
|
# File 'lib/nicinfo/utils.rb', line 161
def NicInfo.get_license_link links
get_link "license", links
end
|
.get_link(rel, links) ⇒ Object
177
178
179
180
181
182
183
184
185
|
# File 'lib/nicinfo/utils.rb', line 177
def NicInfo.get_link rel, links
return nil if !links
links.each do |link|
if link[ "rel" ] == rel
return link[ "href" ]
end
end
return nil
end
|
.get_links(json_data, config) ⇒ Object
139
140
141
142
143
144
145
146
147
|
# File 'lib/nicinfo/utils.rb', line 139
def NicInfo.get_links json_data, config
retval = json_data[ "links" ]
return nil unless retval
if !retval.instance_of?( Array )
config.conf_msgs << "'links' is not an array."
retval = nil
end
return retval
end
|
.get_name(json_data) ⇒ Object
127
128
129
|
# File 'lib/nicinfo/utils.rb', line 127
def NicInfo.get_name json_data
return json_data[ "name" ]
end
|
.get_nameservers(json_data) ⇒ Object
107
108
109
|
# File 'lib/nicinfo/utils.rb', line 107
def NicInfo.get_nameservers json_data
return json_data[ "nameservers" ]
end
|
.get_network(json_data) ⇒ Object
99
100
101
|
# File 'lib/nicinfo/utils.rb', line 99
def NicInfo.get_network json_data
return json_data[ "network" ]
end
|
.get_networks(json_data) ⇒ Object
95
96
97
|
# File 'lib/nicinfo/utils.rb', line 95
def NicInfo.get_networks json_data
return json_data[ "networks" ]
end
|
.get_object_class_name(json_data, expected, config) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/nicinfo/utils.rb', line 58
def NicInfo.get_object_class_name json_data, expected, config
objectClassName = json_data[ "objectClassName" ]
if objectClassName == nil
config.conf_msgs << "Expected 'objectClassName' is not present."
elsif objectClassName != expected
config.conf_msgs << "Expected 'objectClassName' to be '#{expected}' but it is '#{objectClassName}'."
end
return objectClassName
end
|
149
150
151
|
# File 'lib/nicinfo/utils.rb', line 149
def NicInfo.get_related_link links
get_link "related", links
end
|
.get_secure_dns(json_data) ⇒ Object
28
29
30
|
# File 'lib/nicinfo/utils.rb', line 28
def NicInfo.get_secure_dns json_data
return json_data[ "secureDNS" ]
end
|
.get_self_link(links) ⇒ Object
173
174
175
|
# File 'lib/nicinfo/utils.rb', line 173
def NicInfo.get_self_link links
get_link "self", links
end
|
.get_startAddress(json_data) ⇒ Object
111
112
113
|
# File 'lib/nicinfo/utils.rb', line 111
def NicInfo.get_startAddress json_data
return json_data[ "startAddress" ]
end
|
.get_startAutnum(json_data) ⇒ Object
119
120
121
|
# File 'lib/nicinfo/utils.rb', line 119
def NicInfo.get_startAutnum json_data
return json_data[ "startAutnum" ]
end
|
.get_tos_link(links) ⇒ Object
157
158
159
|
# File 'lib/nicinfo/utils.rb', line 157
def NicInfo.get_tos_link links
get_link "terms-of-service", links
end
|
.get_type(json_data) ⇒ Object
131
132
133
|
# File 'lib/nicinfo/utils.rb', line 131
def NicInfo.get_type json_data
return json_data[ "type" ]
end
|
.get_unicodeName(json_data) ⇒ Object
72
73
74
|
# File 'lib/nicinfo/utils.rb', line 72
def NicInfo.get_unicodeName json_data
return json_data[ "unicodeName" ]
end
|
.is_female_name(name) ⇒ Object
26
27
28
|
# File 'lib/nicinfo/common_names.rb', line 26
def NicInfo::is_female_name name
is_name "female-first-names.txt", name
end
|
.is_last_name(name) ⇒ Object
18
19
20
|
# File 'lib/nicinfo/common_names.rb', line 18
def NicInfo::is_last_name name
is_name "last-names.txt", name
end
|
.is_male_name(name) ⇒ Object
22
23
24
|
# File 'lib/nicinfo/common_names.rb', line 22
def NicInfo::is_male_name name
is_name "male-first-names.txt", name
end
|
.is_name(file_name, name) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/nicinfo/common_names.rb', line 30
def NicInfo::is_name file_name, name
retval = false
name.gsub! '*',''
names = name.split( ' ' )
file = File.new( File.join( File.dirname( __FILE__ ) , file_name ), "r" )
file.each_line do |line|
names.each do |n|
if line.start_with?( n )
retval = true
break
end
end
end
file.close
return retval
end
|
.make_safe(url) ⇒ Object
22
23
24
25
26
|
# File 'lib/nicinfo/utils.rb', line 22
def NicInfo.make_safe( url )
safe = URI.escape( url )
safe = URI.escape( safe, "!*'();:@&=+$,/?#[]" )
return safe
end
|
.random_port ⇒ Object
36
37
38
|
# File 'lib/nicinfo/traceroute.rb', line 36
def NicInfo.random_port
1024 + rand(64511)
end
|
.traceroute(host, config) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/nicinfo/traceroute.rb', line 40
def NicInfo.traceroute host, config
ips = Array.new
begin
myname = Socket.gethostname
rescue SocketError => err_msg
config.logger.mesg "Can't get my own host name (#{err_msg})."
exit 1
end
config.logger.mesg "Tracing route to #{host}"
ttl = 1
max_ttl = 255
max_contiguaous_timeout = 16
localport = random_port
dgram_sock = UDPSocket::new
begin
dgram_sock.bind( myname, localport )
rescue
localport = random_port
retry
end
begin
icmp_sock = Socket.open( Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_ICMP )
icmp_sockaddr = Socket.pack_sockaddr_in( localport, myname )
icmp_sock.bind( icmp_sockaddr )
rescue SystemCallError => socket_error
config.logger.mesg "Error with ICMP socket. You probably need to be root: #{socket_error}"
exit 1
end
begin
dgram_sock.connect( host, 999 )
rescue SocketError => err_msg
config.logger.mesg "Can't connect to remote host (#{err_msg})."
exit 1
end
stop_tracing = false
continguous_timeout = 0
until stop_tracing
dgram_sock.setsockopt( 0, Socket::IP_TTL, ttl )
dgram_sock.send( "RubyRoute says hello!", 0 )
begin
Timeout::timeout( 1 ) {
data, sender = icmp_sock.recvfrom( 8192 )
icmp_type = data.unpack( '@20C' )[0]
icmp_code = data.unpack( '@21C' )[0]
ip = Socket.unpack_sockaddr_in( sender )[1].to_s
ips << ip
config.logger.mesg "TTL = #{ttl}: " + ip
continguous_timeout = 0
if ( icmp_type == 3 and icmp_code == 13 )
config.logger.mesg "'Communication Administratively Prohibited' from this hop."
elsif ( icmp_type == 3 and icmp_code == 3 )
config.logger.mesg "Destination reached. Trace complete."
stop_tracing = true
end
}
rescue Timeout::Error
config.logger.mesg "Timeout error with TTL = #{ttl}!"
continguous_timeout += 1
end
ttl += 1
stop_tracing = true if ttl > max_ttl
if continguous_timeout > max_contiguaous_timeout
stop_tracing = true
config.logger.mesg "Getting a lot of contiguous timeouts. Prematurely terminating trace."
end
end
ips
end
|