Giter Club home page Giter Club logo

nicinfo's Introduction

Overview

Gem Version Build Status Coverage Status

NicInfo is a general purpose, command line Registry Data Access Protocol (RDAP) client released under an open source, ISC derivative BSD style license. RDAP is an HTTP-based RESTful protocol defined by the IETF as a replacement for Whois.

The general usage of this software from the command line is "nicinfo QUERY_VALUE" where the QUERY_VALUE is an IP address, domain name, autonomous system number, name server host name, or entity identifier. NicInfo will attempt to determine the most appropriate RDAP server to query and follow redirects to other RDAP servers as needed.

Features

NicInfo has the following features:

  • Query type detection: it will attempt to determine what type of query is needed based on the supplied query value.
  • Plain text output: default output is a text version of the RDAP results.
  • JSON output: the RDAP JSON can be passed directly to a calling program for intergration with scripts with the ability to select specific JSON values.
  • Multiple output controls: the amount of text detail and process execution can be varied and sent to different files.
  • A Built-in cache: RDAP queries are cached.
  • Bootstrapping using the IANA bootstrap files or by using a bootstrap server.
  • Demonstration queries: a set of built-in queries and results are provided for demonstration purposes.

The following is an example of using NicInfo:

$ bin/nicinfo --pager no 1.1.1.1
# NicInfo v.0.1.0-snapshot

[ NOTICE ] Source
         1 Objects returned came from source
         2 APNIC

[ NOTICE ] Terms and Conditions
         1 This is the APNIC WHOIS Database query service. The objects are in RDAP format.
       TOS http://www.apnic.net/db/dbcopyright.html

[ RESPONSE DATA ]
  1= 1.1.1.0 - 1.1.1.255
     |--- 1= APNIC RESEARCH ( AR302-AP )
     `--- 2= IRT-APNICRANDNET-AU ( IRT-APNICRANDNET-AU )

           [ IP NETWORK ]
                   Handle:  1.1.1.0 - 1.1.1.255
            Start Address:  1.1.1.0
              End Address:  1.1.1.255
               IP Version:  v4
                  Country:  AU
                     Type:  ASSIGNED PORTABLE
             Last Changed:  Mon, 12 May 2014 04:16:03 -0000
                  Remarks:  -- description --
                        1:  Research prefix for APNIC Labs
                        2:  APNIC

               [ ENTITY ]
                   Handle:  AR302-AP
                     Name:  APNIC RESEARCH
                    Email:  [email protected]
                    Phone:  +61-7-3858-3188 ( voice )
                    Phone:  +61-7-3858-3199 ( fax )
                    Roles:  Technical, Administrative
        Excessive Remarks:  Use "-V" or "--data extra" to see them.

               [ ENTITY ]
                   Handle:  IRT-APNICRANDNET-AU
                     Name:  IRT-APNICRANDNET-AU
                    Email:  [email protected]
                    Email:  [email protected]
                    Roles:  Abuse

# Use "nicinfo -r 1.1.1.1" to see reverse DNS information.
# Use "nicinfo 1=" to show 1.1.1.0 - 1.1.1.255
# Use "nicinfo 1.1=" to show APNIC RESEARCH ( AR302-AP )
# Use "nicinfo 1.2=" to show IRT-APNICRANDNET-AU ( IRT-APNICRANDNET-AU )
# Use "nicinfo http://rdap.apnic.net/ip/1.1.1.0/24" to directly query this resource in the future.
# Use "nicinfo -h" for help.

Live examples

nicinfo -V .
nicinfo nic.br
nicinfo nic.cz

Versions

Information about the various versions of NicInfo can be found in the CHANGE LOG on the project wiki.

Getting and Installing

Getting and installing NicInfo is easily accomplished as a Ruby Gem using the command gem install nicinfo. If that does not work for you, follow the instructions and advice for your platform on the project Wiki here.

If you wish to build and test this software from source, it follows the typical Ruby development process. More information may be found here.

Getting Help

Helpful information about NicInfo (and RDAP) may be found on the project wiki.

If you have questions or need help with this software, you may use the issue tracker on GitHub or you may use the ARIN Technical Discussions mailing list (it is a very low volume list).

Demonstration Queries

Demonstration queries are available with the --demo option, which will seed the cache with results and list the available demonstration queries.

nicinfo --demo

After the cache has been seeded, you will be presented with a list of example queries which will pull information from the cache.

nicinfo's People

Contributors

amwelch avatar anewton1998 avatar anomaly256 avatar dotysan avatar ericparton avatar gdubin avatar kimmygraham avatar nickhilliard avatar nshopik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nicinfo's Issues

URI encode updated in Ruby 3.1.2

~/.rvm/gems/ruby-3.1.2/gems/nicinfo-1.5.0/lib/nicinfo/nicinfo_main.rb:322:in get': undefined method encode' for URI:Module (NoMethodError)

19a20
> require 'addressable/uri'

322,323c323,324
< uri = URI.parse( URI::encode( url ) )
< req = Net::HTTP::Get.new(uri.request_uri)
---
> uri = URI.parse( Addressable::URI.escape( url ) )
> req = Net::HTTP::Get.new(uri)'

379,380c380,381
< uri = URI.parse( URI::encode( url ) )
< req = Net::HTTP::Get.new(uri.request_uri)
---
> uri = URI.parse( Addressable::URI.escape( url ) )
> req = Net::HTTP::Get.new(uri)

404 produces a stack trace

andy@ubuntu:~/projects/nicinfo$ bundle exec bin/nicinfo -V --pager no arin-o
# NicInfo v.1.3.0-alpha1
## Using configuration found in /home/andy/.NicInfo
# Your configuration is old. Use --reset to create a new one.
## Evicted 0 files from the cache
## Assuming query value is ENTITYHANDLE
## Looking up bootstrap from /home/andy/.NicInfo/bsfiles/entity.json
## Issuing GET for https://rdap.arin.net/registry/entity/arin-o
# Query yielded no results.
## Server conforms to rdap_level_0

[ NOTICE ] Terms of Service
         1 By using the ARIN RDAP/Whois service, you are agreeing to the RDAP/Whois Terms of Use
     About https://www.arin.net/whois_tou.html

 [ ERROR ] ENTITY NOT FOUND
      Code 404
         1 The entity you are seeking as 'ARIN-O' is/are not here.

## Server response code was 404
bundler: failed to load command: bin/nicinfo (bin/nicinfo)
NoMethodError: undefined method `[]' for true:TrueClass
  /home/andy/projects/nicinfo/lib/nicinfo/notices.rb:45:in `display_notices'
  /home/andy/projects/nicinfo/lib/nicinfo/nicinfo_main.rb:630:in `display_rdap_query'
  /home/andy/projects/nicinfo/lib/nicinfo/nicinfo_main.rb:509:in `run'
  bin/nicinfo:25:in `<top (required)>'

