Skip to content

refactoring: remove the duplicated TXT decoding in dns_parser - #500

Merged
keepsimple1 merged 1 commit into
mainfrom
dedup-txt-property
Sep 4, 2026
Merged

keepsimple1 merged 1 commit into
mainfrom
dedup-txt-property

Conversation

@keepsimple1

@keepsimple1 keepsimple1 commented Sep 4, 2026

Copy link
Copy Markdown
Owner

dns_parser and service_info each carried their own copy of decode_txt, the TxtProperty struct, its five From impls, its Display and Debug impls, HEX_TABLE and u8_slice_to_hex, identical apart from the log macro (trace! vs debug!) and the wording of one message.

This was due to historical reason: we tried to separate dns_parser out into own crate. Now we should remove the duplicated copy. dns_parser now uses the service_info copy, which is the canonical one: it is the public, serde- derived TxtProperty that the crate re-exports, and it has the key() and val() accessors the dns_parser copy lacked. dns_parser already depends on service_info, so this adds no new coupling.

dns_parser and service_info each carried their own copy of decode_txt, the
TxtProperty struct, its five From impls, its Display and Debug impls,
HEX_TABLE and u8_slice_to_hex -- about 145 lines, identical apart from the
log macro (trace! vs debug!) and the wording of one message.

Two copies of a decoder for attacker-supplied bytes will drift, and a fix
applied to one would not reach the other. dns_parser now uses the
service_info copy, which is the canonical one: it is the public, serde-
derived TxtProperty that the crate re-exports, and it has the key() and
val() accessors the dns_parser copy lacked.

dns_parser already depends on service_info, so this adds no new coupling.
The only behavior change is that the "TXT record contains invalid data"
message, on the Debug and rdata_print paths, is now logged at debug rather
than trace, matching what the resolve path has always used.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@keepsimple1
keepsimple1 merged commit a6af4b5 into main Sep 4, 2026
3 checks passed
@keepsimple1
keepsimple1 deleted the dedup-txt-property branch September 4, 2026 05:45
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.

1 participant