[GH-ISSUE #559] Get access to "raw" dns reply #240

Open
opened 2026-03-07 22:57:37 +03:00 by kerem · 3 comments
Owner

Originally created by @kpcyrd on GitHub (Sep 19, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/559

I'm looking for a method similar to Resolver::lookup(name, record_type) that returns something like this:

enum Reply {
    Success(RegularDnsReply),
    Fail(DetailedAccessToError),
}

I've tried to match on a specific error in ResolveError but it seems I can only match on NXDOMAIN, but not e.g. SRVFAIL.

I would like to treat every dns reply as a success and only return an Err(_) if I didn't receive a reply at all (eg timeouts or something else io related).

Thanks!

Originally created by @kpcyrd on GitHub (Sep 19, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/559 I'm looking for a method similar to `Resolver::lookup(name, record_type)` that returns something like this: ``` enum Reply { Success(RegularDnsReply), Fail(DetailedAccessToError), } ``` I've tried to match on a specific error in ResolveError but it seems I can only match on NXDOMAIN, but not e.g. SRVFAIL. I would like to treat every dns reply as a success and only return an `Err(_)` if I didn't receive a reply at all (eg timeouts or something else io related). Thanks!
Author
Owner

@bluejekyll commented on GitHub (Sep 19, 2018):

The message is evaluated here:

github.com/bluejekyll/trust-dns@04c9f817c8/resolver/src/lookup_state.rs (L351-L358)

Right now ResolveError and ResolveErrorKind don't currently have detailed error conditions for this, but these can be added. You'll notice that the Resolver has that handle_nxdomain method call. This is because NxDomain isn't regarded as a protocol, or service error, but a valid response where the records just don't exist.

For what you want, we could add a new kind to ResolveErrorKind, similar to NoRecordsFound, that would have the response code, and then whatever information we want. This could be the full Message. I haven't really considered this case in a lot of detail, so if you have other details, I'm happy to discuss.


Edit: I didn't respond to this

I would like to treat every dns reply as a success and only return an Err(_) if I didn't receive a reply at all (eg timeouts or something else io related).

This would be a much bigger change. I understand why you want this, and am aware other libraries for things like HTTP take this stance. This would be a bigger fundamental change to the API, so we'd have to discuss the value of that, as I think extracting the details from the Error/ErrorKind would be fairly straightforward. Again, happy to discuss.

<!-- gh-comment-id:422673174 --> @bluejekyll commented on GitHub (Sep 19, 2018): The message is evaluated here: https://github.com/bluejekyll/trust-dns/blob/04c9f817c8983b8f3c7c3e9d7dedff12b73b3226/resolver/src/lookup_state.rs#L351-L358 Right now ResolveError and ResolveErrorKind don't currently have detailed error conditions for this, but these can be added. You'll notice that the Resolver has that `handle_nxdomain` method call. This is because NxDomain isn't regarded as a protocol, or service error, but a valid response where the records just don't exist. For what you want, we could add a new kind to ResolveErrorKind, similar to `NoRecordsFound`, that would have the response code, and then whatever information we want. This could be the full Message. I haven't really considered this case in a lot of detail, so if you have other details, I'm happy to discuss. ---- Edit: I didn't respond to this > I would like to treat every dns reply as a success and only return an Err(_) if I didn't receive a reply at all (eg timeouts or something else io related). This would be a much bigger change. I understand why you want this, and am aware other libraries for things like HTTP take this stance. This would be a bigger fundamental change to the API, so we'd have to discuss the value of that, as I think extracting the details from the Error/ErrorKind would be fairly straightforward. Again, happy to discuss.
Author
Owner

@ntrippar commented on GitHub (Nov 14, 2019):

@bluejekyll O'm looking for the same kind of details, i would like to get if the response is nxdomain, noerror, or whatever. currently with the trust_dns_resolver::error::ResolveError the response details is really limited. (maybe there is another way, thats also why im asking here)

<!-- gh-comment-id:553715159 --> @ntrippar commented on GitHub (Nov 14, 2019): @bluejekyll O'm looking for the same kind of details, i would like to get if the response is nxdomain, noerror, or whatever. currently with the `trust_dns_resolver::error::ResolveError` the response details is really limited. (maybe there is another way, thats also why im asking here)
Author
Owner

@bluejekyll commented on GitHub (Nov 14, 2019):

So the problem here as I see it is that the Resolver will always retry on errors, and the only thing your get in response is the last or final error.

Not knowing what your use-case is, but is the Client out of trust-dns-client something that would be potentially a little closer to your needs?

<!-- gh-comment-id:553730067 --> @bluejekyll commented on GitHub (Nov 14, 2019): So the problem here as I see it is that the Resolver will always retry on errors, and the only thing your get in response is the last or final error. Not knowing what your use-case is, but is the Client out of trust-dns-client something that would be potentially a little closer to your needs?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#240
No description provided.