mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-09-06 01:47:42 +02:00
This PR renames all types and functions that refer to domain name from using the term “dname” to just “name.” For instance, Dname becomes Name, ToDname becomes ToName, and ToDname::to_dname becomes ToName::to_name. This annoyingly wide-reaching change is motivated by a clash with the DNAME record type that would always be confusing. So we rather do it now. This is a really breaking change. Apologies.
32 lines
898 B
Rust
32 lines
898 B
Rust
use domain::base::name::Name;
|
|
use domain::base::Rtype;
|
|
use domain::rdata::AllRecordData;
|
|
use domain::resolv::StubResolver;
|
|
use std::env;
|
|
use std::str::FromStr;
|
|
|
|
fn main() {
|
|
let mut args = env::args().skip(1);
|
|
let name = args
|
|
.next()
|
|
.and_then(|arg| Name::<Vec<_>>::from_str(&arg).ok());
|
|
let rtype = args.next().and_then(|arg| Rtype::from_str(&arg).ok());
|
|
let (name, rtype) = match (name, rtype) {
|
|
(Some(name), Some(rtype)) => (name, rtype),
|
|
_ => {
|
|
println!("Usage: sync <domain> <record type>");
|
|
return;
|
|
}
|
|
};
|
|
|
|
let res = StubResolver::run(move |stub| async move {
|
|
stub.query((name, rtype)).await
|
|
});
|
|
let res = res.unwrap();
|
|
let res = res.answer().unwrap().limit_to::<AllRecordData<_, _>>();
|
|
for record in res {
|
|
let record = record.unwrap();
|
|
println!("{record}");
|
|
}
|
|
}
|