Skip to content

Commit

Permalink
Merge pull request #75 from icann/dev
Browse files Browse the repository at this point in the history
Release 0.0.17
  • Loading branch information
anewton1998 authored Aug 28, 2024
2 parents 19de4d9 + 047e63c commit 92e1d91
Show file tree
Hide file tree
Showing 29 changed files with 4,230 additions and 18 deletions.
88 changes: 84 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.16"
version = "0.0.17"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/icann/icann-rdap"
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.16", path = "../icann-rdap-client" }
icann-rdap-common = { version = "0.0.16", path = "../icann-rdap-common" }
icann-rdap-client = { version = "0.0.17", path = "../icann-rdap-client" }
icann-rdap-common = { version = "0.0.17", path = "../icann-rdap-common" }

anyhow.workspace = true
clap.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions icann-rdap-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ enum OtypeArg {
/// RDAP JSON with extra information.
JsonExtra,

/// Global Top Level Domain Output
GtldWhois,

/// Automatically determine the output type.
Auto,
}
Expand Down Expand Up @@ -392,6 +395,7 @@ pub async fn main() -> anyhow::Result<()> {
OtypeArg::Json => OutputType::Json,
OtypeArg::PrettyJson => OutputType::PrettyJson,
OtypeArg::JsonExtra => OutputType::JsonExtra,
OtypeArg::GtldWhois => OutputType::GtldWhois,
};

let check_types = if cli.check_type.is_empty() {
Expand Down
57 changes: 53 additions & 4 deletions icann-rdap-cli/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use tracing::error;
use tracing::info;

use icann_rdap_client::{
md::{MdOptions, MdParams, ToMd},
gtld::{GtldParams, ToGtldWhois},
md::{redacted::replace_redacted_items, MdOptions, MdParams, ToMd},
query::{qtype::QueryType, request::ResponseData},
request::{RequestData, RequestResponse, RequestResponses, SourceType},
};
Expand All @@ -33,6 +34,9 @@ pub(crate) enum OutputType {
/// Results are output as Pretty RDAP JSON.
PrettyJson,

/// Global Top Level Domain Output
GtldWhois,

/// RDAP JSON with extra information.
JsonExtra,
}
Expand Down Expand Up @@ -84,7 +88,19 @@ async fn do_domain_query<'a, W: std::io::Write>(
source_host: &source_host,
source_type: SourceType::DomainRegistry,
};
transactions = do_output(processing_params, &req_data, &response, write, transactions)?;
let replaced_rdap = replace_redacted_items(response.rdap.clone());
let replaced_data = ResponseData {
rdap: replaced_rdap,
// copy other fields from `response`
..response.clone()
};
transactions = do_output(
processing_params,
&req_data,
&replaced_data,
write,
transactions,
)?;
let regr_source_host;
let regr_req_data: RequestData;
if let Some(url) = get_related_link(&response.rdap).first() {
Expand Down Expand Up @@ -135,7 +151,19 @@ async fn do_inr_query<'a, W: std::io::Write>(
source_host: &source_host,
source_type: SourceType::RegionalInternetRegistry,
};
transactions = do_output(processing_params, &req_data, &response, write, transactions)?;
let replaced_rdap = replace_redacted_items(response.rdap.clone());
let replaced_data = ResponseData {
rdap: replaced_rdap,
// copy other fields from `response`
..response.clone()
};
transactions = do_output(
processing_params,
&req_data,
&replaced_data,
write,
transactions,
)?;
do_final_output(processing_params, write, transactions)?;
}
Err(error) => return Err(error),
Expand Down Expand Up @@ -169,7 +197,19 @@ async fn do_basic_query<'a, W: std::io::Write>(
source_type: SourceType::UncategorizedRegistry,
}
};
transactions = do_output(processing_params, &req_data, &response, write, transactions)?;
let replaced_rdap = replace_redacted_items(response.rdap.clone());
let replaced_data = ResponseData {
rdap: replaced_rdap,
// copy other fields from `response`
..response.clone()
};
transactions = do_output(
processing_params,
&req_data,
&replaced_data,
write,
transactions,
)?;
do_final_output(processing_params, write, transactions)?;
}
Err(error) => return Err(error),
Expand Down Expand Up @@ -231,6 +271,14 @@ fn do_output<'a, W: std::io::Write>(
})
)?;
}
OutputType::GtldWhois => {
let mut params = GtldParams {
root: &response.rdap,
parent_type: response.rdap.get_type(),
label: "".to_string(),
};
writeln!(write, "{}", response.rdap.to_gtld_whois(&mut params))?;
}
_ => {} // do nothing
};

Expand Down Expand Up @@ -276,6 +324,7 @@ fn do_final_output<W: std::io::Write>(
OutputType::JsonExtra => {
writeln!(write, "{}", serde_json::to_string(&transactions).unwrap())?
}
OutputType::GtldWhois => {}
_ => {} // do nothing
};

Expand Down
2 changes: 1 addition & 1 deletion icann-rdap-cli/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) async fn do_request(
info!("Cache has been disabled.")
}
let query_url = query_type.query_url(base_url)?;
debug!("Requestion RDAP URL {query_url}");
debug!("Requesting RDAP URL {query_url}");
if !processing_params.no_cache {
let file_name = format!(
"{}.cache",
Expand Down
5 changes: 4 additions & 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.16", path = "../icann-rdap-common" }
icann-rdap-common = { version = "0.0.17", path = "../icann-rdap-common" }

buildstructor.workspace = true
cidr-utils.workspace = true
Expand All @@ -27,6 +27,9 @@ strum.workspace = true
strum_macros.workspace = true
thiserror.workspace = true

jsonpath-rust = "=0.5.0"
jsonpath_lib = "0.3.0"

[dev-dependencies]

# fixture testings
Expand Down
Loading

0 comments on commit 92e1d91

Please sign in to comment.