Commit Graph

3834 Commits

Author SHA1 Message Date
Miek Gieben e2db8456df
Revert "Fixes #613 (#617)" (#620)
This reverts commit ac8cd7878c.
2018-01-09 08:03:27 +00:00
Miek Gieben dcdbddd810
ClassANY: don't convert CLASS255 to ANY (#618)
* ClassANY: don't convert CLASS255 to ANY

Class "ANY" is wireformat only. In zonefile you can use CLASS255, but
when String-ing we convert this into "ANY" which is wrong. I.e. this
means we can't read back our own update.

Bit of a kludge to work around this, as I'm not sure we can just remove
ANY from the ClassToString map.
2018-01-07 17:57:04 +00:00
Twitch ac8cd7878c Fixes #613 (#617)
* Fixes #613

* use net.Error interface for detecting temporary errors
2018-01-06 16:01:19 +00:00
Miek Gieben afd3e95dbb
test: remove net tests (#616)
Never executed, flaky and failing now that some SIDN test servers
have been removed.

Just delete the code; hopefully we can bring it back one day in a CI
repo or something?
2018-01-05 13:11:23 +00:00
Miek Gieben 787fb05a25 Release 1.0.1 2017-12-21 11:36:42 +00:00
Lorenz Bauer 9088876525 Don't use untrusted lengths from Header to pre-allocate (#610)
We currently use information from a potential attacker to pre-allocate slices for the Question, Answer, etc. sections. This allows an attacker to force allocation of several MiB per parsed Msg.

Instead, don't pre-allocate those slices. append() always allocates in powers of two, which is probably the best we can do.

Fixes #609.
2017-12-21 10:24:07 +00:00
Miek Gieben 5f2d7c7013
Unpack: return header (#608)
When we unpack a message and only have the header consider it a valid
message and don't return an error.
2017-12-20 10:51:13 +00:00
Matthijs Mekking cef5150e02 Fix issue #605 (#606)
This makes `client.Readmsg` always return the message,
regardless if and how unpacking the message failed.
2017-12-18 20:15:56 +00:00
Miek Gieben 3bbde607ac
relative include: now tested! (#602)
* relative include: now tested!

If you take the effort of creating includePath, actually use it when
opening the file. Now tested (again) with CoreDNS (with a zone file that
includes two others)

Failure to include leads to:

~~~
2017/12/07 16:47:00 plugin/file: /tmp/example.org: dns: failed to include `a/1include1.org' as `/tmp/a/1include1.org': "a/1include1.org" at line: 15:24
~~~

* dont change the error line
2017-12-07 17:12:20 +00:00
Miek Gieben c438b740fe
Allow $INCLUDE to reference relative file (#598)
When using a relative file in an $INCLUDE the file is referenced from
the cwd from the calling processes; this changes it to be down from the
view point where the file exists.

Code from https://github.com/miekg/dns/issues/537#issuecomment-342932962

Fixes #537
2017-12-06 22:03:54 +00:00
Miek Gieben 6d3b6dc31b
Add size-hex: modifier for len() (#599)
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.
2017-12-06 21:41:53 +00:00
Miek Gieben e508eecd67
Some linter fixes from Go report card. (#601)
Implement small linter fixes.
2017-12-06 11:31:56 +00:00
Miek Gieben 862c2faf96
Add codecov yaml to not fail the build (#600) 2017-12-06 10:36:23 +00:00
Miek Gieben fbee4ceea9
Lint: use ignore-this on generated files (#596)
Make golint not complain about generated file - it's a bit of cheating,
but I think that is OK.
2017-12-06 10:02:47 +00:00
Miek Gieben 9271f6595b
Add semver (#595)
Add a version.go that has the semver version of this libary; now at
1.0.0. Use a struct so external code can easily check the for the
version without resulting to string parsing. Add String() function if
you want to access the version string.

Use simple Makefile.release to kick off a new release:

% edit version.go
% make -f Makefile.release

will tag and push according to version, if version is 1.0.0 the tag
in git will be v1.0.0
2017-12-06 09:46:54 +00:00
James Hartig 325e98bb86 Use and vendor golang.org/x/net/ipv4 and golang.org/x/net/ipv6 (#594) 2017-12-04 09:59:24 +00:00
Miek Gieben 6da3249dfb
EDNS0 client subnet: drop draft option (#589)
Noone should be using this option, it has been deprecated ever since
RFC 7178 came out: May 2016. Remove code that deals with that.
2017-11-28 07:48:19 +00:00
spsholleman 052efef004 Add support for TKEY RRs (#567)
* 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
2017-11-28 07:48:02 +00:00
Marc Ende 5ec0c6d20f Modified clientconfig to match ndots0 (#590)
* Modified clientconfig to match ndots0

* Added Tests for reading resolv.conf

* Cleaned up and removed duplicated code in test

* Added test for ndots below 0

* Cleaned up test

* Clean up
2017-11-27 11:17:45 +00:00
Miek Gieben 57a0d1a2cf
458+dep (#591)
* Add support for Ed25519 DNSSEC signing from RFC 8080

Note: The test case from RFC 8080 has been modified
to correct the missing final brace, but is otherwise
present as-is.

* Explain why ed25519 is special cased in (*RRSIG).Sign

* Explain use of ed25519.GenerateKey in readPrivateKeyED25519

* Add dep

This is PR #458 with the dependency added into it.
2017-11-27 10:49:53 +00:00
Miek Gieben 79bfde677f
Include missing types when for DNSSEC sig verify (#587)
rawSignatureData currently missed a few types:
MD MF RP AFSDB RT SIG PX NXT A6

We don't have NXT and A6 anymore in this lib. Add the other ones.

Fixes #523
2017-11-25 08:20:28 +00:00
Miek Gieben 2ae4695cc7
Implement CSYNC (#585)
Implement the CSYNC record.

Fixes #290

Long overdue, lets add this record. Similar in vain as NSEC/NSEC3, we
need to implement len() our selves. Presentation format parsing and
tests are done as well.

This is CoreDNS running with CSYNC support, `dig` doesn't support this
at the moment, so:

~~~
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40323
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;csync.example.org.		IN	TYPE62

;; ANSWER SECTION:
csync.example.org.	10	IN	TYPE62	\# 12 000335240042000460000008

;; AUTHORITY SECTION:
example.org.		10	IN	NS	a.iana-servers.net.
example.org.		10	IN	NS	b.iana-servers.net.
~~~
2017-11-25 08:19:06 +00:00
Miek Gieben e776a21550
Remove idn/ (#584)
Superseded by x/net/idna. It was useful, but not anymore; remove
entire directory.

Fixes #518
2017-11-25 08:18:44 +00:00
JeremyRand cdb76b64a3 Spelling fixes (#583)
* Doc: fix misspelling.

Found via "misspell" static analyzer.

* Parse test: fix misspellings.

Found via "misspell" static analyzer.
2017-11-24 08:14:48 +00:00
Miek Gieben be5ae6ca7a
Add fuzzing framework (#580)
Add easy way to fuzz this dns library, put fuzz related code in fuzz.go
and have a small Makefile.fuzz to be used:

$ make -f Makefile.fuzz build
$ make -f Makefile.fuzz fuzz

Will build and fuzz the library. Both pack/unpack and NewRR are fuzz
targets, but we could open this up.
2017-11-23 09:34:31 +00:00
Miek Gieben acff9ce3fa
Fuzzing the text parser: a few fixes (#579)
I'm fuzzing the text parser and that turned up these two. Will do
further fuzzing with these fixes in.
2017-11-20 18:07:37 +00:00
Miek Gieben 7994cb36ea
Test: rework concurrentExchange (#576)
See issue #575. Try to fix (and maybe trigger it)
2017-11-17 15:31:51 +00:00
Matthijs Mekking 99c447f9f6 TSIG name must be presented in canonical form (#574)
* TSIG name must be presented in canonical form

Update the documentation to make clear that the zonename in the
TsigSecret map must be in canonical form.

* Reference RFC 4034 for canonical form
2017-11-17 13:17:47 +00:00
Miek Gieben 2a67631d76
cleanup: remove debug.Printf from scanner (#573)
Remove the debug.Printf stuff from scanner and some other style nits.
2017-11-17 10:48:42 +00:00
Miek Gieben cfe41281c2
txt parser: fix goroutine leak (#570)
* txt parser: fix goroutine leak

When a higher level (grammar or syntax) error was encountered the lower
level zlexer routine would be left open and trying to send more tokens
on the channel c. This leaks a goroutine, per failed parse...

This PR fixes this by signalling this error - by canceling a context -
retrieving any remaining items from the channel, so zlexer can return.

It also adds a goroutine leak test that can be re-used in other tests,
the TestParseBadNAPTR test uses this leak detector.

The private key parsing code had the same bug and is also fixed in this
PR.

Fixes #586
Fixes https://github.com/coredns/coredns/issues/1233

* sem not needed anymore
2017-11-17 10:47:28 +00:00
Miek Gieben 9fc4eb252e
Server: drop inflight waitgroup (#561)
* Server: drop inflight waitgroup

This drops the waitgroup in Server, the suspicion is this can make the server
fail to stop; doing this make graceful shutdown not work.

Add test that tries to find a race between starting on stopping race;
there was a data race on srv.Inflight.

The coredns' TestReadme doesn't race anymore with this as it did with
the more evasive PR #546.
2017-11-10 10:33:17 +00:00
Miek Gieben 9cfd42f1df
Tests: add ListenAndServe tests (#562)
This increases the test coverage as these methods where not tested.
Add some cosmetic changes to the mix.
2017-11-10 10:11:23 +00:00
Miek Gieben 4bb60ce4d8
Revert "server: drop graceful handling (#546)" (#560)
This reverts commit 8223ae840e.
2017-11-09 21:01:09 +00:00
Miek Gieben 8223ae840e
server: drop graceful handling (#546)
Drop all graceful handling. There is just too much locking in
waitgrouping going on for very little gain; deal with it.

Make the error handling between serve{TCP,UDP} identical.
2017-11-09 09:38:14 +00:00
Tom Limoncelli 7e7e8dcb22 util.TrimDomainName() fails when origin doesn't end in dot (#559)
* Fix https://github.com/miekg/dns/issues/555 dnsutil.TrimDomainName tests fail

* Remove comment

* Clean up comments and code.

* Clean up comments, use dns.Fqdn() where we can, lint.
2017-11-08 18:19:10 +00:00
Miek Gieben 388f6eea29
Tests updates (#556)
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.
2017-11-08 10:01:19 +00:00
Miek Gieben 813f928d53
readme: small bunch updates (#554)
Remove specifying the versions of Go, just say the last two, this is
getting stale every single time.
2017-11-07 17:37:25 +00:00
Miek Gieben 4bcc48899c
golint fixes (#553)
* golint fixes

Comment all RR with references to relevant RFC or other docs.
Some lint fixes in edns0.go.

* Some more fixes
2017-11-07 13:45:27 +00:00
Miek Gieben f73262699a
Add goreportcard badge (#552) 2017-11-07 11:23:24 +00:00
Miek Gieben 13c92255fe
codecov: add shield to README (#551) 2017-11-07 09:35:32 +00:00
Miek Gieben ae5ce096eb
codecov: add test coverage (#550) 2017-11-07 09:17:19 +00:00
Miek Gieben b38dc3dcb7
Cleanup: gofmt -w -s *.go (#548)
Some renames of internal names to make go lint happier.
2017-11-03 16:15:35 +00:00
Miek Gieben 348c84f37e
Test: remove all Logf/Log (#547)
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.
2017-11-03 15:50:01 +00:00
andrewtj 145266a717 Make compress generate output stable and edns.go formatting (#542)
* make compress_generate.go produce stable output

* go fmt edns.go
2017-11-03 14:41:20 +00:00
David McNett a5852667e3 Document SetTsig() needs to be final RRset change (#544)
I spent several hours trying to figure out why my TSIG signatures were
failing on requests to a server.  I finally discovered this little
detail in the RFC which turned out to be my whole problem.  Amending the
documentation to hopefully spare others the same confusion.

    If an incoming message contains a TSIG record, it MUST be the last
    record in the additional section.

RFC2845 3.2
2017-10-30 06:55:49 +00:00
Ethan J. Jackson 822ae18e71 Change quilt.io link in the README to kelda.io (#539)
The project renamed itself, so this patch updates the relevant link.
2017-10-19 07:42:25 +01:00
Neo Zhuo b02ebddc7f Add Apex in Users (#538) 2017-10-18 13:32:32 +01:00
Miek Gieben 54ceb83127 Optimize CompareDomainName (#535)
Optimize CompareDomainName:
old: BenchmarkCompareDomainName-2   	 1000000	      1869 ns/op	      64 B/op	       2 allocs/op
new: BenchmarkCompareDomainName-2   	 2000000	       854 ns/op	      64 B/op	       2 allocs/op

This removes the strings.ToLower and fixes the documentation. It also
does not Fqdn's the names anymore (the documentation said we didn't, now
the documentation is right again).
Unlike what the documentation said we are comparing in a ignore-case
manor, add helper function equal that does this without calling
strings.ToLower.
2017-10-15 16:22:03 +02:00
sarneaud ca092a4398 Allow parsing resolv.conf from io.Reader (#532)
* Allow parsing resolv.conf from io.Reader

This allows projects that use this parser to write unit tests without
writing temporary files to the filesystem.

* Avoid allocation by using strings.NewReader
2017-10-15 16:18:44 +02:00
Star Brilliant f218fef126 Fix EDNS0_SUBNET compatibility with dig (#530)
Do not complain about AddressFamily=0, if SubnetNetmask is also 0.

Fixes issue #529
2017-10-13 18:04:01 +02:00