mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-09-06 01:47:42 +02:00
Now that our MSRV is past 1.85, we can switch to the 2024 edition. This changes some minor behavior in the language and exposes new lints (both from check and clippy). In particular, unsafe functions now require unsafe blocks to call other unsafe functions; this is quite a nice change as it exposes more places where safety comments are needed.
32 lines
898 B
Rust
32 lines
898 B
Rust
use domain::base::Rtype;
|
|
use domain::base::name::Name;
|
|
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}");
|
|
}
|
|
}
|