Commit Graph

3534 Commits

Author SHA1 Message Date
Tom Thorogood b6ecf29d98 Improve performance by addressing some low hanging fruit. (#444)
* Remove unused bytes.Buffer from dns/idn.encode.

This buffer is truncated and written to but never read from. It
serves no purpose and all tests pass with it removed.

It appears to have been introduced when puncycode.go was first
added in miekg/dns@e3c2c07.

* Produce less pointless garbage.

This change:
- removes several needless []byte -> string conversions,
- removes two needless append calls in HashName, and
- writes the hash to the same nsec3 []byte in HashName rather
  than creating a new []byte on each of the k iterations.

These are all minor performance improvements that will likely
go entirely unnoticed. The changes will reduce the ammount of
garbage produced when calling CertificateToDANE, HashName,
(*SIG).Sign and TsigGenerate.
2017-02-02 07:33:49 +00:00
Matthijs Mekking 99f84ae56e return errTruncated after setting header bits (#442) 2017-01-30 10:53:01 +00:00
Matthijs Mekking 2be0b50f7f use the fudge (#441) 2017-01-26 12:40:32 +00:00
Julian K ca336a1f95 Improve test suite (#435)
- Test Go 1.7 instead of 1.5
- Don't use miekg/dns when testing forks
2017-01-04 07:55:54 +00:00
fnevesbr 00b8eaaab9 Fix packing compression according to struct tagging (#433) 2016-12-27 20:21:54 +00:00
Matthijs Mekking 4f8d08ab3c fix comment (#430) 2016-12-16 14:48:54 +00:00
Diep Pham 78bb99c423 adds tests for shutdown bind port (#400)
* adds tests for shutdown bind port

* closes file descriptors in for udp on linux

* adds sleep after shutdown in test

* minimizes defer usages

* reduces sleep time

* replaces sleep with notify channel

after starting DNS server
2016-12-15 16:20:35 +00:00
Tom Thorogood 4744e915eb Fix tcp6-tls support in (*Server).ListenAndServe(). (#427)
In the switch statement srv.Net is matched for tcp6-tls but
then compared against tcp6 within the case statement. This
causes tcp6-tls to be equivalent to tcp-tls and not specific
to tcp6. The `network = "tcp6"` line was previously unreachable.

This change corrects this and ensures tcp6-tls listens on IPv6
only.
2016-12-09 07:38:01 +00:00
Richard Gibson f4d2b08694 For consistency with other types, allow empty UINFO RDATA (#424)
Ref https://github.com/miekg/dns/pull/421#discussion_r90610949
2016-12-02 22:38:56 +00:00
Richard Gibson 21314e1838 Fix TXT RDATA parsing (#421)
* Test for proper parsing of whitespace-separated (TXT) character-strings

* Properly parse whitespace-separated (TXT) character-strings

* Remove non-RFC treatment of backslash sequences in character-strings

Fixes gh-420

* For tests, remove non-RFC treatment of backslashes in domain names
2016-12-02 09:34:49 +00:00
Santhosh Manohar 271c58e0c1 Add nil check for interface value in ActivateAndServe (#419)
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-11-22 06:12:14 +00:00
ayanamist a8a1273f08 support rfc7828 (#402) 2016-11-21 20:15:42 +00:00
Marcus Grando 58f52c57ce Change VERSION private RR to use reserved space (#415) 2016-10-18 07:08:08 +01:00
Miek Gieben 46df8c9462 Fix for miekg/dns issue #289: support the SMIMEA record (#410)
1) Refactoring of tlsa.go
   - moved routine to create the certificate rdata to its own go module
     as this is shared between TLSA and SMIMEA records
2) Added support for creating an SMIMEA domain name
3) Developed in accordance with draft-ietf-dane-smime-12 RFC

Miek,

Submitting for your review. Happy to make any recommended changes or
address omissions.

Lightly tested against our internal DNS service which hosts DANE
SMIMEA records for our email certificates.

Parse tests are added.
2016-10-17 18:09:52 +01:00
Marcus Grando dfae8d8799 Fix miek.nl post link (#414) 2016-10-17 18:09:10 +01:00
Marcus Grando 3efeaabb39 Respect range of RFC6895 (#413) 2016-10-17 17:55:37 +01:00
Bilal Amarni fc4e1e2843 readme - add dockness to user list (#388) 2016-10-06 11:00:29 +01:00
Shane Kerr b96e5025a3 Simple function to clear the DO bit from an OPT resource record. (#407)
* Function to clear the DO bit from an OPT RR.

* Tests for ClearDo() function.

* Changed from ClearDo() to SetDo() with an optional argument.

* Update doc string for SetDo(). Make tests for SetDo() comprehensive.
2016-10-05 09:08:39 +01:00
Faraz Fallahi fce7af874c Add MicroDNS (#408) 2016-10-04 18:15:48 +01:00
Preet Bhinder 3f1f7c8ec9 Fix a couple of comments (#386) 2016-10-03 19:18:08 +01:00
Mehrdad Arshad Rad cb2f719c71 added mylg link to README (#397) 2016-10-03 15:37:16 +01:00
S.Çağlar Onur cd5a49decd Add a badge for godoc (#395) 2016-10-03 15:37:09 +01:00
Pavel Odintsov 8d8a1ec575 Check input data for NewPrivateKey (#399) 2016-10-03 15:36:51 +01:00
Roland Bracewell Shoemaker 574f29b9d6 Always set tokenUpper when setting token (#403) 2016-10-03 15:10:26 +01:00
Kevin Burke b4e7237e90 Fix typos (#405) 2016-10-03 15:10:00 +01:00
Miek Gieben db96a2b759 Handle empty salt value (#392)
When removing the reflection we inadvertely also removed the code for
handling empty salt values in NSEC3 and NSEC3PARAM. These are somewhat
annoying because the text representation is '-', which is not valid hex.
2016-07-25 20:20:27 -07:00
Miek Gieben 5d001d0209 zmsg: return empty rr with header (#380)
When there is no rdata, return the newly created RR with the header
embedded in it. If we only return the header, we changed the
API for Go DNS.
2016-06-14 17:21:01 +01:00
Miek Gieben e6b37d00af Cleanup and removals (#377)
* Cleanup and removals

Gut rawmsg.go as most functions are not used. Reword some documentation.
Add more types to be checked for name compression.

* Yeah, we do use these

* Remove this function as well - only used one
2016-06-13 19:44:38 +01: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 6ae3b9f061 Skip reflection for most types (#369)
Make the reflection types a black list (these types use (or should use)
the tag 'size-xxx' in their struct definition.s

HIP, IPSECKEY, NSEC3, TSIG

All other types don't use reflection anymore.

* Return a pointer to the header when there is no rdata, this restores old
  behavior. The rest of the conversion mostly hangs on getting size-hex
  right, but then packStruct and packStructValue and the unpack variant
  can be killed.
* Generate pack and unpack for all embedded types as well.
* Fix PrivateRRs, register an unpack function as well, when you register
  a new PrivateRR.
* Add the tag octet, nsec, []domains and more  to msg_helper.go
2016-06-12 16:09:37 +01:00
Miek Gieben 331ecbbc51 Add RcodeBadCookie (23) 2016-06-12 13:10:24 +01:00
Miek Gieben e048e89b44 Extra doc for DNS Cookies 2016-06-11 09:37:01 +01:00
Miek Gieben ee126a9f10 RFC 7858 and 7873 are published 2016-06-11 09:21:11 +01:00
Michael Haro 1be7320498 Use t.Errorf in tests and make the error variable naming more consistent. (#367)
* Make the error variable always named err.

Sometimes the error variable was named 'err' sometimes 'e'.  Sometimes
'e' refered to an EDNS or string and not an error type.

* Use t.Errorf instead of t.Logf & t.Fail.
2016-06-09 07:00:08 +01:00
Michael Haro 48c8acaf0c Simplify packing and unpacking (#363)
* Simplify packing and unpacking

* Make a copy of the buffer to allow buffer reuse.

* Revert use of fmt.Sprintf

I don't have time to benchmark this right now and I suspect a different
cleanup will be of higher value.
2016-06-08 17:10:03 +01:00
Michael Haro a465e84f54 Use encoding/binary's conversion functions when possible. (#364)
* Remove {un,}packUint{16,32}Msg functions.

unpackUint16Msg unpackUint32Msg packUint16Msg packUint32Msg implemented
functionality that is part of the encoding/binary package.

* Use encoding/binary's encoding in more places.
2016-06-08 16:38:42 +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 907a4aef57 Generate pack/unpack for all RRs (#360)
Add dns:txt parsing helper to prevent compile errors. This allows
us to generate all unpack/pack function.

Add pack to the RR interface definition and add this method to
PrivateRR.

We still use typeToUnpack to select which types don't use reflection.
2016-06-05 07:53:12 +01:00
Roland Bracewell Shoemaker 3f53d75269 Seed math/rand with crypto/rand (#359)
* Use crypto/rand to seed math/rand instead of using the default seed

* Better seeding+generation and fallback on crypto/rand.Read failure

* Remove user warning
2016-06-05 07:51:30 +01:00
Joe Farrell bd738b30b1 Fixed typo in docstring (#358) 2016-06-04 08:11:36 +01:00
Miek Gieben cbeae15006 Merge branch 'generate_pack' 2016-06-03 12:48:12 +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
Erik Dubbelboer 48ab6605c6 go fmt (#355) 2016-05-12 07:43:16 +01:00
phamhongviet b5deb9f6c0 Add serf-dns to the user list (#353) 2016-05-07 14:17:04 +01:00
Miek Gieben f53eb22bfb Check length before packing OPT (#352)
fixes #351
2016-05-05 16:56:17 +01:00
Miek Gieben 4355939008 massage edns cookie comment 2016-05-03 15:22:17 +00:00
Shumon Huque b534177a1a small patch for EDNS0 cookie support (#350)
* Add EDNS0 Cookie (option 10) support.

* Add EDNS0 Cookie processing.

* Fix nits.

* Add EDNS0 cookie support mention.
2016-05-03 16:19:28 +01:00
looter de1d5dd281 Added grimd project (#349) 2016-05-03 09:16:38 +01:00
Will Bond c9d1302d54 Add Client.Timeout to allow limiting total exchange duration (#345) 2016-04-19 11:29:51 +01:00