4157 Commits

Author SHA1 Message Date
Dave Pifke
50fbccd204
Allow use of fs.FS for $INCLUDE and wrap errors (#1526)
* Allow use of fs.FS for $INCLUDE and wrap errors

This adds ZoneParser.SetIncludeAllowedFS, to specify an fs.FS when
enabling support for $INCLUDE, for reading included files from
somewhere other than the local filesystem.

I've also modified ParseError to support wrapping another error, such
as errors encountered while opening the $INCLUDE target.  This allows
for much more robust handling, using errors.Is() instead of testing
for particular strings (which may not be identical between fs.FS
implementations).

ParseError was being constructed in a lot of places using positional
instead of named members.  Updating ParseError initialization after
the new member field was added makes this change seem a lot larger
than it actually is.

The changes here should be completely backwards compatible.  The
ParseError change should be invisible to anyone not trying to unwrap
it, and ZoneParser will continue to use os.Open if the existing
SetIncludeAllowed method is called instead of the new
SetIncludeAllowedFS method.

* Don't duplicate SetIncludeAllowed; clarify edge cases

Rather than duplicate functionality between SetIncludeAllowed and
SetIncludeAllowedFS, have a method SetIncludeFS, which only sets the
fs.FS.

I've improved the documentation to point out some considerations for
users hoping to use fs.FS as a security boundary.

Per the fs.ValidPath documentation, fs.FS implementations must use
path (not filepath) semantics, with slash as a separator (even on
Windows).  Some, like os.DirFS, also require all paths to be relative.
I've clarified this in the documentation, made the includePath
manipulation more robust to edge cases, and added some additional
tests for relative and absolute paths.
2024-01-15 15:40:43 +01:00
WintBit
f206faa01f
docs: added ninedos to readme (#1522) 2024-01-09 17:52:18 +01:00
Miek Gieben
9bbcd245f8 Try explaining duplicate RCODEs
Add extra link to the docs for the duplicate Rcode entries

See #1523

Signed-off-by: Miek Gieben <miek@miek.nl>
2023-12-13 10:04:56 +01:00
Miek Gieben
836bea2f8d Release 1.1.57 v1.1.57 2023-11-15 09:10:43 +00:00
Jim
257e89e9ba
feat: add support for ReuseAddr (#1510)
* feat: add support for ReuseAddr

* Update listen_reuseport.go

* Update listen_reuseport.go

* fixup! feat: add support for ReuseAddr

---------

Co-authored-by: Miek Gieben <miek@miek.nl>
2023-11-15 10:09:44 +01:00
Tim Scheuermann
3d593a6b1d
Swap closing order in inAxfr and inIxfr (#1511)
* Fix closing order

* Comment to make clear that the close order is deliberate

---------

Co-authored-by: Tim Scheuermann <tscheuermann@anexia-it.com>
2023-11-13 16:10:26 +01:00
Tom Thorogood
5d3f81bc34
Remove slurpRemainder TODO from (*ZoneParser).Next (#1508)
No one has complained about this in the four years it's been here. I
think we can safely accept this new behaviour.
2023-11-07 15:07:11 +01:00
Tom Thorogood
a16092f374
Use strings.Builder in endingToString (#1506)
This will cause one less allocation as String allocates on a
bytes.Buffer but not on a strings.Builder.
2023-11-06 07:27:11 +01:00
Tom Thorogood
3996b17d19
Avoid using a goto loop in unpackDataOpt (#1505)
We definitely shouldn't be using goto for a simple loop.

This is technically a behaviour change when off == len(msg), but we're
always called with off < len(msg) so this is unobservable.
2023-11-06 07:26:49 +01:00
Tom Thorogood
1c418a37a5
Use cloneSlice in unpackDataA and unpackDataAAAA (#1504)
I missed this pattern in #1432. These seem to be the only two
occurrences.

Updates #1432
2023-11-06 07:26:22 +01:00
Tom Thorogood
6836ba80ba
Eliminate tmp buffer from packOctetString (#1503)
This is exactly the same change as #1429 but for packOctetString.

I have no idea how I missed this given it's the very next function.

Updates #1429
2023-11-06 07:25:03 +01:00
Tom Thorogood
9657fe66ad
Cleanup IsRRSet (#1502)
This is a very minor change that simply neatens up this function.
2023-11-06 07:24:27 +01:00
Tom Thorogood
02e9e72099
Avoid using strings.Split (#1501)
* Avoid using strings.Split

strings.Split has to allocate for the return slice. This allocation
was wasteful in ever case it was used in this library.

Instead we use the new strings.Cut and other string manipulation where
appropriate. This tends to lead to cleaner and more readable code in
addition to the benefits this has on the garbage collector.

* Further simplify structTag in the msg_generate.go

This doesn't need to call strings.TrimPrefix twice.
2023-11-06 07:23:41 +01:00
dependabot[bot]
b18c05cc13
Bump golang.org/x/net from 0.15.0 to 0.17.0 (#1498)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.15.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-02 13:59:00 +01:00
dependabot[bot]
cc1571992e
Bump golang.org/x/sync from 0.3.0 to 0.4.0 (#1495)
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.3.0 to 0.4.0.
- [Commits](https://github.com/golang/sync/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-02 13:57:54 +01:00
Aliaksandr Skurydzin
24995b972a
Make SetReply a Reflexive Operation (#1484) 2023-11-02 13:43:57 +01:00
Tom Thorogood
8a3ef11a3c
Simplify CanonicalName (#1494)
This function was previously changed from using strings.ToLower to a
custom loop to ensure it only lowercases ASCII characters. This was
more complicated than it needed to be and introduced more allocations
than is necessary.

Instead of that approach we call strings.Map with a simple ASCII
lowercase mapping function. Sadly we still use the nice ASCII-only fast
path that strings.ToLower had, but it's unlikely to be worth all the
extra code.
2023-11-02 13:38:28 +01:00
Daniel Tang
52f175a7b4
Remove comment about checking zero bit. (#1491)
The check was removed in https://github.com/miekg/dns/issues/975.
2023-11-02 13:34:35 +01:00
Eugene
0d504a67cf
tweak SetDo doc (#1488) 2023-10-10 18:35:54 +02:00
Ben Kochie
4d3b87f4ff
Enable dependabot (#1483)
Update Go module dependencies monthly.

Signed-off-by: SuperQ <superq@gmail.com>
2023-09-19 08:34:45 +02:00
Miek Gieben
0f1051c5dc
up go version for testing (#1482)
Signed-off-by: Miek Gieben <miek@miek.nl>
2023-09-15 13:41:48 +02:00
Miek Gieben
dfe986726a Release 1.1.56 v1.1.56 2023-09-12 11:58:33 +02:00
retornam
a9ed73ac22
CanonicalName should casefold non-US-ASCII chars (#1470)
According to Section 6.2 [1] of RFC 4034,all uppercase US-ASCII letters in the
owner name of the RR are replaced by the corresponding lowercase US-ASCII
letters.

This updates CanonicalName to conform to the RFC.

[1] https://www.rfc-editor.org/rfc/rfc4034#section-6.2

Fixes miekg/dns#1434
2023-09-12 11:57:40 +02:00
Miek Gieben
9ec1b44a51
Bump deps and fix pr template (#1480)
Signed-off-by: Miek Gieben <miek@miek.nl>
2023-09-12 11:56:52 +02:00
Yasar Alev
1bc691571a
readme: add sdns to users (#1471) 2023-09-12 11:46:17 +02:00
Christian Elmerot
d00c6728a4
Use correct string format IPv4 encoded as IPv6 for for AAAA records (#1457)
In order to parse an IPv4 address encoded as IPv6 it needs to have the
prefix of "::ffff:" i.e. ::ffff:192.0.2.1

Co-authored-by: Christian Elmerot <elmerot@cloudflare.com>
2023-09-12 11:45:58 +02:00
dnschecktool
a36acb4f23
Use proper section names when producing dig-like output for UPDATEs (#1479) 2023-09-12 11:44:32 +02:00
Miek Gieben
48f38ebef9 Release 1.1.55 v1.1.55 2023-06-19 16:06:46 +02:00
Andrew Dunham
8b8cf1431c
Make ExchangeWithConnContext public (#1459)
If we want to use a custom mechanism of obtaining a Conn that doesn't
match the net.Dialer type, but retain the timeout behaviour from
ExchangeContext, there was previously no way to accomplish this.

This PR makes the underlying ExchangeWithConnContext function public,
which allows this behaviour.

Now that #1454 is merged, there is no longer any interaction between the
context provided and the singleflight behaviour, so I removed the
comment from ExchangeWithConn.

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
2023-06-19 16:05:20 +02:00
Patryk Małek
7fadba7515
tests: skip unix socket tests for non *nix OSes (#1443)
* tests: fix unix socket tests on darwin

* tests: add test temp dir implementation for darwin and non darwin
2023-06-16 17:57:59 +02:00
Miek Gieben
d11e3f0bbf more stuff we care about
Signed-off-by: Miek Gieben <miek@miek.nl>
2023-06-16 17:51:59 +02:00
Miek Gieben
3dfd7b6096 add PR template
Signed-off-by: Miek Gieben <miek@miek.nl>
2023-06-16 17:47:07 +02:00
Miek Gieben
730c265d18 Release 1.1.54 v1.1.54 2023-04-28 20:26:59 +02:00
Miek Gieben
d4a9e37166
Allow RRSIG algorithm mnemonics (#1456)
* Allow RRSIG algorithm mnemonics

Java outputs these *and* the RFC says we should parse them, so parse
them. We'll never output them though. Throwback to the "be lenient to
what you accept, but strict with what you output". Anyhow the diff is
tiny and it helps interop.

Fixes: #1447

Signed-off-by: Miek Gieben <miek@miek.nl>

* Check parsed algorithm

Signed-off-by: Miek Gieben <miek@miek.nl>

---------

Signed-off-by: Miek Gieben <miek@miek.nl>
2023-04-28 20:26:19 +02:00
Paul Dee
f07f1e694f
Buffer bump (#1446)
* In func (zl *zlexer) Next() (lex, bool)
make max token size buffers str and com something we can grow.

Why? Because.

Reasons: When experimenting with OPENPGPKEY records, which themselves
are basically a key, if my zone file already has an RSA 4096 public key
record, this lib goes boom:

dns: bad OPENPGPKEY PublicKey: "token length insufficient for parsing" at line: .....

The key is good.

Testing against bare ed25519 keys whose base64 length is ~320 characters
and there are no problems

Testing against a bare RSA4096 key whose base64 length is ~3100 characters
and: problems.

Bare is the key word here, since for DNS, one ideally publishes as bare
a key as possible, minus signatures, minus photos, minus extra
metadata beyond the essential that will push a record length up.

A typical public key with two RSA 4K subkeys and several signatures may
rise to > ~21000 bytes.

* Test case for OPENPGPKEY (valid, test pgp public keys)

Reverse TLSA test record fail logic

TestNewRRCommentLengthCrasherString: ...
2023-04-27 13:58:07 +02:00
Tom Thorogood
4bdf302574
Improve IsFQDN performance (#1453)
* Improve IsFQDN performance

While this code may be slightly less clear, it's significantly faster
and this function seems to be a hot path for certain workloads.

name                 old time/op    new time/op    delta
IsFQDN/no_dot-12       5.86ns ± 2%    1.48ns ± 3%  -74.71%  (p=0.000 n=10+10)
IsFQDN/unescaped-12    8.73ns ± 2%    1.57ns ± 1%  -81.98%  (p=0.000 n=9+8)
IsFQDN/escaped-12      27.4ns ± 2%    23.8ns ± 2%  -13.19%  (p=0.000 n=10+10)
FQDN/is_fqdn-12        8.36ns ± 1%    1.80ns ± 2%  -78.50%  (p=0.000 n=9+10)
FQDN/not_fqdn-12       36.8ns ±15%    33.4ns ±12%   -9.25%  (p=0.035 n=10+10)

* Fixup IsFQDN comment
2023-04-27 13:36:03 +02:00
Tom Thorogood
c454332d7b
Remove SingleInflight support from Client (#1454)
* Remove SingleInflight support from Client

Callers should instead implement their own in flight query caching.

* Add doc link to Github issue
2023-04-27 09:38:15 +02:00
Miek Gieben
a6f978594b Release 1.1.53 v1.1.53 2023-03-28 19:37:11 +02:00
Paul Dee
5cac7fb514
Fix some lint checks by (go) staticcheck ./... (#1442)
Some warn about deprecation.

PR #1445 already refactored out deprecated ioutil package
2023-03-28 19:35:46 +02:00
Patryk Małek
6ad6301ae2
chore: don't use deprecated ioutil package (#1445) 2023-03-19 14:01:37 +01:00
dnschecktool
8fcc59a3bb
Readme: Add addr.tools. Remove dow-proxy experiment. (#1439) 2023-03-18 13:15:46 +01:00
Paul Dee
800bb6fc53
Updates to LOC type RFC1876 (#1440)
https://www.rfc-editor.org/rfc/rfc1876
2023-03-18 12:57:18 +01:00
Tom Thorogood
4c50fd8ad8
Use generics for ddd escape parsing (#1435)
* Use generics for dddToByte and dddStringToByte

* Introduce generic isDDD helper

Almost all uses of isDigit look exactly the same, turn them into a
matching helper.
2023-03-12 13:11:22 +01:00
Miek Gieben
5cd605ded2 Release 1.1.52 v1.1.52 2023-03-12 11:15:23 +01:00
Tom Thorogood
e88948ec72
Correct TODO in udp_windows.go (#1433)
These TODOs were not correct as x/net/ipv4 and x/net/ipv6 still don't
have Windows support.
2023-03-12 11:14:37 +01:00
Tom Thorogood
d83d31beda
Introduce a generic slice clone function (#1432)
* Introduce a generic slice clone function

This is nil-preserving unlike the existing code.

We also add some missing []byte slice copies.

* Move cloneSlice call into &RR{...} in types_generate.go

* Wrap longer copy lines in types_generate.go
2023-03-12 11:14:24 +01:00
Tom Thorogood
45916f5f2b
Remove pre-go1.11 support from reuseport code (#1431) 2023-03-12 11:13:38 +01:00
Tom Thorogood
fc45796497
Use tls.Dialer in Client.DialContext (#1430)
This has been a long standing TODO we can cross off as tls.Dialer is
well supported now.
2023-03-12 11:13:18 +01:00
Tom Thorogood
b69c3a2007
Eliminate tmp buffer from packTxtString (#1429)
This allocation and the copy of s are both pointless.
2023-03-12 11:12:57 +01:00
Mikk Margus Möll
85afa114a5
Tweaks (#1425)
* fix typo

* more IPSECKEY/AMTRELAY tests

* avoid bytes.Equal for IP comparison

* *_generate: convert fprintf with no argument to fprint, add newlines to ztypes so gofumpt doesn't try to fix it
2023-03-02 18:56:59 +01:00