Commit Graph

3578 Commits

Author SHA1 Message Date
James Hartig 032fbabc82 Correctly set the Source IP to the received Destination IP (#524)
Previously, the oob data was just stored and sent to WriteMsgUDP but it
ignores the Src field when writing. Instead, now it is setting the Src
to the original Dst and handling IPv4 IPs over IPv6 correctly.
2017-09-29 10:38:26 +01:00
Richard Gibson eccf8bbe83 Correctly parse omitted TTLs and relative domains (#513)
* Fix $TTL handling
* Error when there is no TTL for an RR
* Fix relative name handling
* Error when a relative name is used without an origin (cf. https://tools.ietf.org/html/rfc1035#section-5.1 )

Fixes #484
2017-09-26 11:15:37 -04:00
Roland Bracewell Shoemaker 689d334b01 Implement EDNS(0) Padding option code (#520)
* Implement EDNS(0) Padding option code

* Fix EDNS0_PADDING.String
2017-09-21 13:50:49 +01:00
Miek Gieben e420576857 scan: Fix $INCLUDE arguments to parseZone (#508)
When an $INCLUDE was seen the arguments to parseZone where in the wrong
order meaning the filename was used as the `neworigin` instead of the
actual origin we need.

Extend the testcase to check for the full name of the record.
2017-08-18 14:14:42 +01:00
Matthijs Mekking 0598bd43cf Fix TSIG bug releated to ID substitution (#504)
* Fix TSIG bug releated to ID substitution

TSIG accounts for ID substitution. This means if the ID in the DNS
message is changed by for example a forwarder, TSIG calculation should
use the original message ID (from the TSIG RR).

I have a test for this as well, but it seems tsig_test.go has been
removed, so not sure where to put it now.

* Add tests for TSIG bugfix
2017-08-12 20:21:44 +01:00
Tim Esselens bbca4873b3 variable shadowing of token (#503)
* Added test for $INCLUDE statement parser in zone files

* FIX: localized l to switch statement, shadowed later call to os.Open(l.token)
2017-08-08 15:19:10 -07:00
Pat Moroney 0f3adef2e2 document RCodes from the IANA registry (#499)
* document RCodes from the IANA registry

* added URL to IANA registry for DNS parameters
2017-07-21 08:02:54 -07: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
Jacob Hoffman-Andrews e46719b2fe Add ExchangeContext methods. (#497)
These obey the timeouts provided in a Context.
2017-06-30 04:44:44 -07:00
Miek Gieben e78414ef75 xfr: return sane error when !RcodeSuccess (#496)
When the server returns a non succesful rcode, return that to the caller
in stead of the "bad soa" of before. "dns: bad xfr rcode: <RCODE>" is
now returned.

Fixes #467
2017-06-04 13:30:08 +01:00
Dmitriy Akulov fb6fbed0f5 Added dnsperf (#494) 2017-06-02 12:50:00 +01:00
everclear e8c11471fe Added new user (#495) 2017-06-02 12:47:46 +01:00
Alexey Palazhchenko 0c23f842c8 Use latest Go patch releases as well as tip. (#493) 2017-05-25 23:19:06 +01:00
Ray Bellis 193f91db0b Fix default response generation (#492)
- response Opcode must match request
- RD and CD semantics are only defined for QUERY
2017-05-24 15:34:52 +01:00
Miek Gieben babbdab23a parsing: error on unbalanced braces (#489)
When done parsing, check if we have balanced braces, if not error out.

Fixes #488
2017-05-23 11:21:56 +01:00
Miek Gieben f282f80e24 bump travis to 1.7/1.8 2017-05-01 16:26:13 +01:00
Danny Berger 113c7538ea Fix minor typos in comments (#486) 2017-04-26 18:46:52 +01:00
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