Commit Graph

4038 Commits

Author SHA1 Message Date
cesarkuroiwa a614451ab3
Use ed25519 from Go standard lib (#1243)
* Use "crypto/ed25519"

* Remove unused dependencies

* Version bump

Co-authored-by: Cesar Kuroiwa <cesar@registro.br>
2021-03-16 15:37:10 +01:00
Tom Thorogood e5407eb800
Remove fuzz from .github/workflows/go.yml (#1238) 2021-03-04 16:40:54 +01:00
Tom Thorogood 40ce7c7df7
Bump go versions in .github/workflows/go.yml (#1237)
* Bump go versions in .github/workflows/go.yml

These are very out of date and it's causing persistent failures in the
fuzz CI step.

* Remove GOPATH=$GOROOT assignment

go1.16 shows a warning:
  "warning: GOPATH set to GOROOT (/opt/hostedtoolcache/go/1.16.0/x64) has no effect"
2021-03-04 07:32:55 +01:00
Tom Thorogood b694ab3d93
Update go.mod dependencies (#1236)
Automatically submitted.
2021-03-04 06:25:23 +00:00
Miek Gieben 4fdbc51bbd
Run a go fmt -w -s (#1235)
Noticed a non-gofmted `;` earlier, run gofmt -w -s on all files.

(mechanical change)

Signed-off-by: Miek Gieben <miek@miek.nl>
2021-03-01 15:30:32 +01:00
Miek Gieben db96610e5e
loc: use float64 to get enough precision (#1234)
Fixes: #1232

Signed-off-by: Miek Gieben <miek@miek.nl>
2021-03-01 15:19:31 +01:00
madestro 375601dc88
Implementation of zone digest (ZONEMD) (#1208)
* adding ZONEMD

* adding ZONEMD

* deleting extra cod

* updating constants

* updating mod

* updating release

* Moving ZONEMD Implementation to project structure

* re adding indirect tools import

* case-insensitive digest

* fixing if zone has rfc 3597 RRs

* remove .idea folder

* restore go.mod imports

* gofmt files

* pseudo rollback

* after go generate...

* parsing zonemd in rfc3597

* removing the check for a STRING as HAsh Algorithm in ZONEMD, RFC says only numbers go there

* adding ZONEMD constants

* Reverting changes in generate.go

un-gofmt ing generate.go file

* Reverting changes in generate.go

un-gofmt ing generate.go file

* remove ZoneMD reserved types

* remove zonemd RFC3597 branch in ZONEMD parser

* revert rfc3597 related modifications

* revert rfc3597 related modifications

* removing unintentional changes from go.sum and types.go

* add line break to go.sum

* removing spaces from types.go

* Use ZONEMD official RFC link as reference

* Add ZONEMD parsing test

* Update parse_test.go

Co-authored-by: Miek Gieben <miek@miek.nl>

Co-authored-by: Eduardo <eriveros@dcc.uchile.cl>
Co-authored-by: Eduardo <e.sdfbsadjhgskndwegit@xor.cl>
Co-authored-by: Eduardo <e.git@xor.cl>
Co-authored-by: Miek Gieben <miek@miek.nl>
2021-02-26 16:35:05 +01:00
Josh Soref 883641f4a9
Spelling (#1222)
* spelling: artifacts

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: encoding

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exponent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ignoring

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: implemented

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: implements

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: next

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: numeric

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: previous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: positions

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: presentation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: resetting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: stringifying

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: subsequent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: validated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Miek Gieben <miek@miek.nl>
2021-02-25 17:08:05 +01:00
Shubhendra Singh Chauhan 2f14d104f3
improve code quality (#1228)
* Combine multiple `append`s into a single call

* Fix Yoda conditions

* Fix check for empty string

* revert "combine multiple `append`s"
2021-02-25 17:01:55 +01:00
Miek Gieben 9884b9f446 Release 1.1.40 2021-02-25 11:00:46 +01:00
R+ 2543d8bb2d
Close the UDPConn before returning if `setUDPSocketOptions` went wrong (#1227)
Detail: https://github.com/miekg/dns/issues/1226
2021-02-25 09:24:39 +01:00
Nikolay Nikolaev c08efdcc07
readme: adding Kuma.io (#1225)
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
2021-02-23 10:54:40 +01:00
Miek Gieben 4ec3e54a9e Release 1.1.39 2021-02-23 10:30:20 +01:00
Miek Gieben 4495f1939f
readme: add CAA and ZOMEMD RFCs (#1224)
Try to keep this list semi up to date.

Signed-off-by: Miek Gieben <miek@miek.nl>
2021-02-23 10:10:31 +01:00
Andrey Meshkov 67bd57debd
Send DNS query in one packet when using TCP/TLS (#1219)
* Send DNS query in one packet when using TCP/TLS

* fix review comments

* Removed net.Buffers

* Added unit-tests for writing messages over TCP in one go
2021-02-13 19:49:02 +01:00
unknowndev233 7d5e1ea350
README.md: Users list update: add v2fly/v2ray-core (#1220) 2021-02-10 07:42:07 +01:00
chantra ee8fef6743
Update Truncate doc with compress behaviour (#1217)
* Update Truncate doc with compress behaviour

This is a documentation update to highlight the behaviour of Truncate, which will reset dns.Compress to false when the message fits in the requested size without truncation, and make it the caller responsibility to set it back to true if they wish to compress, regardless of fitting, uncompressed, in the requested message size in the first place or not.
Fixes #1216

* address comments

* d/Note that/
* s/reset/set/
* s/caller/caller's/
* removed backticks

* regardless of size
2021-02-10 07:41:26 +01:00
Miek Gieben 35023fab5c Release 1.1.38 2021-02-01 09:20:37 +01:00
Tom Thorogood 2fd5af9f92
Validate Rdlength and off in UnpackRRWithHeader (#1215) 2021-02-01 09:15:50 +01:00
Tom Thorogood e6df8867af
Fix Rdlength related parsing bug in RFC3597 records (#1214)
* Set Rdlength in fromRFC3597

This was a bug found by oss-fuzz. My bad (#1211).

* Limit maximum length of Rdata in (*RFC3597).parse

RDATA must be a 16-bit unsigned integer.

* Validate Rdlength and off in UnpackRRWithHeader

* Revert "Validate Rdlength and off in UnpackRRWithHeader"

This reverts commit 2f6a8811b944b100af7605e53a6fb164944a6d65.

* Use hex.DecodedLen in (*RFC3597).fromRFC3597

While this isn't done elsewhere, it is clearer and more obvious.
2021-02-01 09:10:38 +01:00
Miek Gieben ba2d042a57 Release 1.1.37 2021-01-30 14:07:04 +01:00
Miek Gieben a1362108be Merge branch 'master' of github.com:miekg/dns 2021-01-30 14:06:35 +01:00
Miek Gieben a25c26b5ed Release 1.1.36 2021-01-30 14:06:14 +01:00
Tom Thorogood 13238cb6ad
Support parsing known RR types in RFC 3597 format (#1211)
* Support parsing known RR types in RFC 3597 format

This is the format used for "Unknown DNS Resource Records", but it's
also useful to support parsing known RR types in this way.

RFC 3597 says:

   An implementation MAY also choose to represent some RRs of known type
   using the above generic representations for the type, class and/or
   RDATA, which carries the benefit of making the resulting master file
   portable to servers where these types are unknown.  Using the generic
   representation for the RDATA of an RR of known type can also be
   useful in the case of an RR type where the text format varies
   depending on a version, protocol, or similar field (or several)
   embedded in the RDATA when such a field has a value for which no text
   format is known, e.g., a LOC RR [RFC1876] with a VERSION other than
   0.

   Even though an RR of known type represented in the \# format is
   effectively treated as an unknown type for the purpose of parsing the
   RDATA text representation, all further processing by the server MUST
   treat it as a known type and take into account any applicable type-
   specific rules regarding compression, canonicalization, etc.

* Correct mistakes in TestZoneParserAddressAAAA

This was spotted when writing TestParseKnownRRAsRFC3597.

* Eliminate canParseAsRR

This has the advantage that concrete types will now be returned for
parsed ANY, NULL, OPT and TSIG records.

* Expand TestDynamicUpdateParsing for RFC 3597

This ensures we're properly handling empty RDATA for RFC 3597 parsed
records.
2021-01-30 14:05:25 +01:00
Tom Thorogood f9dc403cff
Fix potentially truncated int casts in $GENERATE code (#1212)
These were flagged by GitHub CodeQL code scanning as potential
vulnerabilities or issues. Fixing them is easy and they are incorrect.

Adding tests is less easy because int is 64-bits on most systems,
including those we test on, so we can't consistently provoke a failure
here.
2021-01-30 10:07:06 +01:00
Matt Dainty 731b191cab
Add a link to https://github.com/bodgit/tsig (#1206) 2021-01-09 09:37:20 +01:00
Matt Dainty 59aea23afe
Add GSS-TSIG support (#1201)
Automatically submitted.
2021-01-07 14:28:20 +00:00
Janik at Cloudflare 23c4faca9d
Fix comment about SVCB values in AliasMode (#1202)
Automatically submitted.
2020-12-18 19:16:09 +00:00
Till! 428cef3187
Add a link for dnsbl_exporter (#1194)
Adding a shameless plug to my Prometheus exporter. ;) Thanks for sharing your code on here.
2020-11-06 18:31:18 +01:00
Miek Gieben 91eca25c30
Remove travis (#1193)
This also removed the codecov that was still done. We could potentially
re-add as an action, but I don't really miss it. Add testing for 1.14
and 1.15 (it's very fast now).

Fuzzing needs to stay on 1.14 due to brokeness of some kind.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-11-06 18:30:22 +01:00
Catena cyber 9732cfa6b8
Runs CIFuzz only when go files are modified (#1192)
and run it for 5 minutes instead of 10
2020-11-05 15:35:21 +01:00
Miek Gieben 1ba9487b18
make the client.Exchange doc work (#1190)
Remove the newline so the comment is picked up as documentation.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-26 14:10:31 +01:00
Miek Gieben 3b41a31342 Release 1.1.35 2020-10-25 09:22:05 +01:00
Tom Thorogood fa528cceb7
Fix PacketConnReader typo in DecorateReader docs (#1189) 2020-10-25 02:26:19 +10:30
Tom Thorogood 0e1c4e69dd
Support generic net.PacketConn's for the Server (#1174)
* Support generic net.PacketConn's for the Server

This commit adds support for listening on generic net.PacketConn's for
UDP DNS requests, previously *net.UDPConn was the only supported type.

In the event of a future v2 of this module, this should be streamlined.

* Eliminate wrapper functions around RunLocalXServerWithFinChan

* Eliminate RunLocalTCPServerWithTsig function

* Replace RunLocalTLSServer with a wrapper around RunLocalTCPServer

This reduces code duplication.

* Add net.PacketConn server tests

This provides coverage over nearly all of the newly added code (with
the unfortunate exception of (*response).RemoteAddr).

* Fix broken client_test.go tests

a433fbede4 was merged into master between this PR being opened and
being merged. This broke the CI tests in rather strange ways as the
code was being merged into master in a way that wasn't at all clear.
This commit fixes the two broken lines.
2020-10-25 02:23:01 +10:30
Tom Thorogood a3ad44419a
Fix XFR tests (#1188)
* Fix XFR tests

axfrTestingSuite returned the test function that was never actually
executed. These were broken from the beginning awkwardly, though the
test cases pass fine once fixed.

* Switch axfrTestingSuite argument order

*testing.T is customarily the first argument.
2020-10-24 13:58:44 +02:00
Tom Thorogood 93945c2844
Remove HMAC-MD5 support from TSIG (#1187) 2020-10-24 13:57:51 +02:00
Tom Thorogood db53c847ca
Remove RSAMD5 support from (*RRSIG).Verify (#1185)
AFAIK, the only way to get an RSAMD5 DNSKEY was to manually construct
one. This is ancient, just get rid of it.

The only remaining usage of md5 is in tsig.go. Hopefully that might be
removable as well.
2020-10-24 13:55:55 +02:00
Tom Thorogood be51022368
Remove the remnants of DSA support (#1184)
crypto/dsa is formally deprecated as of go1.16 and DSA support was
largely removed from this library in 9c315c51c3, but some remnants
remained.
2020-10-24 13:55:21 +02:00
Peter Wu 6d41f43022
svcb: documentation fixes (#1182)
`&dns.HTTPS{Hdr: ...}` fails due to `cannot use promoted field SVCB.Hdr
in struct literal of type dns.HTTPS`. Fix this, less readable
alternatives include using `dns.SVCB` directly, or `&dns.HTTPS{SVCB:
dns.SVCB{Hdr: ...}}`.

Fix the draft reference, draft-02 has not been published yet. Fix ECH,
its type has changed from base64 to a byte array.
2020-10-21 17:42:39 +02:00
Laurent Demailly 04c41addaf
add link to https://github.com/fortio/dnsping (#1181)
Thanks for the great library!

I couldn't quite figure out the sort order so I put my link at the end...
2020-10-21 08:14:38 +02:00
Miek Gieben 276b51d84b Release 1.1.34 2020-10-18 07:56:38 +02:00
Andrew Ayer a433fbede4
Ignore responses with unexpected IDs (#1155)
* Ignore replies with unexpected IDs

This fixes the following problem:

At time 0, we send a query with ID X from port P.

At time T, we time out the query due to lack of response, and then send
a different query with ID Y.  By coincidence, the new query is sent from
the same port number P (since port numbers are only 16 bits, this can happen
with non-negligible probability when making queries at a high rate).

At time T+epsilon, we receive a response to the original query.
Since the ID in this response is X, not Y, we would previously return
ErrId, preventing the second query from succeeding.

With this commit, we simply ignore the response with the mismatched ID
and return once we receive the response with the correct ID.

* Update test for bad ID

The new test sends two replies: the first one has a bad ID, which should
be ignored, and the second one has the correct ID.

* Add test to ensure query times out when server returns bad ID

* Avoid use of error string matching in test case

* Check for mismatched query IDs when using TCP

* Reduce timeout in TestClientSyncBadID
2020-10-18 07:55:24 +02:00
Miek Gieben 61a22d0ee6
svcb: doc updates (#1178)
The SVBC record didn't have a class, so add that and use struct literal
to put it all on 1 one. Use `s` for SVCB records, and `h` for HTTPS to
be more consistent.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-17 10:00:13 +02:00
Miek Gieben 95dddd3867
Make the 900 number lower in this test (#1176)
Original PR doesn't make clear why this is 900-now assuming we want to
cross the 14 bit length boundary.

Up to 900 creates a super large (>2^16) message. Not sure why that needs
testing.

Also remove the packs at lower sizes.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-16 11:55:29 +02:00
Miek Gieben 3b0ffe413f
tests: reduce timeouts and iterations (#1175)
This reduces the time it takes to run the test. Shorter timeouts on
clients to avoid awaiting for the detault timeouts.

It's also reduces the iterations in some test functions, this doesn't
seem to impact the tests indicating those numbers where random to begin
with.

Use shorter crypto keys, as we don't need to strength in tests.

Stop using Google Public DNS and other remotes in tests as well: it's
faster, keeps things local and avoids spilling info to Google.

This brings the test duration down from ~8s to ~2s on my machine, a 4x
reduction.

~~~
PASS
ok  	github.com/miekg/dns	2.046s

Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
PASS
ok  	github.com/miekg/dns	7.915s
~~~

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-16 09:10:36 +02:00
Miek Gieben 10e0aeedbe Release 1.1.33 2020-10-14 08:44:55 +02:00
Miek Gieben ef286f8f39
Update doc for Truncate (#1173)
Follow up after #1171, update the docs about TC and use the MinMsgSize
constant for 512 in the code.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-14 08:42:57 +02:00
Chris O'Haver 5579226123
dont unset TC on a message that is already truncated (#1171)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-10-14 07:18:59 +02:00
Tom Thorogood 08cf611c2b
Bump CI tested go versions (#1172)
This bumps Travis CI to the last two supported golang releases, as
documented in the readme: go1.14 and go1.15.

It also bumps the GitHub Code Action CI to go1.14 as it doesn't yet
supported go1.15 (see actions/setup-go#74).
2020-10-14 07:16:31 +02:00