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

Release v0.0.18 #83

Merged
merged 28 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e2e5229
first pass at in memory storage suffix searches with domain labels
anewton1998 Mar 20, 2024
0d5c13b
Merge branch 'dev' into andy_dev
anewton1998 Aug 25, 2024
1fa0130
Merge branch 'dev' into andy_dev
anewton1998 Aug 28, 2024
d947136
domain search by name now implemented in srv
anewton1998 Aug 31, 2024
32f3084
Merge pull request #76 from icann/andy_dev
anewton1998 Aug 31, 2024
d3857ed
a bunch of clippy lint cleanups
anewton1998 Aug 31, 2024
283ad1f
Merge pull request #77 from icann/andy_dev
anewton1998 Aug 31, 2024
5157943
make description in notice/remark optional to be tolerant of bad servers
anewton1998 Aug 31, 2024
671f871
refactor of the check enum and associated functions
anewton1998 Sep 1, 2024
e6430d2
Merge pull request #78 from icann/andy_dev
anewton1998 Sep 1, 2024
55bd972
making href optional in links and adding check for it
anewton1998 Sep 1, 2024
e78c413
allows event action to be optional for misbehaving servers
anewton1998 Sep 1, 2024
c1185a9
allows public id parts to be missing for misbehaved servers
anewton1998 Sep 1, 2024
98792b4
allow cidr0 parts to be missing for misbehaving servers
anewton1998 Sep 1, 2024
7ea485a
hreflang can be a string or array of strings
anewton1998 Sep 1, 2024
3d76fe1
Merge pull request #79 from icann/andy_dev
anewton1998 Sep 1, 2024
082d260
documentation fixes plus some consistency on the object class builders
anewton1998 Sep 2, 2024
2450f49
added new docs to address #69
anewton1998 Sep 4, 2024
f1e9e2a
added roles to Contact
anewton1998 Sep 4, 2024
8891227
more complete support of contact role
anewton1998 Sep 4, 2024
59d690e
added contact-uri to Contact and cli
anewton1998 Sep 4, 2024
9d2820f
added urls to contacts
anewton1998 Sep 5, 2024
565a4e0
can now get it when street parts are an array of strings
anewton1998 Sep 5, 2024
5073e5a
Merge pull request #81 from icann/andy_dev
anewton1998 Sep 5, 2024
cb34651
fixes #74
anewton1998 Sep 5, 2024
7bbe9ae
removed from debug messages that should have been removed
anewton1998 Sep 6, 2024
94527ae
Merge pull request #82 from icann/andy_dev
anewton1998 Sep 6, 2024
706922e
bumping to v0.0.18
anewton1998 Sep 6, 2024
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
70 changes: 66 additions & 4 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ members = [
resolver = "2"

[workspace.package]
version = "0.0.17"
version = "0.0.18"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/icann/icann-rdap"
keywords = ["whois", "rdap"]

[workspace.dependencies]

# for suffix string searchs
ab-radix-trie = "0.2.1"

# easy error handling
anyhow = "1.0"

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ This repository contains open source code written by the Internet Corporation fo
for use with the Registry Data Access Protocol (RDAP). 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/).

About
-----

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

* [icann-rdap-cli](icann-rdap-cli/README.md) is the Command Line Interface client.
* [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-srv](icann-rdap-srv/README.md) is a simple, in-memory RDAP server.
* [icann-rdap-srv](icann-rdap-srv/README.md) is a simple, in-memory RDAP server. This package produces multiple executable binaries.

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 @@ -14,8 +14,8 @@ path = "src/main.rs"

[dependencies]

icann-rdap-client = { version = "0.0.17", path = "../icann-rdap-client" }
icann-rdap-common = { version = "0.0.17", path = "../icann-rdap-common" }
icann-rdap-client = { version = "0.0.18", path = "../icann-rdap-client" }
icann-rdap-common = { version = "0.0.18", path = "../icann-rdap-common" }