--json and --jv options output Ruby representation not JSON

Using the --json and --jv options produces output in Ruby form, not JSON. An example:

andy@ubuntu:~/projects/nicinfo$ bundle exec bin/nicinfo --jv links 192.139.1.1 --pager no
# NicInfo v.1.5.0-alpha1
{"value"=>"https://rdap.arin.net/registry/ip/192.139.1.1", "rel"=>"self", "type"=>"application/rdap+json", "href"=>"https://rdap.arin.net/registry/ip/192.139.1.0"}
{"value"=>"https://rdap.arin.net/registry/ip/192.139.1.1", "rel"=>"alternate", "type"=>"application/xml", "href"=>"https://whois.arin.net/rest/net/NET-192-139-1-0-1"}

Note the => and not the :. Also, in the example above links is an array but the array wrapper does not get output.

"in `process': undefined method `size' for nil:NilClass (NoMethodError)"

It seems nicinfo chokes on some RDAP servers (reading the JSON output of this server, rdap.nic.bostik, shows no obvious issue).

% nicinfo nic.bostik
# NicInfo v.1.4.1
# Result type is DOMAIN.
/var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/entity.rb:134:in `process': undefined method `size' for nil:NilClass (NoMethodError)
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/entity.rb:255:in `process'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/common_json.rb:71:in `block in process_entities'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/common_json.rb:69:in `each'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/common_json.rb:69:in `process_entities'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/domain.rb:112:in `process'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/domain.rb:35:in `block in display_domain'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/domain.rb:34:in `each'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/domain.rb:34:in `display_domain'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/nicinfo_main.rb:701:in `display_rdap_query'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/lib/nicinfo/nicinfo_main.rb:537:in `run'
	from /var/lib/gems/2.5.0/gems/nicinfo-1.4.1/bin/nicinfo:25:in `<top (required)>'
	from /local/bin/nicinfo:23:in `load'
	from /local/bin/nicinfo:23:in `<main>'

Ruby Gem

Make this a Ruby Gem so it can be installed as a gem

spelling correction in README.md

The general usage of this software from the command line is "nicinfo QUERY_VALE" where the QUERY_VALUE is an IP address, domain name, autonomous system number, name server host name, or entity identifier.

s/QUERY_VALE/QUERY_VALUE/

Switching to use bootstrap files

Is there a way how to convince client to use boostrap files from IANA and not going through rdap.arin.net? IMHO this should be default.

$ /tmp/nicinfo/bin/nicinfo -V --iana nic.cz
# NicInfo v.1.1.0-alpha
## Using configuration found in /home/jara/.NicInfo
## Evicted 0 files from the cache
## Downloading http://data.iana.org/rdap/asn.json to /home/jara/.NicInfo/bsfiles
## Downloading http://data.iana.org/rdap/ipv4.json to /home/jara/.NicInfo/bsfile
## Downloading http://data.iana.org/rdap/ipv6.json to /home/jara/.NicInfo/bsfile
## Downloading http://data.iana.org/rdap/dns.json to /home/jara/.NicInfo/bsfiles
## Assuming query value is DOMAIN
## Issuing GET for https://rdap.arin.net/registry/domain/nic.cz
# Query yielded no results.
## Server conforms to rdap_level_0

[ NOTICE ] Terms of Service
         1 By using the ARIN RDAP/Whois service, you are agreeing to the
           RDAP/Whois Terms of Use
     About https://www.arin.net/whois_tou.html

 [ ERROR ] DOMAIN NOT FOUND
      Code 404
         1 The domain you are seeking as 'nic.cz.' is/are not here.

## Server response code was 404'

URI escape updated in Ruby

23,25c23,26
<     safe = URI.escape( url )
<     safe = URI.escape( safe, "!*'();:@&=+$,/?#[]" )
<     return safe
---
>     return URI.encode_www_form_component(url, enc=nil)
>     #safe = URI.escape( url )
>     #safe = URI.escape( safe, "!*'();:@&=+$,/?#[]" )
>     #return safe

using base url on command line causes problems

andy@ubuntu:~/projects/nicinfo$ bundle exec bin/nicinfo -V -b http://rdap.arin.net/bootstrap 192.136.136.2
# NicInfo v.1.5.0-alpha1
## Using configuration found in /home/andy/.NicInfo
## Evicted 0 files from the cache
## Assuming query value is IP4ADDR
bundler: failed to load command: bin/nicinfo (bin/nicinfo)
NoMethodError: undefined method `end_with?' for nil:NilClass
  /home/andy/projects/nicinfo/lib/nicinfo/rdap_query.rb:224:in `make_rdap_url'
  /home/andy/projects/nicinfo/lib/nicinfo/rdap_query.rb:80:in `do_rdap_query'
  /home/andy/projects/nicinfo/lib/nicinfo/nicinfo_main.rb:504:in `run'
  bin/nicinfo:25:in `<top (required)>'

.deb doesn't quite work

$ nicinfo

/usr/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'nicinfo' (>= 0) among 13 total gem(s) (Gem::LoadError)
        from /usr/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
        from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
        from /usr/bin/nicinfo:22:in `<main>'

Ruby 3.2.0 File class exist(s) method name change

NicInfo v.1.5.1

/opt/homebrew/lib/ruby/gems/3.2.0/gems/nicinfo-1.5.1/lib/nicinfo/config.rb:134:in `get_bsfiles_last_update_time': undefined method>

  if File.exists?( fname )
         ^^^^^^^^

Did you mean? exist?
from /opt/homebrew/lib/ruby/gems/3.2.0/gems/nicinfo-1.5.1/lib/nicinfo/config.rb:150:in check_bsfiles_age?' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/nicinfo-1.5.1/lib/nicinfo/nicinfo_main.rb:425:in run'
from /opt/homebrew/lib/ruby/gems/3.2.0/gems/nicinfo-1.5.1/bin/nicinfo:25:in `<top (required)>'

