Skip to content

Commit 06e7ab3

Browse files
committed
add: secure dns example
1 parent ff01edb commit 06e7ab3

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

icann-rdap-common/src/response/domain.rs

+85-4
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,46 @@ lazy_static! {
256256
}
257257

258258
/// Represents the DNSSEC information of a domain.
259+
///
260+
/// The following shows how to use the builders to
261+
/// create a domain with secure DNS informaiton.
262+
///
263+
/// ```rust
264+
/// use icann_rdap_common::prelude::*;
265+
///
266+
/// // Builds DNS security `keyData`.
267+
/// let key_datum = KeyDatum::builder()
268+
/// .flags(257)
269+
/// .protocol(3)
270+
/// .algorithm(8)
271+
/// .public_key("AwEAAa6eDzronzjEDbT...Jg1M5N rBSPkuXpdFE=")
272+
/// .build();
273+
///
274+
/// // Builds DNS security `dsData`.
275+
/// let ds_datum = DsDatum::builder()
276+
/// .algorithm(13)
277+
/// .key_tag(20149)
278+
/// .digest_type(2)
279+
/// .digest("cf066bceadb799a27b62e3e82dc2e4da314c1807db98f13d82f0043b1418cf4e")
280+
/// .build();
281+
///
282+
/// // Builds DNS security.
283+
/// let secure_dns = SecureDns::builder()
284+
/// .ds_data(ds_datum)
285+
/// .key_data(key_datum)
286+
/// .zone_signed(true)
287+
/// .delegation_signed(false)
288+
/// .max_sig_life(604800)
289+
/// .build();
290+
///
291+
/// // Builds `domain` with DNS security.
292+
/// let domain = Domain::builder()
293+
/// .ldh_name("example.com")
294+
/// .handle("EXAMPLE-DOMAIN")
295+
/// .status("active")
296+
/// .secure_dns(secure_dns)
297+
/// .build();
298+
/// ```
259299
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
260300
pub struct SecureDns {
261301
#[serde(rename = "zoneSigned")]
@@ -287,15 +327,15 @@ impl SecureDns {
287327
zone_signed: Option<bool>,
288328
delegation_signed: Option<bool>,
289329
max_sig_life: Option<u64>,
290-
ds_data: Vec<DsDatum>,
291-
key_data: Vec<KeyDatum>,
330+
ds_datas: Vec<DsDatum>,
331+
key_datas: Vec<KeyDatum>,
292332
) -> Self {
293333
Self {
294334
zone_signed: zone_signed.map(Boolish::from),
295335
delegation_signed: delegation_signed.map(Boolish::from),
296336
max_sig_life: max_sig_life.map(Numberish::<u64>::from),
297-
ds_data: to_opt_vec(ds_data),
298-
key_data: to_opt_vec(key_data),
337+
ds_data: to_opt_vec(ds_datas),
338+
key_data: to_opt_vec(key_datas),
299339
}
300340
}
301341

@@ -365,6 +405,47 @@ lazy_static! {
365405
/// "ldhName": "foo.example.com"
366406
/// }
367407
/// ```
408+
///
409+
/// Domains have many sub-structures that are also constructed
410+
/// using builders, which may then be passed into a Domain
411+
/// builder.
412+
///
413+
/// ```rust
414+
/// use icann_rdap_common::prelude::*;
415+
///
416+
/// let nameservers = vec![
417+
/// Nameserver::builder()
418+
/// .ldh_name("ns1.example.com")
419+
/// .address("127.0.0.1")
420+
/// .build()
421+
/// .unwrap(),
422+
/// Nameserver::builder()
423+
/// .ldh_name("ns2.example.com")
424+
/// .build()
425+
/// .unwrap(),
426+
/// ];
427+
///
428+
/// let ds_datum = DsDatum::builder()
429+
/// .algorithm(13)
430+
/// .key_tag(20149)
431+
/// .digest_type(2)
432+
/// .digest("cf066bceadb799a27b62e3e82dc2e4da314c1807db98f13d82f0043b1418cf4e")
433+
/// .build();
434+
///
435+
/// let secure_dns = SecureDns::builder()
436+
/// .ds_data(ds_datum)
437+
/// .zone_signed(true)
438+
/// .delegation_signed(false)
439+
/// .build();
440+
///
441+
/// let domain = Domain::builder()
442+
/// .ldh_name("foo.example.com")
443+
/// .handle("foo_example_com-3")
444+
/// .status("active")
445+
/// .nameservers(nameservers)
446+
/// .secure_dns(secure_dns)
447+
/// .build();
448+
/// ```
368449
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
369450
pub struct Domain {
370451
#[serde(flatten)]

icann-rdap-srv/src/bin/rdap-srv-data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ async fn make_domain(
993993
.and_zone_signed(args.zone_signed)
994994
.and_delegation_signed(args.delegation_signed)
995995
.and_max_sig_life(args.max_sig_life)
996-
.ds_data(args.ds.clone())
996+
.ds_datas(args.ds.clone())
997997
.build();
998998
Some(secure_dns)
999999
} else {

0 commit comments

Comments
 (0)