mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[PR #1919] [CLOSED] Make the Name API more principled #2697
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#2697
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hickory-dns/hickory-dns/pull/1919
Author: @djc
Created: 4/5/2023
Status: ❌ Closed
Base:
main← Head:name-api📝 Commits (4)
2ef67edproto: group Name constructors at the top of the impl blocka741a3fproto: stop deriving Default for Name and LowerName1dde4d4proto: deprecate Name::from_utf8() in favor of FromStr implcf703c0proto: parse UTF-8 as ASCII where possible📊 Changes
7 files changed (+346 additions, -262 deletions)
View changed files
📝
Cargo.lock(+37 -0)📝
crates/proto/src/rr/domain/label.rs(+24 -10)📝
crates/proto/src/rr/domain/name.rs(+265 -241)📝
crates/proto/src/rr/lower_name.rs(+1 -1)📝
crates/proto/src/rr/rdata/svcb.rs(+6 -5)📝
crates/resolver/src/async_resolver.rs(+3 -4)📝
tests/integration-tests/src/mock_client.rs(+10 -1)📄 Description
So I started to work towards a better API to accomodate the discussion in #1904. Ideally I think we'd want to allow underscore by default in host names, and potentially provide a separate API that does not allow them. So here are some things that I ran into that seem to have surprising error potential:
NameimplementsDefault, andDefaultyields an emptyNamethat is notroot(is_fqdnisfalse). This seems like a weird default value that's probably not valid in most cases? My second commit here removes theDefaultimpl forNameandLowerNameinstead.Namehas aFromStrimpl and several implementations for the localIntoNametrait, butFromStrrelies onName::from_str_relaxed()while theIntoNameimpls rely onfrom_utf8(). I think a reasonably expectation would be thatFromStrexactly callsfrom_utf8(), so I implemented that and deprecatedName::from_utf8()in favor of theFromStrimpl for good measure, which seems like a cleaner API. I think maybe theIntoNametrait predatesTryFromand could be removed in favor ofTryFromimpls these days?I noticed that
from_ascii()andfrom_utf8()have quite different behavior.Label::from_utf8()switches to callingLabel::from_ascii()when the first character of the label is_. However,Name::from_utf8()andName::from_ascii()have the documented behavioral difference thatfrom_utf8()always normalizes to lowercase whereasfrom_ascii()preserves case. This seems like very surprising behavior -- IMOfrom_ascii()should also normalize to lowercase. What do you think?cc @nrempel @cpu
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.