Commit Graph

3711 Commits

Author SHA1 Message Date
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
Piper Chester dcffd061aa README: Fix typo (#483) 2017-03-31 07:08:51 +01:00
Miek Gieben 767422ac12 Add AVC record (#480)
See
https://www.iana.org/assignments/dns-parameters/AVC/avc-completed-template
for the template, a new record that is (again) a mirror of the TXT
record. For lack of a better name, name the rdata Txt - as we do in SPF
and TXT.
2017-03-29 22:17:13 +02:00
saurori 89d392d274 Fix large RSA exponent check (#481) 2017-03-29 21:52:38 +02:00
Richard Gibson c1bdeb82b2 Domain name limits (#478)
* limiting domain names to 255/63 octets/labels (#463)

(cherry picked from commit 0b729df06c)

* account for \ and \xxx in presentation format

(cherry picked from commit a094f774892fb4305051d185c2488cb43200c4d9)

* go fmt

* Add tests for UnpackDomainName

Domain names must not exceed 255 octets in wire format.

Ref gh-463
Ref gh-469

* Fix UnpackDomainName

* Introduce a long-domain sentinel error

A typed error would be better, but inconsistent with this library.
cf.  https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully
2017-03-29 20:43:02 +01:00
Tom Limoncelli b54e1be39a Add DNSControl to the list of users (#477) 2017-03-22 21:36:10 +00:00
andrewtj 765aea0018 Cover NSEC3 Salt and allow mixed case in NSEC3 NextDomain (#475)
* Add test to cover packing of NSEC3 salt

* Allow mixed case in NSEC3 NextDomain
2017-03-22 06:49:16 +00:00
Roland Bracewell Shoemaker fb16e4c487 Only pack NSEC3/NSEC3PARAM salt when it is not empty (#474)
* Only pack when salt is not empty

* Actually generate things properly

* Use string literal
2017-03-21 19:35:21 +00:00
Miek Gieben 25ac7f1714 Revert "limiting domain names to 255/63 octets/labels (#463)"
This reverts commit 0b729df06c.
2017-03-21 07:03:31 +00:00
Julius Rickert 2d7eb4f050 Fixed typo (#472) 2017-03-19 15:10:46 +00:00
Jon Nappi c862b7e359 Replace Atoi with ParseUint where appropriate (#470)
* replace Atoi with ParseUint where appropriate

* more Atoi replacements
2017-03-10 21:57:03 +00:00
Michael 59e593b27b Added coredns to list of users (#468) 2017-03-08 07:08:31 +00:00
Yongcheng Bao eda6b32024 Update README.md (#466)
add use case
2017-02-27 10:24:06 +00:00
Ethan J. Jackson 2d57b17e0c README: Add Quilt to the list of users (#465)
Quilt is container orchestrator that depends on JavaScript as its
configuration mechanism.  It takes advantage of miekg/dns for name
resolution, and thus should be listed in the README.md file.
2017-02-27 07:49:27 +00:00
Olafur Gudmundsson 0b729df06c limiting domain names to 255/63 octets/labels (#463) 2017-02-21 22:36:40 +00:00
Miek Gieben 75229eecb7 msg.go: don't fiddle with Compress (#460)
Don't set Compress to false on dns to calucate the uncompressed length,
instead a a function where the compression is a flag and use that.
2017-02-17 12:10:30 +00:00
Miek Gieben 01a32dc202 Re-gen zcompress.go (#461)
and add one golint/doc fix intoit.
2017-02-17 11:59:01 +00:00
devnev e95d107053 Fix data race in error handling. (#459)
The response message must copied regardless of whether there was an
error or not, otherwise two concurrent queries may modify the response
as they write it out.
2017-02-17 11:38:00 +00: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 5a15a35f5f Golint fixes (#456)
Fixes #370
2017-02-15 20:40:16 +00:00
Curtis Brandt ec20779724 Update GoDoc reference to EDNS0_SUBNET.SourceNetmask field. (#455) 2017-02-14 22:00:34 +00:00
James Hartig 672033dedc Added NameList function to ClientConfig (#452) 2017-02-13 20:16:50 +00:00
Andrew Brampton dadd480c0d Refactored the udp*.go files, to remove redundancy, and to make them compile for Go on App Engine. (#451)
App Engine even though is Linux, does not allow referencing the syscall package. Thus I reorganised
the udp*.go files a little to make this work. As best I can the functionality is unchanged, and all
this continues to compiles on darwin, linux, windows, plan9 and appengine.

Namely:
* Moved all Linux specific code from udp.go into udp_linux.go (e.g setUDPSocketOptions)
* Deleted udp_plan9.go which was almost a copy of udp.go.
* Added build tags to stop appengine using the linux build, and instead using the udp_other.go.
2017-02-13 09:42:34 +00:00
Andrew Brampton ea75cede31 A co.Conn is not always a (*net.UDPConn) so don't convert to it. (#450) 2017-02-11 08:53:59 +00:00
Miek Gieben 4e953232d8 dns/tcp: more robust read. (#448)
My home router only return 1 byte on the initial tcp read of 2 bytes
for the size of the reply. We should read the other byte as well if this
happen.

With this fix, this:
~~~
% ./q -tcp @192.168.1.1 higgs
;; dns: short read
~~~

becomes:
~~~
% ./q -tcp @192.168.1.1 higgs
;; opcode: QUERY, status: NOERROR, id: 12968
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;higgs.	IN	 A

;; ANSWER SECTION:
higgs.	0	IN	A	192.168.1.108

;; query time: 10737 µs, server: 192.168.1.1:53(tcp), size: 44 bytes
~~~
2017-02-07 22:33:10 +00:00
Tom Thorogood f3c59acd3d Work around golang/go#11833 predictable random issue in Id. (#447)
* Work around golang/go#11833 predictable random issue.

In certain circumstances crypto/rand.Reader will return non-random
bytes. The most likely case is near boot, and as init is run when
the go program is started, it's possible that a non-random seed
could be used. While this is very unlikely to ever be an issue,
it is a very easy fix and it is preferable to be resilient.

Instead of seeding the global math/rand rng during init, a separate
math/rand.Rand is seeded upon the first call to Id. This also avoids
polluting the global math/rand rng which might be seeded elsewhere.

If crypto/rand.Reader fails, math/rand.Int63 will be called to
provide a seed. This is better than the current fallback to a seed
of 1.

This change introduces no noticeable performance overhead as the
global math/rand rng already uses a sync.Mutex internally.

* Document lack of performance overhead from mutex in `func id()`
2017-02-05 08:47:07 +00:00
Tom Thorogood 8060d9f513 Improve DNSSEC performance by addressing some low hanging fruit. (#446)
* Produce less garbage in dnssec.go.

This change removes several needless append calls.

This is a minor performance improvement and will likely go
entirely unnoticed. The changes will reduce the amount of
garbage produced when calling (*DNSKEY).ToDS, (*RRSIG).Sign
and (*RRSIG).Verify.

* Minor performance improvement in RSA DNSSEC key generation.

This change ensures that (*big.Int).Bytes is only called once in
exponentToBuf because each call has non-zero overhead. It also
makes buf large enough to append without a second allocation.

exponentToBuf is invoked by (*DNSKEY).setPublicKeyRSA which is in
turn invoked by (*DNSKEY).Generate when (*DNSKEY).Algorithm is set
to an RSA* constant.

This is a minor performance improvement that will likely go
entirely unnoticed. The changes will improve the performance and
reduce the ammount of garbage produced when calling
(*DNSKEY).Generate.
2017-02-03 12:34:08 +00:00
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