anyhow.workspace = true
clap.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion icann-rdap-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ by the Internet Corporation for Assigned Names and Numbers [(ICANN)](https://www
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
--------------------------
Expand Down Expand Up @@ -79,7 +80,7 @@ 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.
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).
Expand Down
26 changes: 16 additions & 10 deletions icann-rdap-cli/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async fn do_domain_query<'a, W: std::io::Write>(
let mut transactions = RequestResponses::new();
let base_url = get_base_url(&processing_params.bootstrap_type, client, query_type).await?;
let response = do_request(&base_url, query_type, processing_params, client).await;
let registrar_response;
match response {
Ok(response) => {
let source_host = response.http_data.host.to_owned();
Expand All @@ -106,11 +107,12 @@ async fn do_domain_query<'a, W: std::io::Write>(
if let Some(url) = get_related_link(&response.rdap).first() {
info!("Querying domain name from registrar.");
let query_type = QueryType::Url(url.to_string());
let registrar_response =
let registrar_response_result =
do_request(&base_url, &query_type, processing_params, client).await;
match registrar_response {
Ok(registrar_response) => {
regr_source_host = registrar_response.http_data.host;
match registrar_response_result {
Ok(response_data) => {
registrar_response = response_data;
regr_source_host = registrar_response.http_data.host.to_owned();
regr_req_data = RequestData {
req_number: 2,
source_host: &regr_source_host,
Expand All @@ -119,7 +121,7 @@ async fn do_domain_query<'a, W: std::io::Write>(
transactions = do_output(
processing_params,
&regr_req_data,
&response,
&registrar_response,
write,
transactions,
)?;
Expand Down Expand Up @@ -363,18 +365,22 @@ fn get_related_link(rdap_response: &RdapResponse) -> Vec<&str> {
let urls: Vec<&str> = links
.iter()
.filter(|l| {
if let Some(rel) = &l.rel {
if let Some(media_type) = &l.media_type {
rel.eq_ignore_ascii_case("related")
&& media_type.eq_ignore_ascii_case(RDAP_MEDIA_TYPE)
if l.href.as_ref().is_some() {
if let Some(rel) = &l.rel {
if let Some(media_type) = &l.media_type {
rel.eq_ignore_ascii_case("related")
&& media_type.eq_ignore_ascii_case(RDAP_MEDIA_TYPE)
} else {
false
}
} else {
false
}
} else {
false
}
})
.map(|l| l.href.as_str())
.map(|l| l.href.as_ref().unwrap().as_str())
.collect::<Vec<&str>>();
urls
} else {
Expand Down
42 changes: 22 additions & 20 deletions icann-rdap-cli/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,35 @@ pub(crate) async fn do_request(
let response = rdap_url_request(&query_url, client).await?;
if !processing_params.no_cache {
if let Some(self_link) = response.rdap.get_self_link() {
if response.http_data.should_cache() {
let data = serde_json::to_string_pretty(&response)?;
let cache_contents = response.http_data.to_lines(&data)?;
let query_url = query_type.query_url(base_url)?;
let file_name = format!(
"{}.cache",
PctString::encode(query_url.chars(), URIReserved)
);
debug!("Saving response to cache file {file_name}");
let path = rdap_cache_path().join(file_name);
fs::write(path, &cache_contents)?;
if query_url != self_link.href {
if let Some(self_link_href) = &self_link.href {
if response.http_data.should_cache() {
let data = serde_json::to_string_pretty(&response)?;
let cache_contents = response.http_data.to_lines(&data)?;
let query_url = query_type.query_url(base_url)?;
let file_name = format!(
"{}.cache",
PctString::encode(self_link.href.chars(), URIReserved)
PctString::encode(query_url.chars(), URIReserved)
);
debug!("Saving response to cache file {file_name}");
let path = rdap_cache_path().join(file_name);
fs::write(path, &cache_contents)?;
if query_url != *self_link_href {
let file_name = format!(
"{}.cache",
PctString::encode(self_link_href.chars(), URIReserved)
);
debug!("Saving response to cache file {file_name}");
let path = rdap_cache_path().join(file_name);
fs::write(path, &cache_contents)?;
}
} else {
debug!("Not caching data according to server policy.");
debug!("Expires header: {:?}", &response.http_data.expires);
debug!(
"Cache-control header: {:?}",
&response.http_data.cache_control
);
}
} else {
debug!("Not caching data according to server policy.");
debug!("Expires header: {:?}", &response.http_data.expires);
debug!(
"Cache-control header: {:?}",
&response.http_data.cache_control
);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions icann-rdap-cli/tests/integration/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,21 @@ async fn GIVEN_idn_WHEN_query_a_label_THEN_success() {
let assert = test_jig.cmd.assert();
assert.success();
}

#[tokio::test(flavor = "multi_thread")]
async fn GIVEN_domain_WHEN_search_domain_names_THEN_success() {
// GIVEN
let mut test_jig = TestJig::new_with_enable_domain_name_search().await;
let mut tx = test_jig.mem.new_tx().await.expect("new transaction");
tx.add_domain(&Domain::basic().ldh_name("foo.example").build())
.await
.expect("add domain in tx");
tx.commit().await.expect("tx commit");

// WHEN
test_jig.cmd.arg("-t").arg("domain-name").arg("foo.*");

// THEN
let assert = test_jig.cmd.assert();
assert.success();
}
16 changes: 15 additions & 1 deletion icann-rdap-cli/tests/integration/test_jig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use assert_cmd::Command;
use icann_rdap_srv::config::ListenConfig;
use icann_rdap_srv::server::AppState;
use icann_rdap_srv::server::Listener;
use icann_rdap_srv::storage::mem::config::MemConfig;
use icann_rdap_srv::storage::mem::ops::Mem;
use icann_rdap_srv::storage::CommonConfig;
use std::time::Duration;
use test_dir::DirBuilder;
use test_dir::FileType;
Expand All @@ -18,7 +20,19 @@ pub struct TestJig {

impl TestJig {
pub async fn new() -> TestJig {
let mem = Mem::default();
let common_config = CommonConfig::default();
TestJig::new_common_config(common_config).await
}

pub async fn new_with_enable_domain_name_search() -> TestJig {
let common_config = CommonConfig::builder()
.domain_search_by_name_enable(true)
.build();
TestJig::new_common_config(common_config).await
}

pub async fn new_common_config(common_config: CommonConfig) -> TestJig {
let mem = Mem::new(MemConfig::builder().common_config(common_config).build());
let app_state = AppState {
storage: mem.clone(),
bootstrap: false,
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.17", path = "../icann-rdap-common" }
icann-rdap-common = { version = "0.0.18", path = "../icann-rdap-common" }

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