Skip to content

Fix/question class matching - #553

Merged
keepsimple1 merged 6 commits into
keepsimple1:mainfrom
thankgodode:fix/question-class-matching
Nov 21, 2026
Merged

keepsimple1 merged 6 commits into
keepsimple1:mainfrom
thankgodode:fix/question-class-matching

Conversation

@thankgodode

Copy link
Copy Markdown
Contributor

Summary

Fix the responder so it checks a question’s DNS class before answering. It now answers class IN and class ANY queries, while ignoring unsupported classes such as class 2.

Why

Previously, a class 2 query for a known hostname could receive a class IN address record, even though the classes did not match.

Testing

  • Added a parser test covering IN, ANY, unsupported classes, and the QU bit.
  • Added a responder test that confirms IN receives an answer and class 2 does not.
  • Verified the responder test fails without the fix and passes with it.
  • Ran cargo test --lib.

@keepsimple1 keepsimple1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for your PR! Comments inline.

Comment thread src/dns_parser.rs Resolved
Comment thread src/service_daemon.rs Resolved
Comment thread src/dns_parser.rs Resolved
Comment thread src/service_daemon.rs Resolved
Comment thread src/service_daemon.rs Resolved
@thankgodode

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I’ve pushed the changes: simplified the class helper, preserved the accepted questions in legacy replies, updated the test error message, and shortened the comment. All 111 library tests pass.

Comment thread src/dns_parser.rs Resolved
Comment thread src/service_daemon.rs Resolved
Comment thread src/dns_parser.rs Resolved
Comment thread src/dns_parser.rs Resolved

@thankgodode thankgodode left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed the latest review comments and merged upstream main to resolve the conflict. All 112 library tests pass. Ready for another look—thanks!

@keepsimple1 keepsimple1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for updating, looks good! I've made a couple of nit edits before ready to merge.

@keepsimple1
keepsimple1 merged commit 958b5a9 into keepsimple1:main Nov 21, 2026
6 checks passed
@thankgodode
thankgodode deleted the fix/question-class-matching branch November 21, 2026 06:48
Sealdot added a commit to Sealdot/mdns-sd that referenced this pull request Nov 22, 2026
When a probe conflict triggers name_change/hostname_change, the appended ` (n)`/`-n` suffix can push the first label past MAX_LABEL_BYTES, after which write_name rejects every packet and the service silently vanishes.

Shorten the base so the label with the new suffix still fits, like mDNSResponder: measure wire bytes via escape-aware helpers in dns_parser.rs (\. and \\ count as one byte, never cut inside a pair or a UTF-8 char), trim a trailing space/`-`, and recompute on every rename as ` (9)` -> ` (10)` grows the suffix. register_service now rejects an instance label over 63 wire bytes up front instead of failing silently on the network.

Fixes keepsimple1#549.

Rebased onto main @ e5ee843 (keepsimple1#553, keepsimple1#555): test imports union upstream's new_multicast_socket with this change's check_instance_label_length.

AI assistance: Cognition Devin CLI agent (SWE-2 High).
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