https://stackoverflow.com/questions/14351272/why-do-i-get-undefined-method-exist-for-fileclass

Inform users of truncated responses

In certain cases, the data set back from RDAP will have a truncated list of records (entities with 256+ networks). When this happens, nicinfo should notify the user the dataset is truncated. Currently, the user will not be aware they haven't received all the records.

Version config

It would probably be a good idea to version the config so that upgrades will know what to do.

weird notice with foo.cz lookup

Need to look into this:

## Getting https://rdap.nic.cz/domain/foo.cz from cache.
## Server conforms to rdap_level_0
## Server conforms to fred_version_0

[ NOTICE ] Disclaimer
         1 (c) 2015 CZ.NIC, z.s.p.o.

Intended use of supplied data and information

Data contained in the domain name
           register, as well as information supplied through public information services of CZ.NIC association, are appointed
           only for purposes connected with Internet network administration and operation, or for the purpose of legal or
           other similar proceedings, in process as regards a matter connected particularly with holding and using a concrete
           domain name. 

domain lookup did not work

so i decided to take it for a spin. sierra on a mid-2014 rmbp. did a
simple gem install.

ryuu.psg.com:/usr/local/src# gem install nicinfo-1.1.1.gem 
Successfully installed nicinfo-1.1.1
Parsing documentation for nicinfo-1.1.1
Installing ri documentation for nicinfo-1.1.1
1 gem installed

fwiw, the docco install took foreverrrrrrr

it worked for ip addresses, less so for domain names

ryuu.psg.com:/Users/randy> nicinfo rg.net       
# NicInfo v.1.1.1
# Query yielded no results.

[ NOTICE ] Terms of Service
         1 By using the ARIN RDAP/Whois service, you are agreeing to the
           RDAP/Whois Terms of Use
     About https://www.arin.net/whois_tou.html

 [ ERROR ] DOMAIN NOT FOUND
      Code 404
         1 The domain you are seeking as 'rg.net.' is/are not here.

even being explicit did not help

ryuu.psg.com:/Users/randy> nicinfo -t domain psg.com
# NicInfo v.1.1.1
# Query yielded no results.

[ NOTICE ] Terms of Service
         1 By using the ARIN RDAP/Whois service, you are agreeing to the
           RDAP/Whois Terms of Use
     About https://www.arin.net/whois_tou.html

 [ ERROR ] DOMAIN NOT FOUND
      Code 404
         1 The domain you are seeking as 'psg.com.' is/are not here.

i assume i am doing something st00pid, but what? and how to debug?

Calculate CIDR block

Providing CIDR notation for the queried prefix would be helpful. If I query for a host address, nicinfo will display the start and end address, but not the CIDR block that contains the info. whois provides this info. For example:

whois 2620:0:861:ed1a::1
<output truncated>
NetRange:       2620:0:860:: - 2620:0:863:FFFF:FFFF:FFFF:FFFF:FFFF
CIDR:           2620:0:860::/46

Having the CIDR block calculated would be helpful.

Thank you

Fails for network with multiple countries

The console output below probably says it all:

$ bin/nicinfo 2a02:c0::
# NicInfo v.1.1.1 EXPERIMNETAL
# Error 400.

[ NOTICE ] Terms and Conditions
         1 This is the RIPE Database query service. The objects are in RDAP format.
       TOS http://www.ripe.net/db/support/db-terms-conditions.pdf

 [ ERROR ] Multiple country: found in 2a02:c0::/48
      Code 400
/local/home/tore/git/nicinfo/lib/nicinfo/error_code.rb:34:in `display_error_code': undefined method `each' for nil:NilClass (NoMethodError)
        from /local/home/tore/git/nicinfo/lib/nicinfo/nicinfo_main.rb:847:in `handle_error_response'
        from /local/home/tore/git/nicinfo/lib/nicinfo/nicinfo_main.rb:749:in `rescue in do_rdap_query'
        from /local/home/tore/git/nicinfo/lib/nicinfo/nicinfo_main.rb:712:in `do_rdap_query'
        from /local/home/tore/git/nicinfo/lib/nicinfo/nicinfo_main.rb:499:in `run'
        from bin/nicinfo:25:in `<main>'

Fix demo queries

After switching to the IANA bootstrapping, some of the demo queries are no longer working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.