Commit Graph

30 Commits

Author SHA1 Message Date
Miek Gieben b38dc3dcb7
Cleanup: gofmt -w -s *.go (#548)
Some renames of internal names to make go lint happier.
2017-11-03 16:15:35 +00:00
Miek Gieben 348c84f37e
Test: remove all Logf/Log (#547)
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.
2017-11-03 15:50:01 +00:00
Miek Gieben 54ceb83127 Optimize CompareDomainName (#535)
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.
2017-10-15 16:22:03 +02:00
Roland Bracewell Shoemaker 6ebcb714d3 NSEC/3 Cover+Match cleanup (#479)
* Initial NSEC cleanup

* Use readable names

* Finish tests

* Use existing functions, simplify hash/zone split

* Make IsSubDomain case insensitive, add tests

* Use internal Split instead of strings.Split
2017-04-12 19:47:48 +01:00
Miek Gieben 475ab80867 Remove (most) reflection
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.
2016-06-03 12:45:22 +01:00
tal@whatexit.org 808f9308ef Added new functions: TrimDomainName()/AddOrigin()
* TrimDomainName() Trims the domain off a FQDN.
  * AddOrigin() Adds a domain to a shortname or leaves a FQDN alone.
2016-01-25 12:08:29 -05:00
shawnps 0cea3842b9 gofmt -s 2016-01-22 08:44:49 -08:00
Michael Haro 6b54d9f863 Revert "Use gofmt to simplify code"
This reverts commit 48dce403d5.
2015-02-26 01:48:30 -08:00
Michael Haro 48dce403d5 Use gofmt to simplify code 2015-02-26 00:38:33 -08:00
Michael Haro 2fb2a25e84 More test clean up
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)
2015-02-25 22:14:21 -08:00
Michael Haro f995f1aff3 Convert tests from being t.Log(..) then t.Fail() to just t.Error(...) as
t.Error(...) does both and makes it more clear which messages are errors
vs information log messages.
2015-02-23 17:43:07 -08:00
Miek Gieben 0aa3021a83 Remove all copyright notices
Use the central COPYRIGHT file.
2014-09-11 20:57:37 +01:00
Miek Gieben f5fe400c53 Lowercase all test output.
Add Shutdown tests as well
2014-08-19 08:39:04 +00:00
Miek Gieben 1f066aa6d9 Test for procent in label names 2014-02-07 10:19:14 +00:00
Miek Gieben 1f586fdcda Fixup PrevLabel and add a test 2013-09-12 09:58:42 +01:00
Miek Gieben c67fc3a2a1 Add more tests for the labels 2013-09-12 09:18:54 +01:00
Miek Gieben 9764818db3 Make CountLabel faster
We don't need an allocation here, it works ok for non-fqdns and fqdns
2013-09-12 09:11:19 +01:00
Miek Gieben 08e7365dc2 Make SplitLabels faster
don't allocate a new string at all, it does not matter is the given
string is not fully qualified.
2013-09-12 08:57:37 +01:00
Miek Gieben 9c1ee5d5ca Update IsDomainName
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).
2013-09-10 18:09:22 +00:00
Miek Gieben db41985b91 copy the optimization from go tip into here 2013-08-23 18:41:35 +00:00
Ray Bejjani 9d2d8b36eb SplitDomainName handles non-FQDN labels correctly, doesn't return '.' in parts.
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.
2013-06-25 10:53:30 -07:00
Miek Gieben 76db7d1a62 add benchmarking 2013-06-22 09:40:00 +01:00
Miek Gieben 9762efef1e Use new names 2013-06-22 08:48:26 +01:00
Miek Gieben 2b65c92022 Merge branch 'master' of github.com:miekg/dns 2013-06-22 08:45:58 +01:00
Miek Gieben bb732937a2 Add Benchmarking functions 2013-06-22 08:40:02 +01:00
Miek Gieben 38ea608d79 Rename the Label* functions
SplitLabels -> SplitDomainName
CompareLabels -> CompareDomainName
LenLabels -> CountLabel
          -> NextLabel was added as a simple iterator-like function
2013-06-22 07:21:15 +00:00
Miek Gieben 9640d43c82 Make SplitLabels use Split 2013-06-21 15:17:12 +00:00
Miek Gieben a16b289765 Add todo 2013-06-20 20:36:13 +00:00
Miek Gieben f595bf7a06 Set license on test files 2013-05-12 16:09:52 +02:00
Miek Gieben 1bcfaec67f more radix stuff 2012-08-01 07:30:45 -07:00