Skip to content

Non-domain queries combined with an incompatible output option like --whois emit no output but still return a zero exit code #37

Description

@FRooter

Certain (non-domain) queries combined with an incompatible output option (--whois) should return a non-zero exit code and a warning or error message. Presently, queries for an ASN or IP address combined with the --whois output option emit nothing but still return a zero exit code, which can be confusing when there is also no warning or error emitted. The same (non-domain) queries function correctly with --text output, but my hope is that the user experience can be further improved when attempting output options that are incompatible, specifically where the user is informed via a warning or error message in combination with a non-zero exit code.

Examples

  1. ~/go/bin/rdap --cache-dir='' --whois AS1
% ~/go/bin/rdap --cache-dir='' --whois AS1
% echo $?
0
Verbose OpenRDAP whois output with an ASN query input
% ~/go/bin/rdap --verbose --cache-dir='' --whois AS1
# OpenRDAP v0.9.1
#
# rdap: Configuring query...
# rdap: Using in-memory cache
# rdap: Bootstrap URL is default 'https://data.iana.org/rdap/'
# rdap: Bootstrap cache TTL set to 3600 seconds
# rdap: Timeout is 30 seconds
#
# client: Running...
# client: Request type  : autnum
# client: Request query : 1
# client: Request URL   : TBD, bootstrap required
#   bootstrap: Looking up...
#   bootstrap: Question type : asn
#   bootstrap: Question query: 1
#   bootstrap: Cache state: asn.json: not cached
#   bootstrap: Downloading asn.json
#   bootstrap: Looked up '1'
#   bootstrap: Matching entry 'AS1-AS1876'
#   bootstrap: Service URL #1: 'https://rdap.arin.net/registry/'
#   bootstrap: Service URL #2: 'http://rdap.arin.net/registry/'
# client: RDAP URL #0 is https://rdap.arin.net/registry/autnum/1
# client: RDAP URL #1 is http://rdap.arin.net/registry/autnum/1
# client: GET https://rdap.arin.net/registry/autnum/1
# client: status-code=200, content-type=application/rdap+json, length=9971 bytes, duration=214.325667ms
# client: Successfully decoded response
#
# rdap: Finished in 340.433833ms
% echo $?
0
  1. ~/go/bin/rdap --cache-dir='' --whois 1.1.1.1
% ~/go/bin/rdap --cache-dir='' --whois 1.1.1.1
% echo $?
0
Verbose OpenRDAP whois output with an IPv4 query input
% ~/go/bin/rdap --verbose --cache-dir='' --whois 1.1.1.1
# OpenRDAP v0.9.1
#
# rdap: Configuring query...
# rdap: Using in-memory cache
# rdap: Bootstrap URL is default 'https://data.iana.org/rdap/'
# rdap: Bootstrap cache TTL set to 3600 seconds
# rdap: Timeout is 30 seconds
#
# client: Running...
# client: Request type  : ip
# client: Request query : 1.1.1.1
# client: Request URL   : TBD, bootstrap required
#   bootstrap: Looking up...
#   bootstrap: Question type : ipv4
#   bootstrap: Question query: 1.1.1.1
#   bootstrap: Cache state: ipv4.json: not cached
#   bootstrap: Downloading ipv4.json
#   bootstrap: Looked up '1.1.1.1/32'
#   bootstrap: Matching entry '1.0.0.0/8'
#   bootstrap: Service URL #1: 'https://rdap.apnic.net/'
# client: RDAP URL #0 is https://rdap.apnic.net/ip/1.1.1.1
# client: GET https://rdap.apnic.net/ip/1.1.1.1
# client: status-code=200, content-type=application/rdap+json, length=3854 bytes, duration=419.6ms
# client: Successfully decoded response
#
# rdap: Finished in 614.786583ms
% echo $?
0
  1. ~/go/bin/rdap --cache-dir='' --whois 2606:4700:4700::1111
% ~/go/bin/rdap --cache-dir='' --whois 2606:4700:4700::1111
% echo $?
0
Verbose OpenRDAP whois output with an IPv6 query input

% ~/go/bin/rdap --verbose --cache-dir='' --whois 2606:4700:4700::1111
# OpenRDAP v0.9.1
#
# rdap: Configuring query...
# rdap: Using in-memory cache
# rdap: Bootstrap URL is default 'https://data.iana.org/rdap/'
# rdap: Bootstrap cache TTL set to 3600 seconds
# rdap: Timeout is 30 seconds
#
# client: Running...
# client: Request type  : ip
# client: Request query : 2606:4700:4700::1111
# client: Request URL   : TBD, bootstrap required
#   bootstrap: Looking up...
#   bootstrap: Question type : ipv6
#   bootstrap: Question query: 2606:4700:4700::1111
#   bootstrap: Cache state: ipv6.json: not cached
#   bootstrap: Downloading ipv6.json
#   bootstrap: Looked up '2606:4700:4700::1111/128'
#   bootstrap: Matching entry '2600::/12'
#   bootstrap: Service URL #1: 'https://rdap.arin.net/registry/'
#   bootstrap: Service URL #2: 'http://rdap.arin.net/registry/'
# client: RDAP URL #0 is https://rdap.arin.net/registry/ip/2606:4700:4700::1111
# client: RDAP URL #1 is http://rdap.arin.net/registry/ip/2606:4700:4700::1111
# client: GET https://rdap.arin.net/registry/ip/2606:4700:4700::1111
# client: status-code=200, content-type=application/rdap+json, length=12130 bytes, duration=307.6895ms
# client: Successfully decoded response
#
# rdap: Finished in 386.910542ms
% echo $?
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions