Commit Graph

1336 Commits

Author SHA1 Message Date
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
Gleb Kogtev
52b3172b2e Do not interrupt querying readiness probes for plugins (#6975)
* Do not interrupt querying readiness probes for plugins

Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>

* Add monitor param for ready plugin

Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>

* Update ready docs

Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>

* Update ready docs

Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>

---------

Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>
2025-04-08 09:46:30 -04:00
Manuel Rüger
76ba39ffe9 chore: Upgrade to golangci-lint v2 (#7236)
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2025-04-04 14:27:39 -04:00
Parfenov Ivan
e16162dd3c Added SetProxyOptions function for forward plugin (#7229)
Signed-off-by: Paramoshka <parfenov_ivan_42a@mail.ru>
2025-04-04 12:27:47 -04:00
Ben Kochie
a1cc54b719 Update for Go 1.24 (#7226)
* Update for Go 1.24

* Update Go build to 1.24.1.
* Update minimum Go version to 1.23.0.
* Bump golangci-lint version.

Signed-off-by: SuperQ <superq@gmail.com>

* Workaround confused golangci-lint error.

Signed-off-by: SuperQ <superq@gmail.com>

---------

Signed-off-by: SuperQ <superq@gmail.com>
2025-03-24 12:50:13 -04:00
Min Woo Kim
33d0d05811 Increase CNAME lookup limit from 7 to 10 (#7153)
Signed-off-by: Min Woo Kim <59036289+minportant@users.noreply.github.com>
Signed-off-by: Min Woo Kim <minportant@gmail.com>
Co-authored-by: Min Woo Kim <59036289+minportant@users.noreply.github.com>
2025-03-24 10:38:11 -04:00
Rich
f400f870bf timeouts plugin documentation include DNS over QUIC (DoQ) (#7166)
Signed-off-by: Rich <git0@bitservices.io>
2025-03-24 10:37:28 -04:00
momantech
1bb184aa09 chore: fix some comments (#7201)
Signed-off-by: momantech <cuimoman@qq.com>
2025-03-24 10:32:39 -04:00
Bartosz Borkowski
7c76d534d3 Fix handling of pods having DeletionTimestamp set (#7119) (#7131)
Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
Co-authored-by: Bartosz Borkowski <bartosz.borkowski@grupawp.pl>
2025-03-24 10:31:24 -04:00
Chris O'Haver
8eed5991f0 Update README.md (#7210) 2025-03-24 10:25:44 -04:00
Adrian Moisey
58d8999192 Revert "only create PTR records for endpoints with hostname defined (#6898)" (#7194)
This reverts commit f4f0d55dce.

Signed-off-by: Adrian Moisey <adrian@changeover.za.net>
2025-03-18 15:42:43 -04:00
Puneet Loya
4de8fb57b2 plugin/forward: added option failfast_all_unhealthy_upstreams to return servfail if all upstreams are down (#6999)
* feat: option to return servfail if upstreams are down

Signed-off-by: Puneet Loya <puneetloya@Puneets-MBP.attlocal.net>

* fix based on review comments and added to Readme

Signed-off-by: Puneet Loya <puneetloya@Puneets-MBP.attlocal.net>

* add tests to improve code coverage

Signed-off-by: Puneet Loya <puneetloya@Puneets-MBP.attlocal.net>

* added failfast_all_unhealthy_upstreams option to forward plugin

Signed-off-by: Puneet Loya <puneetloya@Puneets-MBP.attlocal.net>

---------

Signed-off-by: Puneet Loya <puneetloya@Puneets-MBP.attlocal.net>
Co-authored-by: Puneet Loya <puneetloya@Puneets-MBP.attlocal.net>
2025-03-07 11:37:25 -05:00
Viktor
6c39f4bae7 multisocket plugin (#6882)
* multisocket plugin improves performance in multiprocessor systems

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* - refactoring
- update doc

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* remove port from reuseport plugin README

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* rename reuseport plugin to numsockets plugin

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* Add Recommendations to numsockets README

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* added numsockets test; made NUM_SOCKETS mandatory in doc

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* restart and whoami tests for numsockets plugin

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* default value for numsockets

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* caddy up

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* add numsockets to plugin.cfg

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* - rename numsockets plugin to multisocket
- default as GOMAXPROCS
- update README

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

* resolve conflicts

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>

---------

Signed-off-by: Viktor Rodionov <33463837+Shmillerov@users.noreply.github.com>
2024-11-13 09:40:25 -08:00
Nicolai Søborg
20c5f55802 root: explicit mark dnssec support (#6753)
DNSSEC keys can be specified relative to `root`: https://github.com/coredns/coredns/blob/master/plugin/dnssec/setup.go#L135

Co-authored-by: Nicolai Søborg <NicolaiSoeborg@users.noreply.github.com>
2024-10-24 15:17:25 -04:00
Keith Coleman
7078f1576f feat: dnssec load keys from AWS Secrets Manager (#6618)
feat: dnssec load keys from AWS Secrets Manager
Signed-off-by: kcolemangt <20099734+kcolemangt@users.noreply.github.com>
2024-10-24 14:50:04 -04:00
AdamKorcz
04d00b0083 fuzzing: fix broken oss-fuzz build (#6880)
Signed-off-by: Adam Korczynski <adam@adalogics.com>
2024-10-24 14:33:58 -04:00
Tobias Klauser
23e9004f63 Replace k8s.io/utils/strings/slices by Go stdlib slices (#6863)
Use the functionality provided by the Go standard library slices package
since Go 1.21 instead of the deprecated functions in the
k8s.io/utils/strings/slices package.

Signed-off-by: Tobias Klauser <tobias@isovalent.com>
2024-10-24 10:24:08 -04:00
Nikita Usatov
92724349dc plugin/rewrite: Add "revert" parameter for EDNS0 options (#6893)
* plugin/rewrite: Add "revert" parameter for EDNS0 options

Signed-off-by: Nikita Usatov <nikitakosatka@yandex.ru>

* Update README

Signed-off-by: Nikita Usatov <nikitakosatka@yandex.ru>

* plugin/rewrite: Update tests

Signed-off-by: Nikita Usatov <nikitakosatka@yandex.ru>

* plugin/rewrite: Revert change to improve coverage

Signed-off-by: Nikita Usatov <nikitakosatka@yandex.ru>

---------

Signed-off-by: Nikita Usatov <nikitakosatka@yandex.ru>
2024-10-07 13:47:56 -04:00
TAKAHASHI Shuuji
5100feebd3 Fix "GitHub" capitalization (#6806)
Signed-off-by: TAKAHASHI Shuuji <shuuji3@gmail.com>
2024-10-01 12:15:42 -04:00
Lin-1997
d4e351c3fd fix: plugin/auto: call OnShutdown() for each zone at its own OnShutdown() (#6705)
Signed-off-by: Lin-1997 <1204878199@qq.com>
2024-10-01 12:07:37 -04:00
chenylh
ae0b79313b feature: log queue and buffer memory size configuration (#6591)
* feature: log queue and buffer memory size configuration

Signed-off-by: chenyuliang5 <chenyuliang@jd.com>
2024-10-01 11:49:59 -04:00
Till Riedel
6efa95ca98 plugin/bind: add zone for link-local IPv6 instead of skipping (#6547)
* add zone for link-local IPv6 instead of skipping

Signed-off-by: Till Riedel <riedel@teco.edu>

* revert changed error handling for IPs

Signed-off-by: Till Riedel <riedel@teco.edu>

---------

Signed-off-by: Till Riedel <riedel@teco.edu>
2024-10-01 11:47:56 -04:00