Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #102

Merged
merged 7 commits into from
Jan 25, 2025
Merged

Dev #102

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.0.20"
version = "0.0.21"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/icann/icann-rdap"
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ About

This repository hosts 4 separate packages (i.e. Rust crates):

* [icann-rdap-cli](icann-rdap-cli/README.md) is the Command Line Interface client. This package produces an executable binary.
* [icann-rdap-client](icann-rdap-client/README.md) is a library handling making RDAP requests.
* [icann-rdap-common](icann-rdap-common/README.md) is a library of RDAP structures.
* [icann-rdap-cli](icann-rdap-cli/README.md) is the Command Line Interface client and testing tool.
* [icann-rdap-client](icann-rdap-client/README.md) is a Rust library handling making RDAP requests.
* [icann-rdap-common](icann-rdap-common/README.md) is a Rust library of RDAP structures.
* [icann-rdap-srv](icann-rdap-srv/README.md) is a simple, in-memory RDAP server. This package produces multiple executable binaries.

![Example of rdap command](https://github.com/icann/icann-rdap/wiki/images/rdap_command.png)

Installation and Usage
----------------------

See the [project wiki](https://github.com/icann/icann-rdap/wiki) for information on installation
and usage of this software.

License
-------

Expand Down
4 changes: 2 additions & 2 deletions icann-rdap-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ An RDAP Command Line Interface client.

[dependencies]

icann-rdap-client = { version = "0.0.20", path = "../icann-rdap-client" }
icann-rdap-common = { version = "0.0.20", path = "../icann-rdap-common" }
icann-rdap-client = { version = "0.0.21", path = "../icann-rdap-client" }
icann-rdap-common = { version = "0.0.21", path = "../icann-rdap-common" }

anyhow.workspace = true
clap.workspace = true
Expand Down
148 changes: 10 additions & 138 deletions icann-rdap-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,152 +1,24 @@
ICANN RDAP CLI
==============

This package consists of the following commands:
* The [`rdap`](https://github.com/icann/icann-rdap/wiki/RDAP-command) command is a general-purpose RDAP command line client.
* The [`rdap-test`](https://github.com/icann/icann-rdap/wiki/RDAP-TEST-command) command is a testing tool for RDAP.

![Example of rdap command](https://github.com/icann/icann-rdap/wiki/images/rdap_command.png)

This is a command-line interface (CLI) client for the Registration Data Access Protocol (RDAP) written and sponsored
by the Internet Corporation for Assigned Names and Numbers [(ICANN)](https://www.icann.org).
RDAP is standard of the [IETF](https://ietf.org/), and extensions
to RDAP are a current work activity of the IETF's [REGEXT working group](https://datatracker.ietf.org/wg/regext/documents/).
More information on ICANN's role in RDAP can be found [here](https://www.icann.org/rdap).
General information on RDAP can be found [here](https://rdap.rcode3.com/).

Installing the RDAP Client
--------------------------

### Pre-Built Binaries

Pre-built binaries are available for most mainstream systems: x86_64 and Arm 64bit for Linux GNU systems, x86_64 and Arm 64bit
macOS, and x86_64 for Windows. You may find the pre-built binaries on the [Releases](https://github.com/icann/icann-rdap/releases)
page.

For non-Ubuntu Linux, compiling from crates.io or source (both are easy) is recommended to avoid issues with dynamic linking to OpenSSL.

### Compiling from crates.io

If you have [Rust](https://www.rust-lang.org/) installed on your system, then compiling from source is
very straightforward. If you do not have Rust installed on your system, it is usually very easy to do:
see [Rustup](https://rustup.rs/).

If you are on a Linux system, you will need OpenSSL development files. For Debian and Ubuntu, this is
usually done via `apt install pkg-config libssl-dev`. For other Linux systems, consult your packaging
documentation.

For macOS and Windows, the native TLS libraries are used, and there are no steps needed to install them.

To build and install: `cargo install icann-rdap-cli`.

### Compiling from Source

If you have [Rust](https://www.rust-lang.org/) installed on your system, then compiling from source is
very straightforward. If you do not have Rust installed on your system, it is usually very easy to do:
see [Rustup](https://rustup.rs/).

If you are on a Linux system, you will need OpenSSL development files. For Debian and Ubuntu, this is
usually done via `apt install pkg-config libssl-dev`. For other Linux systems, consult your packaging
documentation.

For macOS and Windows, the native TLS libraries are used, and there are no steps needed to install them.

Run the tests: `cargo test`

Then build the software: `cargo build --release`. The 'rdap' executable binary will be available in the `target/release` directory.

Using the RDAP Client
---------------------

The basic usage is `rdap XXX` where XXX is a domain name, IP address, AS number, etc...

For more advanced usage, run `rdap --help` which should yield the extensive help guide.

Paging Output
-------------

The client has a built-in (embedded) pager. Use of this pager is controlled via the `RDAP_PAGING`
environment variable and the `-P` command argument.

It takes three values:

* "embedded" - use the built-in pager
* "auto" - use the built-in pager if the program is being run from a terminal
* "none" - use no paging

For example, `-P embedded` will default to using the built-in pager.

By default, the client will not use a pager.

When set to "auto", the client determines if a pager is appropriate.
This is done by attempting to determine if the terminal is interactive or not. If the terminal
is not interactive, paging will be turned off otherwise it will be on.

Output Format
-------------

By default, the client will attempt to determine the output format of the information. If it determines the shell
is interactive, output will be in `rendered-markdown`. Otherwise, the output will be JSON.

You can explicitly control this behavior using the `-O` command argument or the `RDAP_OUTPUT` environment variable
(see below).

Directing Queries To A Specific Server
--------------------------------------

By default, the client will use the RDAP bootstrap files provided by IANA to determine the authoritative server
for the information being requested. These IANA files have the "base URLs" for the RDAP servers.

You can override this behavior by either specifying a base "object tag" from the IANA object tags registry or with
an explicit URL.

An object tag can be specified with the `-b` command argument or the `RDAP_BASE` environment variable (see below).
For example, `-b arin` will direct the client to find the ARIN server in the RDAP object tag registry.

An explicit base URL can be specified using the `-B` command or the `RDAP_BASE_URL` environment variable.

Caching
-------

By default, the client will cache data based on the request URL and "self" links provided in the RDAP results.

This can be turned off with the `-N` command parameter or by setting the `RDAP_NO_CACHE` environment variable to "true".

Logging
-------

The client logs errors, warning, and other information on its processing. This can be controlled with the
`--log-level` command argument or the `RDAP_LOG` environment variable.

Secure Connections
------------------

By default, the client will use secure connections. The following arguments and environment variables can be used
to modify this behavior:

* `-T` or `RDAP_ALLOW_HTTP` : RDAP servers should be using HTTPS. When given or set to true, HTTP will be allowed.
* `-K` or `RDAP_ALLOW_INVALID_HOST_NAMES` : Allows HTTPS connections in which the host name does not match the certificate.
* `-I` or `RDAP_ALLOW_INVALID_CERTIFICATES` : Allows HTTPS connections in which the TLS certificate is invalid.

Configuration
-------------

Configuration of this program may be set using environment variables or
using an environment variables configuration file in the configuration
directory of this program. An example is automatically written to the
configuration directory. This configuraiton file may be customized by
uncommenting out the provided environment variable settings.

The location of the configuration file is platform dependent.

On Linux, this file is located at $XDG_CONFIG_HOME/rdap/rdap.env or
$HOME/.config/rdap/rdap.env.

On macOS, this file is located at
$HOME/Library/Application Support/rdap/rdap.env.

On Windows, this file is located at
{FOLDERID_RoamingAppData}\rdap\config\rdap.env.

Resetting
---------
Installation and Usage
----------------------

Use the `--reset` argument to reset all client state. This will remove the RDAP and IANA caches and
reset the `rdap.env` file (see above) to the default.
See the [project wiki](https://github.com/icann/icann-rdap/wiki) for information on installation
and usage of this software.


License
Expand Down
9 changes: 7 additions & 2 deletions icann-rdap-cli/src/rt/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub async fn execute_tests<'a, BS: BootstrapStore>(
QueryType::Url(url) => url.to_owned(),
_ => {
let base_url = qtype_to_bootstrap_url(&bs_client, bs, value, |reg| {
debug!("Fetching IANA registry {} for value {value}", reg.url())
info!("Fetching IANA registry {} for value {value}", reg.url())
})
.await?;
value.query_url(&base_url)?
Expand All @@ -102,12 +102,13 @@ pub async fn execute_tests<'a, BS: BootstrapStore>(
// if they URL to test is a referral
if options.chase_referral {
let client = create_client(client_config)?;
info!("Fetching referral from {query_url}");
let response_data = rdap_url_request(&query_url, &client).await?;
query_url = get_related_links(&response_data.rdap)
.first()
.ok_or(TestExecutionError::NoReferralToChase)?
.to_string();
debug!("Chasing referral {query_url}");
info!("Referral is {query_url}");
}

let parsed_url = Url::parse(&query_url)?;
Expand All @@ -132,6 +133,7 @@ pub async fn execute_tests<'a, BS: BootstrapStore>(
let mut test_run = TestRun::new_v4(vec![], v4, port);
if !options.skip_v4 && more_runs {
let client = create_client_with_addr(client_config, host, test_run.socket_addr)?;
info!("Sending request to {}", test_run.socket_addr);
let rdap_response = rdap_url_request(&query_url, &client).await;
test_run = test_run.end(rdap_response, options);
}
Expand All @@ -144,6 +146,7 @@ pub async fn execute_tests<'a, BS: BootstrapStore>(
.origin(HeaderValue::from_str(&options.origin_value)?)
.build();
let client = create_client_with_addr(&client_config, host, test_run.socket_addr)?;
info!("Sending request to {}", test_run.socket_addr);
let rdap_response = rdap_url_request(&query_url, &client).await;
test_run = test_run.end(rdap_response, options);
}
Expand All @@ -159,6 +162,7 @@ pub async fn execute_tests<'a, BS: BootstrapStore>(
let mut test_run = TestRun::new_v6(vec![], v6, port);
if !options.skip_v6 && more_runs {
let client = create_client_with_addr(client_config, host, test_run.socket_addr)?;
info!("Sending request to {}", test_run.socket_addr);
let rdap_response = rdap_url_request(&query_url, &client).await;
test_run = test_run.end(rdap_response, options);
}
Expand All @@ -171,6 +175,7 @@ pub async fn execute_tests<'a, BS: BootstrapStore>(
.origin(HeaderValue::from_str(&options.origin_value)?)
.build();
let client = create_client_with_addr(&client_config, host, test_run.socket_addr)?;
info!("Sending request to {}", test_run.socket_addr);
let rdap_response = rdap_url_request(&query_url, &client).await;
test_run = test_run.end(rdap_response, options);
}
Expand Down
2 changes: 1 addition & 1 deletion icann-rdap-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An RDAP client library.

[dependencies]

icann-rdap-common = { version = "0.0.20", path = "../icann-rdap-common" }
icann-rdap-common = { version = "0.0.21", path = "../icann-rdap-common" }

buildstructor.workspace = true
cidr.workspace = true
Expand Down
Loading
Loading