Commit Graph

110 Commits

Author SHA1 Message Date
Miek Gieben 388f6eea29
Tests updates (#556)
Use :0 for loopback testing. This is more portable between testing environments.
Add testRR that calls NewRR and throws error away - apply it everywhere where needed.

It seems only Go 1.9 can deal with :0 being used. Disable 1.8 in travis.
2017-11-08 10:01:19 +00:00
Miek Gieben 4bcc48899c
golint fixes (#553)
* golint fixes

Comment all RR with references to relevant RFC or other docs.
Some lint fixes in edns0.go.

* Some more fixes
2017-11-07 13:45:27 +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
Lars Lehtonen 0559e6d230 Fix ignored err variables. (#498)
* Fix ignored err variables.

* Removed unneeded err return.
2017-07-08 23:56:13 -07:00
Miek Gieben 74ec3b2433 Generate the compressionHelper functions (#454)
* Generate the compressionHelper functions and fix compression.

This was a long standing TODO: generate the compression helper
functions. This now automatically picks up new names that can be
used for compression.

When packing add names to compression map:

When packing a message we should only compress when compress is true.
But whenever the compression map is not nil we should still add names
to it that can be *used* for future compression. The packing
inadvertently only added those names when compress would be true.

* Removed unused functions
2017-02-17 09:48:37 +00:00
Miek Gieben b51e305bc6 Remove reflection (#376)
Everything is generated. Remove all uses of packStruct/unpackStruct and
make the library reflectionless.
2016-06-12 21:06:46 +01:00
Miek Gieben dbffa4b057 Kill all reflection when packing/unpacking RR (#372)
Update the size-xxx-member tags to point to another field in the struct
that should be used for the length in that field. Fix NSEC3/HIP and TSIG
to use to this and generate the correct pack/unpack functions for them.

Remove IPSECKEY from the lib and handle it as an unknown record - it is
such a horrible RR, needed kludges before - now just handle it as an
unknown RR.

All types now use generated pack and unpack functions. The blacklist is
removed.
2016-06-12 18:31:50 +01:00
Miek Gieben 799de7044d Remove WKS support
Support for WKS was incomplete, i.e. len() method was incorrect.
Remove support for the record and handle it as an unknown one.

Fixes #361
2016-06-05 08:23:44 +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
Miek Gieben dd83d5cbcf IsSubDomain docs
Improve the docs a little and add a test for when the child and parent
are equal.
2016-04-12 22:05:53 +01:00
Filippo Valsorda 023972bb19 Expose TypeToRR 2015-10-16 23:36:49 +01:00
Roland Shoemaker 522331911d Enable CAA parsing 2015-06-16 02:01:28 -07: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 acee6af0bc Merge branch 'master' of github.com:miekg/dns 2015-02-19 09:59:37 +00:00
Miek Gieben 67945c119e A bunch of golint fixes
The proposed vars names are a nono, because they break the API.
Things left: document each RR and zscan_rr.go has some funcky if-then-elses.
2015-02-19 09:58:33 +00:00
Michael Haro 9e96f28311 Fix problems noted by 'go vet' 2015-02-19 00:08:28 -08:00
Miek Gieben 48ba40204d Add some more binary tests in TestMsgPackBuffer 2015-02-18 09:17:00 +00:00
Daniel Morsing a4af4dd14e Used shared backing array for Msg.Copy
If you have a system with large amounts of copies, these slice
allocations start stacking up. Use a shared slice and then subslice
them with a cap limit so that append works properly.

Also, add a benchmark and test for Msg.Copy

Benchcmp:
benchmark         old ns/op     new ns/op     delta
BenchmarkCopy     1880          1672          -11.06%

benchmark         old allocs     new allocs     delta
BenchmarkCopy     13             11             -15.38%

benchmark         old bytes     new bytes     delta
BenchmarkCopy     528           528           +0.00%
2015-02-05 13:07:07 +00:00
Miek Gieben b6ff23905a Finish implementing IPSECKEY
Remaining tests and unpack for IPSECKEY.
2015-01-25 12:24:39 +00:00
Miek Gieben 477cb4d3fa Implement IPSECKEY
IPSECKEY is kinda strange because it has a type selector which tells
what type a later rdata field has. The type can be a domainname, address
or v6 address. You sort of wish Go would have a union type for this, but
alas.
Currently this is implemented as:

	GatewayA    net.IP `dns:"a"`
	GatewayAAAA net.IP `dns:"aaaa"`
	GatewayName string `dns:"domain-name"`

In the IPSECKEY. Only one of these is active at any one time. When
parsing/packing and unpacking the value of GatewayType is checked
to see what to do.

Parsing from strings is also implemented properly and tested. The Unpack
function still needs work.
2015-01-25 10:58:30 +00:00
Daniel Morsing 433ab7b569 Reduce amount of work done when unpacking unprintable characters.
Instead of going through the fmt package, we can use append int,
which saves an allocation.

benchmark                                old ns/op     new ns/op     delta
BenchmarkUnpackDomainNameUnprintable     2147          506           -76.43%
2014-11-06 13:51:29 +00:00
Miek Gieben a945149fab Print unknown record type with CLASSX and TYPEX
When printing unknown records it is best to print the entire thing
as unknown, instead of relying on the internal defined type. An
example A record, printed as an unknown one:
    miek.nl.      3600    CLASS1  TYPE1   \# 4 0a000101
2014-11-02 11:06:05 +00:00
Miek Gieben 02dd474056 Dont export typeToRR (old rr_mk) 2014-09-16 07:31:20 +01:00
Miek Gieben bcb640ccaf Make rr_mk public and call it TypeToRR 2014-09-16 07:15:06 +01:00
Miek Gieben 0aa3021a83 Remove all copyright notices
Use the central COPYRIGHT file.
2014-09-11 20:57:37 +01:00
Miek Gieben 06fc321c2c fmt 2014-08-30 08:45:10 +01:00
Miek Gieben 34f5a12bfc Don't crash on emtpy string in compressionLenSearch
Fixes #105
2014-08-22 08:46:24 +00:00
Miek Gieben 9f5fcf8459 Add extra length test for issue #105 2014-08-22 08:15:35 +01:00
Miek Gieben f5fe400c53 Lowercase all test output.
Add Shutdown tests as well
2014-08-19 08:39:04 +00:00
Miek Gieben 5a8fe5d5f7 Add Copy test 2014-06-06 21:10:38 +01:00
Andrew Tunnell-Jones 8772f9064c Make PackRR enforce RR data length limit
• Make rawSetRdlength return false if length would overflow
• Make PackRR assume rawSetRdlength returning false indicates an overflow
2014-04-29 05:03:01 +00:00
Miek Gieben 87b380cad5 Revert "Use dLen for domain name length"
This reverts commit b595183834.

Fix up the tests too.
2014-02-14 20:20:22 +00:00
Miek Gieben c46b0e07c3 Normalize names a bit 2014-02-12 13:36:04 +00:00
Miek Gieben 89cc033428 Be much more precice in msg.Len()
There is still a one-off in EDNS0 records, but I'm not too bothered with
that one.
2014-02-12 12:59:42 +00:00
Miek Gieben b595183834 Use dLen for domain name length 2014-02-12 12:50:16 +00:00
Miek Gieben 31102c38b7 Make Len() much more accurate for compressed messages.
Lots of changes made and bugs fixed.
2014-02-11 23:01:47 +00:00
Miek Gieben d0fa099d08 Document and disable the test 2014-02-10 20:28:17 +00:00
Miek Gieben d24565edc8 Merge branch 'len'
Cleanup the rest and add the test.
2014-02-10 20:20:08 +00:00
Miek Gieben 21283d2192 Improve msg.Len() accuracy
Currently msg.Len() overshoots a _lot_ when compression is
enabled. The main problem is that once a part of a domain is found to
be compressed, the whole domain is _not_ added back to compression
dictionary.

That means if we once cache ".microsoft.com" we won't cache
"blah.microsoft.com".

Ammended a bit: put the test in dns_test.go
2014-02-10 20:16:05 +00:00
Miek Gieben 372e3d55c3 More tests lenght 2014-02-10 12:29:33 +00:00
Miek Gieben 56e0bb46d8 Remove packLen() and fix bug in Len()
packLen() was a featureless mirror of Len(). Remove it, and just use
Len() internally too.
Fix bug in Len() too, where the length of the additional section was
not counted.
2014-02-10 12:23:53 +00:00
Alex Ciuba 008c1d5916 Add domain unpacking benchmark 2014-02-01 01:29:10 -05:00
Miek Gieben dd35496669 dont care about padding for benchmark function 2014-01-29 07:56:21 +00:00
Miek Gieben 876680216e Revert "Revert "Add benchmark for message unpacking""
This reverts commit ca87093b6d.
2014-01-29 07:52:43 +00:00
Miek Gieben 509a6ff9e2 Revert "Revert "Fix benchmark alignment""
This reverts commit b8e6bd45be.
2014-01-29 07:52:23 +00:00
Miek Gieben f2f9d43da5 Revert "Revert "Add more benchmarks""
This reverts commit 58a3a82b8e.
2014-01-29 07:51:36 +00:00
Miek Gieben 58a3a82b8e Revert "Add more benchmarks"
This reverts commit 5a3bf3d749.
2014-01-28 22:44:07 +00:00
Miek Gieben b8e6bd45be Revert "Fix benchmark alignment"
This reverts commit 008dfb4ee8.
2014-01-28 22:43:57 +00:00
Miek Gieben ca87093b6d Revert "Add benchmark for message unpacking"
This reverts commit dc4eddaf9a.
2014-01-28 22:43:37 +00:00