* add Canonical function to get name in canonical form
* replace strings.ToLower with Canonical
* rename Canonical to CanonicalName
* replace Fqdn with CanonicalName in ServeMux
* Doc updates
Was reading https://pkg.go.dev/github.com/miekg/dns?tab=doc and spotted
some types and things to could be slightly better.
Make v unexported, as this version stuff should not be part of the
public API.
Signed-off-by: Miek Gieben <miek@miek.nl>
* fix test
Signed-off-by: Miek Gieben <miek@miek.nl>
* Add a message truncation implementation
* Remove OPT if-statement at end of Scrub
* Impose RFC 6891 payload size limit in Scrub
* Remove *Msg receiver from truncateLoop
* Remove OPT record creation from Scrub
* Test that TestRequestScrubAnswerExact has correct record count
* Rename (*Msg).Scrub to Truncate
This better reflects it's purpose.
* Remove comment reference to scrubbing in Truncate
* Properly calculate the length of OPT record in Truncate
* Correct comment in IsEdns0 in regards to RFC 6891
* Handle the OPT record being anywhere in Truncate
* Slight cleanup of Msg.Truncate
* Fork packDomainName for IsDomainName
* Eliminate msg buffer from packDomainName2
* Eliminate compression code from packDomainName2
* Remove off argument and return from packDomainName2
* Remove bs buffer from packDomainName2
* Merge packDomainName2 into IsDomainName
* Eliminate root label special case from IsDomainName
* Remove ls variable from IsDomainName
* Fixup comments in IsDomainName
* Remove msg == nil special cases from packDomainName
* Eliminate lenmsg variable from packDomainName
* Eliminate label counting from packDomainName
* Change off length check in IsDomainName
* Fix IsDomainName for escaped names
* Use strings.HasSuffix for IsFqdn
* Revert "Use strings.HasSuffix for IsFqdn"
I'll submit this as a seperate PR.
This reverts commit 80bf8c83700d121ea45edac0f00db52817498166.
* Cross reference IsDomainName and packDomainName
* Correct IsDomainName max length comment
* Reduce compression memory use with map[string]uint16
map[string]uint16 uses 25% less memory per-entry than a map[string]int
(16+2)/(16+8) = 0.75. All entries in the compression map are bound by
maxCompressionOffset which is 14-bits and fits within a uint16.
* Add PackMsg benchmark with more RRs
* Add a comment to the compressionMap struct
* ClassANY: don't convert CLASS255 to ANY
Class "ANY" is wireformat only. In zonefile you can use CLASS255, but
when String-ing we convert this into "ANY" which is wrong. I.e. this
means we can't read back our own update.
Bit of a kludge to work around this, as I'm not sure we can just remove
ANY from the ClassToString map.
Start at the end of the additional section instead of the beginning.
Optionally we only scan the last 2 records, and get rid of the loop
in its entirety.
This new functions just compiles the domain to wire format, if that
works, the name is deemed OK. It is also much less strict than the
older code. Almost everything is allowed in the name, except two
dots back to back (there is an explicit test for that).
Actually just go with Robert's suggestion as this seems the
cleanest way to do it. Also saves me from thinking about could
names for the new functions.
After some discussion with Robert Edmonds, these helper functions
seems in order. It is not what he requested (that was an RRType
and RRClass as new types), but is does make sense to add some
convience functions to save some typing. The dns package itself
also used these function (4 times). So clearly there is a need.
I'm not completely sold about the names.