Commit Graph

3834 Commits

Author SHA1 Message Date
Tom Thorogood 4a8fde8d2a Add go1.10.x to Travis (#718)
tip now points to what will be go1.11 leaving go1.10 untested.
2018-08-04 08:48:20 +01:00
Tom Thorogood b559d43c31 Abstract shutdown checking into seperate function (#716) 2018-07-28 13:47:30 +01:00
Tom Thorogood 1e845a5b06 Use RFC 8032 functions added to x/crypto/ed25519 (#715)
This was added in golang/crypto@5ba7f63082 and can replace the
workaround from #458.
2018-07-25 13:01:44 +01:00
Lorenzo Fontana 8004f28488 Add testcases to validate consistency of packDataNsec (#714)
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2018-07-23 22:44:09 +01:00
Jerry Jacobs 3e6e47bc11 README.md: Add github.com/xor-gate/sshfp (#706) 2018-07-01 19:37:35 +01:00
Miek Gieben e7c3f513a1
Remove compression from AFSDB (#704)
This type should not compress its rdata.

Fixes #521
2018-06-23 09:43:19 +01:00
Joel Sing ed07089f3b Correctly handle $GENERATE modifiers (#703)
* Add a ParseZone test for $GENERATE.

* Add a test for modToPrintf used by $GENERATE.

* Correctly handle $GENERATE modifiers.

As per http://www.zytrax.com/books/dns/ch8/generate.html, the width and type (aka base)
components of a modifier are optional. This means that ${2,0,d}, ${2,0} and ${2} are
valid modifiers, however only the first format was previously permitted. Use default
values for the width and/or type if they are unspecified in the modifier.
2018-06-23 09:12:44 +01:00
Miek Gieben df46691620
Add IsDuplicate function (#699)
The makes checking for duplicates more efficient, as you don't have to
use String() and re-parse elements from it anymore.

Fixes #679
2018-06-23 09:12:31 +01:00
Miek Gieben f90eb8fb45
tests: remove t.Log(f) when nothing is failing (#698)
* tests: remove t.Log(f) when nothing is failing

This clears up the travis output some more and adheres to the Unix
saying: no output is good news
2018-06-07 19:15:11 +01:00
Miek Gieben 4c681ac41f
dep ensure -update (#697)
* Some deletes

* some adds
2018-06-07 19:14:42 +01:00
Anton Korshikov c9cd01bc14 Update vendor libs (#690 and #655) (#694) 2018-06-06 18:35:07 +01:00
Andrew Tunnell-Jones 0a83f30697 Harden RSA public key unpacking (#693)
RFC 2537 (RSA/MD5) and RFC 3110 (RSA/SHA1) disallow leading zero octets.
RFC 5702 (RSA/SHA256 and RSA/SHA512) isn't specific but defers to these
earlier RFCs in other places.

There is an upper limit of 4096 bits for both the modulus and exponent.
The modulus must be at least 512 bits. No minimum is specified for the
exponent but a quick search suggests single byte exponents are viable.

Exponents larger than 32 bits are already disallowed. This commit adds
checks for the other requirements, general bounds checks, and defers
initialisation of the big num till the other checks have passed.
2018-06-05 07:18:10 +01:00
Miek Gieben 5a2b9fab83 Release 1.0.8 2018-06-04 22:06:13 +01:00
andrewtj da0e668c16 Fix unpacking RSA exponent and tighten exponent validation (#692)
* Add test from #688 demonstrating bug decoding RSA exponent

* Unpack RSA exponent in correct order

Fixes #688

* Don't unpack RSA keys with an exponent too large for the crypto package

* Update dnssec_test.go

Fix the one nit
2018-06-04 21:58:29 +01:00
Francois Tur d8bd04e7e1 Fix DialTimeout for direct call of Dial (#691)
* ensure dialTimeout is used at Dial time. Ensure dial functions setup the right timeout

* - on Dialing, ensure a dialTimeout for the Dialer only if it is just created, else keep going with parameters of the Dialer.
2018-06-04 21:36:08 +01:00
Tom Thorogood 8ccae88257 Require URLs for DOH addresses (#684)
* Require URLs for DOH addresses

* Move time.Now directly above http.Client.Do in DoH

* Remove https scheme check from DOH

Although the draft RFC explicitly requires that the scheme be https,
this was deemed undesirable, so remove it.
2018-05-29 15:39:02 +01:00
andrewtj 350cd086d1 Don't use padding in base32 helpers (#683)
The base32 variant NSEC3 uses doesn't have padding. This hasn't been a
problem in practice because SHA1 is the only current NSEC3 hash algorithm
and its output doesn't require padding.

No-pad support was introduced in Go 1.9 which is the oldest release this
package supports.
2018-05-21 20:47:51 +01:00
Miek Gieben 0947afec0a
Revert 6f3c0a126c (#682)
Previous behavior was correct. Checking with coredns:

current:

~~~
; <<>> DiG 9.10.3-P4-Debian <<>> +norec +noad +edns=1 +noednsneg soa miek.nl @localhost -p 1043
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: ?256, id: 35480
;; flags: qr; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 0
;; Query time: 0 msec
;; SERVER: ::1#1043(::1)
;; WHEN: Sat May 19 16:42:54 BST 2018
;; MSG SIZE  rcvd: 23
~~~

this pr:

~~~
; <<>> DiG 9.10.3-P4-Debian <<>> +norec +noad +edns=1 +noednsneg soa miek.nl @localhost -p 1043
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: BADVERS, id: 25912
;; flags: qr; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 0
;; Query time: 0 msec
;; SERVER: ::1#1043(::1)
;; WHEN: Sat May 19 16:51:28 BST 2018
;; MSG SIZE  rcvd: 23
~~~
2018-05-21 20:47:30 +01:00
Miek Gieben 0f8c7717de
doh: Fix mime type (#681)
Latest draft uses "application/dns-message".
2018-05-20 16:56:13 +01:00
Miek Gieben e57bf427e6 Release 1.0.7 2018-05-16 07:59:02 +00:00
Tom Thorogood 64746df23b WIP: DNS-over-HTTPS support for Client.Exchange API (#671)
* Add DNS-over-HTTPS support to (*Client).Exchange

* Ignore net/http goroutine leak from DoH

* Use existing Dialer and TLSConfig fields on Client for DOH

* Make DOH http.Client fully configurable

* Pipe context into exchangeDOH
2018-05-16 08:54:01 +01:00
Miek Gieben 3745b9737d
Small comment tweaks (#678)
Some post #668 comments nits.
2018-05-16 08:53:51 +01:00
Pierre Souchay 09649115c1 Fixed len computation when size just goes beyond 14 bits (#668)
* Fixed len computation when size just goes beyond 14 bits

* Added bouds checks around 14bits

* Len() always right including when around 14bits boudaries

* Avoid splitting into labels when not applicable

* Fixed comments

* Added comments in code

* Added new test cases

* Fixed computation of Len() for SRV and all kind of records

* Fixed Sign that was relying on non-copy for Unit tests

* Removed unused padding

* Fixed typo in PackBuffer() function

* Added comment about packBufferWithCompressionMap() for testing purposes
2018-05-16 07:20:13 +01:00
Uladzimir Trehubenka 621df0907e Make MaxTCPQueries configurable (#673) 2018-05-14 20:12:20 +01:00
Tom Thorogood 77d95a53d0 Handle empty NSEC3 salt in scanner (#677)
Fixes #676
2018-05-14 20:07:52 +01:00
chantra 1f2aa4c780 do not modify dns.Rcode when packing to wire format (#675)
* do not modify dns.Rcode when packing to wire format

When the message has an EDNS0 option in the additional section and
dns.Msg.Rcode is set to an extended rcode, dns.Msg.PackBuffer() modifies
dns.Msg.Rcode.
If you were to `Pack` the message and log it after, the Rcode would show
NOERROR.

Running the test before the change would error with:

```
=== RUN   TestPackNoSideEffect
--- FAIL: TestPackNoSideEffect (0.00s)
	msg_test.go:51: after pack: Rcode is expected to be BADVERS
```

after fixing dns.Msg.PackBuffer(), all tests are still passing.

Fixes #674

* address comments from PR#675
2018-05-13 08:36:02 +01:00
Miek Gieben a93f3e4f6b
copyHeader is redundant (#672)
copyHeader() is redundant, we allocate a header and then copy the
non-pointer elements into it; we don't need to do this, because if we
just asssign rr.Hdr to something else we get the same result.

Remove copyHeader() and the generation and use of it in ztypes.go.
2018-05-10 14:50:26 +01:00
Miek Gieben eac804ceef Release 1.0.6 2018-05-09 20:05:41 +01:00
Uladzimir Trehubenka 98a1ef4565 Use workers instead spawning goroutines for each incoming DNS request (#664)
* Use workers instead spawning goroutines for each incoming DNS request

* Replace count (int) with inUse (bool)
2018-05-09 16:44:32 +01:00
Stefan Aurori 9c76f9827e Add DSA to SHA1 mapping in dnssec AlgorithmToHash (#670) 2018-05-05 19:03:36 +02:00
Tom Thorogood 01d59357d4 Cleanup serve function (reland) (#667)
* Split central ServeDNS code out of (*Server).serve

* Add UDP and TCP specific (*Server).serve wrappers

* Move UDP serve functionality into serveUDPPacket

* Merge serve into serveTCPConn

* Cleanup serveTCPConn replacing goto with for

* defer Close in serveTCPConn

* Remove remoteAddr field from response struct

* Fix broken tsigSecret check in serveDNS

* Reorder serveDNS arguments

This makes it consistent with the ordering of arguments to
serveUDPPacket and serveTCPConn.
2018-04-06 16:09:55 +01:00
Tom Thorogood 3f2548fb60 Skip UDP OOB tests on unsupported architectures (#661) 2018-04-06 14:51:59 +01:00
Tom Thorogood 800934f8d4 Cleanup udp.go somewhat (#662)
* Avoid hard-coding required UDP OOB buffer size

* Simplify parseDstFromOOB if statements

* Use self-invoking function for udpOOBSize variable
2018-04-06 14:51:04 +01:00
Eric Greer 46f728d51b ExchangeWithDialer does not exist anymore (#666) 2018-04-06 12:05:09 +01:00
Miek Gieben 83c435cc65 Release 1.0.5 2018-04-01 13:59:20 +01:00
Miek Gieben 7fdfb0141b Revert "Cleanup serve function (#653)"
This reverts commit d174bbf0a5.
2018-04-01 12:27:36 +01:00
Miek Gieben dfb943b13e
Take the max compression offset into account in Len(). (#658)
This offset max was not taking into account leading Len() to emit a
smaller value that could not be matched by Pack(), i.e all names can
be fully compressed or used as a target for compression.

Split length tests off in seperate file length_test.go to clean up
dns_test.og a bit.
2018-04-01 09:45:32 +01:00
Tom Thorogood d174bbf0a5 Cleanup serve function (#653)
* Split central ServeDNS code out of (*Server).serve

* Add UDP and TCP specific (*Server).serve wrappers

* Move UDP serve functionality into serveUDPPacket

* Merge serve into serveTCPConn

* Cleanup serveTCPConn replacing goto with for

* defer Close in serveTCPConn

* Remove remoteAddr field from response struct

* Fix broken tsigSecret check in serveDNS

* Reorder serveDNS arguments

This makes it consistent with the ordering of arguments to
serveUDPPacket and serveTCPConn.
2018-03-30 14:50:27 +01:00
clmul 22cb769f47 use a local variable to calculate rtt (#656) 2018-03-27 08:01:29 +01:00
chantra 5b169d1842 [msg] Add UnpackRRWithHeader (#643)
This function allow to extra the raw content of a record type based on
an existing header.
Fixes #633
2018-03-15 09:09:45 +00:00
Ludovic Fernandez 906238edc6 fix: panicing on options parsing. (#642) 2018-03-01 06:22:09 -08:00
Tom Thorogood 4d25966dce Test that Shutdown does not surface closed errors (#624)
* Test that Shutdown does not surface closed errors

This test checks that calling Shutdown does not cause ActivateAndServe
(via serveTCP and serveUDP) to return the underlying
'use of closed network connection' error.

This commit unifies TestShutdownTCP with TestShutdownUDP. After this
commit, both tests will check that ActivateAndServe returns a nil error
and that Shutdown succeeded.

This was previously broken for serveTCP.

* Add comment explaining why fin chan is buffered
2018-02-27 17:38:12 -08:00
Miek Gieben 5364553f1e Release 1.0.4 2018-01-25 10:38:03 +00:00
Miek Gieben 43913f2f4f
Fix for CVE-2017-15133 TCP DOS (#631)
serveTCP calls reader.ReadTCP in the accept loop rather than in
the per-connection goroutine. If an attacker opens a connection
and leaves it idle, this will block the accept loop until the
connection times out (2s by default). During this time no other
incoming connections will succeed, preventing legitimate queries
from being answered.

This commit moves the call to reader.ReadTCP into the per-connection
goroutine. It also adds a missing call to Close whose absence allowed
file-descirptors to leak in select cases.

This attack and fix have no impact on serving UDP queries.
2018-01-25 10:36:19 +00:00
Frank Denis 862243b3b1 Add dnscrypt-proxy and rpdns to the list of users (#628) 2018-01-17 20:57:19 +00:00
Tom Thorogood f5ac34d755 Fix TCP Shutdown 'use of closed network connection' (#623)
The check for srv.started being false is in the wrong place, it should
be after Accept not after ReadTCP. If Shutdown is called, serveTCP will
currently return a 'use of closed network connection' error, which is
undesired.

This commit mirrors the behaviour of serveUDP with respect to Shutdown.
2018-01-10 13:37:59 +00:00
Miek Gieben 9cef7a0d3d Release: plain push is also needed
Apparently a git push --tags doesn't push all the changes!?!
Adding plain "git push" to avoid release confusion.
2018-01-10 08:17:22 +00:00
Miek Gieben 5ec25f2a50 Release 1.0.3 2018-01-10 08:11:11 +00:00
Tom Thorogood ddd8477be2 Ignore malformed UDP datagrams without headers (#622)
Ignore malformed UDP datagrams with incomplete DNS headers
2018-01-10 07:51:00 +00:00
Tom Thorogood 69d25e845f Fixes #613 & #619 (#621)
* Do not reutrn ErrShortRead in readUDP

A read of zero bytes indicates a peer shutdown for TCP sockets -- and
thus returning ErrShortRead is fine in readTCP -- but not for UDP
sockets. For UDP sockets a read of zero bytes literally indicates a
zero-byte datagram, and is a valid return value not indicating an error.

Removing this case will cause readUDP to correctly return a zero-byte
message.

* Return non-temporary error from serveUDP loop

Fixes #613
2018-01-09 13:57:26 +00:00