Commit Graph

1357 Commits

Author SHA1 Message Date
Ville Vesilehto
2f981ff797 fix(forward): use netip package for parsing (#7472)
Replace manual host:port parsing using net.SplitHostPort +
strconv.ParseUint with the standard library net/netip function
ParseAddrPort. This eliminates integer conversion warnings and
improves type safety.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-08-25 13:06:44 -07:00
Ville Vesilehto
f4ab4d9ed5 test(plugin): improve test coverage for pprof (#7473)
Add tests for Startup/Shutdown methods and HTTP endpoints.
Enhance setup tests with edge cases. Increases test coverage
from 58% to 100%.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-08-25 13:06:19 -07:00
wencyu
2c99f62acb plugin/file: fix label offset problem in ClosestEncloser (#7465)
Signed-off-by: yuwenchao <ywc689@163.com>
2025-08-20 16:02:41 -07:00
Ville Vesilehto
2b273d48ab feat(trace): migrate dd-trace-go v1 to v2 (#7466)
- Upgrade dd-trace-go dependency to v2.2.2
- Separate Zipkin and DataDog code paths for better maintainability
- Add proper tracer shutdown through OnShutdown()
- Replace deprecated opentracer.New() with direct tracer.Start()
- Added tests

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-08-20 16:00:21 -07:00
Qasim Sarfraz
712a5050bd plugin/header: Remove deprecated syntax (#7436)
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
2025-08-08 15:38:41 -07:00
Olli Janatuinen
52639bc66c plugin/loadbalance: support prefer option (#7433)
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2025-08-05 11:34:38 -07:00
Guillaume Jacquet
1025a199e9 Properly create hostname from IPv6 (#7431)
Generate valid hostname from IPv6 when the address ends with `::`.

Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
2025-08-04 16:53:40 -07:00
harshith-2411-2002
6ba43927b6 fix: handle cached connection closure in forward plugin (#7427) 2025-07-28 12:06:26 -07:00
houpo-bob
2c2b075eaa refactor: use slices.Equal to simplify code (#7426) 2025-07-28 12:04:53 -07:00
Syed Azeez
1981f22170 plugin/test: fix TXT record comparison for multi-chunk vs multiple records (#7413) 2025-07-15 05:11:25 -07:00
dependabot[bot]
d5932041f7 build(deps): bump github.com/miekg/dns from 1.1.66 to 1.1.67 (#7406)
* build(deps): bump github.com/miekg/dns from 1.1.66 to 1.1.67

Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.66 to 1.1.67.
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.66...v1.1.67)

---
updated-dependencies:
- dependency-name: github.com/miekg/dns
  dependency-version: 1.1.67
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix build failure

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yong Tang <yong.tang.github@outlook.com>
2025-07-14 22:48:29 -07:00
Syed Azeez
d8906ce610 plugin/file: preserve case in SRV record names and targets per RFC 6763 (#7402) 2025-07-14 18:56:59 -07:00
Cameron Steel
0aee758833 fix(auto/file): return REFUSED when no next plugin is available (#7381) 2025-07-04 02:39:19 -07:00
Stephen Kitt
1449cb660e Port to AWS Go SDK v2 (#6588) 2025-07-03 02:19:21 -07:00
Sebastian Mayr
ae5e03a94d fix(cache): data race when refreshing cached messages (#7398) 2025-07-02 19:39:46 -07:00
Sebastian Mayr
06da7dcd98 fix(cache): data race when updating the TTL of cached messages (#7397) 2025-07-02 19:20:47 -07:00
Dennis Simmons
b2a2a5f648 plugin/rewrite: Add EDNS0 Unset Action (#7380)
* plugin/rewrite: EDNS0 unset action

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* plugin/rewrite: EDNS0 unset tests

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* plugin/rewrite: EDNS0 unset documentation

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* gofmt whitespace fixes

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* plugin/rewrite: improve edns0 test coverage

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

---------

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>
2025-06-19 17:49:37 -04:00
Dave Brown
ab74d3acf2 add args: startup_timeout for kubernetes plugin (#7068)
Signed-off-by: mangoyhuang <mangoyhuang@tencent.com>
Co-authored-by: mangoyhuang <mangoyhuang@tencent.com>
2025-06-11 11:22:07 -07:00
Oleg Guba
27273a3a26 [plugin/cache] create a copy of a response to ensure original data is never modified (#7357)
Signed-off-by: Oleg Guba <oleg.guba@gmail.com>
2025-06-06 05:14:41 -07:00
blakebarnett
6cba588951 Add support for fallthrough to the grpc plugin (#7359)
Fixes: https://github.com/coredns/coredns/issues/7358

Signed-off-by: Blake Barnett <bbarnett@groq.com>
2025-06-06 04:58:17 -07:00
Ben Kochie
83afff1fec view: Add IPv6 example match (#7355)
Add an IPv6 source address matching example to the view plugin.

Fixes: https://github.com/coredns/coredns/issues/7354

Signed-off-by: SuperQ <superq@gmail.com>
2025-06-05 18:20:24 +02:00
Matthieu MOREL
186e4a1dbb chore: enable early-return and superfluous-else from revive (#7129)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-05 10:10:58 +03:00
Ville Vesilehto
ddb74cdcf4 test(plugin): improve tests for auto (#7348) 2025-06-04 14:37:52 -07:00
Ville Vesilehto
11774d9e98 fix(proxy): flaky dial tests (#7349) 2025-06-04 14:36:59 -07:00
Ville Vesilehto
9f9aed31cf test: add t.Helper() calls to test helper functions (#7351) 2025-06-04 14:36:04 -07:00
Ville Vesilehto
b4abdcacf0 fix(kubernetes): multicluster DNS race condition (#7350) 2025-06-04 06:31:41 +03:00
Ville Vesilehto
8cac83dfb5 lint: enable wastedassign linter (#7340) 2025-06-01 16:30:41 -07:00
Ville Vesilehto
bb33ab5301 test(plugin): add tests for any (#7341) 2025-06-01 16:30:01 -07:00
Ville Vesilehto
53e9681a39 lint: enable protogetter linter (#7336)
Enable protogetter in golangci config and update all protobuf field
access to use getter methods instead of direct field access.
Getter methods provide safer nil pointer handling and return
appropriate default values, following protobuf best practices.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-30 15:29:32 -07:00
Ville Vesilehto
a61d8b3143 lint: enable nolintlint linter (#7332) 2025-05-29 07:19:04 +03:00
Ville Vesilehto
384fa3285e fix: missing intrange lint fix (#7333)
Missed in #7323

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-29 04:41:27 +03:00
Ville Vesilehto
60227bd8d2 perf(kubernetes): optimize AutoPath slice allocation (#7323)
Pre-allocate slice capacity in AutoPath to eliminate unnecessary
memory reallocations. This avoids slice growth when appending
search domains and sentinel value.

Benchmark shows significant performance improvement:
- Before: 538.6 ns/op, 560 B/op, 13 allocs/op
- After:  436.8 ns/op, 336 B/op, 11 allocs/op
- Result: 19% faster, 40% less memory, 15% fewer allocations

The optimization benefits Kubernetes clusters using autopath for
server-side search path completion.

Adds benchmark test to measure AutoPath performance.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:58:01 -07:00
Ville Vesilehto
19a6ae4983 lint: enable intrange linter (#7331)
Enable intrange linter to enforce modern Go range syntax over
traditional for loops, by converting:

for i := 0; i < n; i++

to:

for i := range n

Adding type conversions where needed for compatibility
with existing uint64 parameters.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:50:55 -07:00
vdbe
b3acbe5046 feat(plugin/file): fallthrough (#7327)
* feat(plugin/file): fallthrough

implement and test fallthrough for the file plugin

Signed-off-by: vdbe <vdbewout@gmail.com>

* docs(plugin/file): fallthrough

Signed-off-by: vdbe <vdbewout@gmail.com>

* docs(plugin/file): regenerate man page

`make -f Makefile.doc man/coredns-file.7`

Signed-off-by: vdbe <vdbewout@gmail.com>

---------

Signed-off-by: vdbe <vdbewout@gmail.com>
2025-05-28 17:34:16 -07:00
Ville Vesilehto
bebb7bce43 lint: enable canonicalheader linter (#7330)
Enable canonicalheader linter to enforce proper HTTP header casing.
This ensures headers use Go's canonical format (e.g., "Content-Type"
instead of "content-type") for consistency.

Fixes header casing in DoH implementation.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:33:07 -07:00
Ville Vesilehto
0a48523083 fix(proxy): avoid Dial hang after Transport stopped (#7321)
Ensure Dial exits early or returns error when Transport has been
stopped, instead of blocking on the dial or ret channels. This removes
a potential goroutine leak where callers could pile up waiting
forever under heavy load.

Add select guards before send and receive, and propagate clear error
values so callers can handle shutdown gracefully.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 06:58:48 -07:00
Ville Vesilehto
8cd0c63595 test(plugin): add tests for pkg/rand (#7320)
Add test suite covering thread-safe random number generator with
tests for:

- Constructor with various seed values (positive, zero, negative)
- Deterministic behavior verification with same seeds
- Permutation generation and validation
- Concurrent access safety with multiple goroutines
- Mixed operations under concurrent load

Also clarify package documentation to explicitly state this is
for load balancing and server selection, not cryptographic use.
The math/rand usage is intentional for performance in non-security
contexts like upstream server selection and DNS record shuffling.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-27 17:49:13 -07:00
Ville Vesilehto
7bd43af427 fix: loop variable capture and linter (#7328)
Enable copyloopvar linter and remove redundant variable
shadowing in Kubernetes plugin metadata handling. This pattern is
no longer needed in Go 1.22+ where loop variables are automatically
captured correctly in closures.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-27 14:44:20 -07:00
Ville Vesilehto
eeb1663847 lint: enable usetesting linter (#7322)
Enable the usetesting linter in golangci.yml configuration to
enforce proper testing practices. Replace manual temporary
directory and file creation with t.TempDir() in test files.

This improves test reliability by ensuring proper cleanup and
follows Go testing best practices.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-27 10:02:55 -07:00
Ville Vesilehto
1948b6efc3 test: skip certain network-specific tests on non-Linux (#7318)
Add conditional test skipping for bind and readme tests that rely on
Linux-specific loopback interface behavior. These tests reference
network configurations that may not exist on for e.g. macOS or other
platforms, causing spurious test failures.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-23 09:23:14 -07:00
Ville Vesilehto
32ea433a29 fix(metrics): preserve request size from plugins (#7313)
The rewrite plugin modifies DNS messages, affecting the request
size observed in the coredns_dns_request_size_bytes metric.

This change captures the original request size before any plugins
can modify it. It adds a functional options pattern to Report() to
pass this information while maintaining API compatibility.

Tests have been added to verify the fix prevents rewrite from
affecting the request size metrics.

Docs included.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-22 06:38:22 -07:00
skipper
528cc26a4c fix: ensure DNS query name reset in plugin.NS error path (#7142)
Signed-off-by: hansedong <skipiper1314@gmail.com>
Co-authored-by: hansedong <skipiper1314@gmail.com>
2025-05-22 06:37:55 -07:00
Mark Mickan
1de92ec9dc fix(plugin/bind): remove zone for link-local IPv4 (#7295)
This fixes a bug introduced in
https://github.com/coredns/coredns/pull/6547 which resulted in the zone
being added to IPv4 addresses.  This bug results in a failure to start
when binding to an interface with a link-local IPv4 address assigned to
it, with the following error:

    $ ./coredns -conf=/etc/coredns/Corefile
    maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined
    lookup 169.254.1.1%dummy0: no such host

Signed-off-by: Mark Mickan <mark.mickan@openlms.net>
Co-authored-by: Mark Mickan <mark.mickan@openlms.net>
2025-05-20 06:07:46 -07:00
Arthur Outhenin-Chalandre
5c71bd0b87 kubernetes: add multicluster support (#7266)
* kubernetes: add multicluster support

Add multicluster support via Multi-Cluster Services API (MCS-API) via a
new option `multiclusterZones` in the kubernetes plugin.

When some multicluster zones are passed to the kubernetes plugin, it
will start watching the ServiceImport objects and its associated
EndpointSlices.

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* kubernetes: implement xfr support for multicluster zones

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

---------

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
2025-05-18 22:58:16 -07:00
Ville Vesilehto
efaed02c6a feat: limit concurrent DoQ streams and goroutines (#7296) 2025-05-18 17:49:21 -07:00
Kevin Lyda
17eb2eed34 Prepare for the k8s api upgrade (#7293)
Don't explicitly set `RetryOnError` to `false`.  It won't exist in the
next version of the k8s api and it won't make a difference in this code
since the struct would default to that.

Signed-off-by: Kevin Lyda <kevin@lyda.ie>
2025-05-14 13:48:13 +02:00
Yannick Epstein
13da7f749c fix(rewrite): truncated upstream response (#7277)
Forward information that a upstream response is truncated when rewriting
a CNAME. Otherwise, the cache plugin stores the truncated resonse,
making it impossible to receive the full response as a client via TCP.

Signed-off-by: Yannick Epstein <yannicke@spotify.com>
2025-05-01 10:59:15 -04:00
Hirotaka Tagawa / wafuwafu13
328165de1e fix(plugin/secondary): make transfer property mandatory (#7249)
* fix(plugin/secondary): make transfer property mandatory

Signed-off-by: wafuwafu13 <jaruwafu@gmail.com>
2025-04-25 13:40:15 -04:00
Viktor Oreshkin
427b406300 plugin/bind: remove macOS bug mention in docs (#7250)
fixed by updating to miekg/dns@v1.1.65 in #7240

upstream bug was fixed by miekg/dns#1643

Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
2025-04-25 13:38:00 -04:00
Ambrose Chua
2d1455b3e2 Remove ?bla=foo:443 for POST DoH (#7257)
Signed-off-by: Ambrose Chua <ambrose@hey.com>
2025-04-25 13:23:57 -04:00