Skip to content

Conversation

@ArcticLampyrid
Copy link

@willstott101
Copy link
Contributor

willstott101 commented Jul 19, 2024

Thanks, I want to try and get a new release out this weekend. Apologies for the quiet.

I appreciate the link to the spec, even so could you add a brief description of the changes you've made? Just to help me understand the diff a bit quicker.

@ArcticLampyrid
Copy link
Author

A DNS response can be divided into answers and additional answers. The answers should only include the domain name requested by the user (in the past, it included data not requested by the user), while the additional answers are used to include data not requested by the user but possibly needed in subsequent requests, to reduce the number of broadcast packets.

Copy link
Contributor

@willstott101 willstott101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this improvement, but I'm not quite prepared to merge it right now. I'm inclined to think I would prefer we collated a de-serialized DNS response as structs and then packet-ised it, rather than stream-producing something only a few hundred bytes long. That would be easier to test and reason about IMO

}
let response = builder.build().unwrap_or_else(|x| x);
if question.qu {
unicast_builder = self.handle_question(&question, unicast_builder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you've removed the collation here (as every single handle_question might move the builder to the additional section), but it does seem unfortunate.

   When possible, a responder SHOULD, for the sake of network
   efficiency, aggregate as many responses as possible into a single
   Multicast DNS response message.  For example, when a responder has
   several responses it plans to send, each delayed by a different
   interval, then earlier responses SHOULD be delayed by up to an
   additional 500 ms if that will permit them to be aggregated with
   other responses scheduled to go out a little later.

This library doesn't ever meaningfully delay responses atm, so sending all answers in a single packet seems perfectly sensible to me, and ideally I'd like to keep it that behaviour.

https://datatracker.ietf.org/doc/html/rfc6762#section-6.4


/// Packet building helpers for `fsm` to respond with `ServiceData`
impl ServiceData {
pub fn add_ptr_rr(&self, builder: AnswerBuilder, ttl: u32) -> AnswerBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this move to pure functions from functions that take a builder, but the reality of the resulting handle_question function is just too difficult to read for me. There is so much repetition of add_answer and it's arguments I can barely keep up. There must be a better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants