This was missing and generated the wrong code for TKEY; it adds a +1 to
the amount. This should happen (technically).
I think the fallout is not super bad (of the +1) as we allocate a byte
more for when pack a message.
* Add support for TKEY RRs
- make sure Key and Data fields are variable length hex fields
- checkin output from 'go generate'
- add a TKEY specific test to ensure this stays working
* go format changes
* address review comments
* add ability to parse TKEY via string
* handle review comments - change TKEY string output
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.
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.
* 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
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.
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)
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%
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.
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%
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
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
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.