NLnetLabs / domain

A DNS library for Rust.
https://nlnetlabs.nl/projects/domain/about/
BSD 3-Clause "New" or "Revised" License
355 stars 60 forks source link

Ns record extraction #244

Closed Wicpar closed 11 months ago

Wicpar commented 11 months ago

Hi, I am trying to get the authority servers as a fallback if a dns challenge is not present and replay the query on a more restricted config only with the authority servers, however do not know which type to use for .into_record::<??> to get the dname from the authority NS record.

partim commented 11 months ago

If you have a message already, getting the authority section and then calling limit_to::<Ns<_>>() is probably what you are after. This will give you an iterator over all the NS records in the additional section (or, well, strictly speaking a result).

So, something like this:

for record in msg.additional()?.limit_to::<domain::rdata::Ns<_>>() {
    let record = record?;

    // Do something with the record ...
}

Is that roughly what you were looking for?

Wicpar commented 11 months ago

ah i see, i was missing the limit_to function :)