* add Canonical function to get name in canonical form
* replace strings.ToLower with Canonical
* rename Canonical to CanonicalName
* replace Fqdn with CanonicalName in ServeMux
* change NextLabel and PrevLabel to be faster
This reduces readability, but they are in the hot path of coredns.
* @redyeti pointed out, that my implementation disregarded triple backslashes
* add synthetic benchmark-tests for PrevLabel and NextLabel
* rename ii -> j
* invert compare
* PrevLabel: add empty string check + test case
* NextLabel: fix and add testcase for NextLabel("", offset>0)
* 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
Move some of them to Errorf and friends, but most of them are just
gone: This make go test -v actually readable.
Remove a bunch of test that used ipv6 on localhost as this does not work
on Travis.
Optimize CompareDomainName:
old: BenchmarkCompareDomainName-2 1000000 1869 ns/op 64 B/op 2 allocs/op
new: BenchmarkCompareDomainName-2 2000000 854 ns/op 64 B/op 2 allocs/op
This removes the strings.ToLower and fixes the documentation. It also
does not Fqdn's the names anymore (the documentation said we didn't, now
the documentation is right again).
Unlike what the documentation said we are comparing in a ignore-case
manor, add helper function equal that does this without calling
strings.ToLower.
Remove the use of reflection when packing and unpacking, instead
generate all the pack and unpack functions using msg_generate.
This will generate zmsg.go which in turn calls the helper functions from
msg_helper.go.
This increases the speed by about ~30% while cutting back on memory
usage. Not all RRs are using it, but that will be rectified in upcoming
PR.
Most of the speed increase is in the header/question section parsing.
These functions *are* not generated, but straight forward enough. The
implementation can be found in msg.go.
The new code has been fuzzed by go-fuzz, which turned up some issues.
All files that started with 'z', and not autogenerated were renamed,
i.e. zscan.go is now scan.go.
Reflection is still used, in subsequent PRs it will be removed entirely.
Remove trailing \n from t.Log and t.Error messages as it's unnecessary.
In some instances, combine multiple t.Error()s into one
To provide more consistency across the tests, rename e to err and use %v
as the format arg for errors.
Replace Logf and Errorf with Log and Error when it made sense. For
example t.Errorf("%v", err) to t.Error(err)
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).
SplitDomainName would always include the '.' after each label segment. This was
inconsistent with the "." case (were it returned nil) and didn't seem too useful
since it required more processing to remove the '.' (like when building a
compression dictionary in Msg.Len() or Msg.Pack()). It also had issues with the
last segment, not including it in the split. It now returns all segments,
including the last, irrespective of the label being fully qualified.
A test has also been added to ensure no regressions.