Commit Graph

1321 Commits

Author SHA1 Message Date
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
Chris O'Haver
f4f0d55dce only create PTR records for endpoints with hostname defined (#6898)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2024-09-30 10:32:13 -04:00
Jason Joo
4e7bd5a51c fix: reverter should execute the reversion in reversed order (#6872)
Signed-off-by: Jason Joo <hblzxsj@gmail.com>
2024-09-11 21:07:02 -04:00
Anifalak
ee4d26b780 plugin/etcd: fix etcd connection leakage when reload (#6646)
Signed-off-by: zhongyuanjun <zhongyuanjun@bytedance.com>
Co-authored-by: zhongyuanjun <zhongyuanjun@bytedance.com>
2024-08-27 09:35:19 -04:00
Manuel Rüger
ebbbb453be kubernetes: Add useragent (#6484)
In kubernetes' audit logs you'll see:

"userAgent":"coredns/v0.0.0 (linux/amd64) kubernetes/$Format"

This change adds a userAgent to the requests made by CoreDNS against the kubernetes API:

"userAgent":"CoreDNS/v1.11.1 git_commit:ae2bbc29be1aaae0b3ded5d188968a6c97bb3144 (linux/amd64/go1.22)"

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2024-08-26 16:45:39 -04:00
Ben Kochie
d85c3b648d Update build (#6836)
* Update build

* Update Go to 1.23.0
* Update minimum Go version to 1.22.
* Update golangci-lint to v1.60.1.
* Make GitHub action version hash/tag consistent.
* Increase dependabot open PRs from 5 to 20.

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

* Fixup lint issue.

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

---------

Signed-off-by: SuperQ <superq@gmail.com>
2024-08-18 07:13:53 +02:00
Ben Kochie
ec8e3844a9 Update grpc library use (#6826)
Replace deprecated grpc Dial/DialContext with grpc.NewClient.

Signed-off-by: SuperQ <superq@gmail.com>
2024-08-18 06:13:10 +02:00
Kevin Lyda
c742ec03f5 Upgrade antonmedv/expr to expr-lang/expr (#6814)
* Upgrade antonmedv/expr to expr-lang/expr

The project has moved.  This also upgrades from 1.15.5 to 1.16.9.
The expr project lacks a changelog but tests pass and the changes don't
seem to change it much - but there were a lot of changes.

Signed-off-by: Kevin Lyda <kevin@lyda.ie>

* Upgrade build image

In reviewing the build results I see the old build image was deprecated so
upgrading to something newer.

Signed-off-by: Kevin Lyda <kevin@lyda.ie>

---------

Signed-off-by: Kevin Lyda <kevin@lyda.ie>
2024-08-11 08:00:49 -04:00
Paco Xu
e5945d2767 hosts: add hostsfile as label for coredns_hosts_entries (#6801)
Signed-off-by: Paco Xu <paco.xu@daocloud.io>
2024-08-06 07:13:22 -04:00
cedar-gao
a6338e924e optimize the performance for high qps (#6767)
Signed-off-by: gaoxuesong <gaoxuesong@jd.com>
2024-07-02 08:08:56 -04:00
Nathan Currier
626333a1b3 Fix zone parser error handling (#6680)
Signed-off-by: Nathan Currier <nathan.currier@broadcom.com>
2024-07-01 11:27:50 -04:00
Jasper Bernhardt
2e9986c622 Add alternate option to forward plugin (#6681)
Allows the forward plugin to execute the next plugin based on the return code. Similar to the externally mainted alternate plugin https://github.com/coredns/alternate

Based on the idea of chrisohaver@ in #6549 (comment)
Also incoperated the request to rename `alternate` to `next` as an option

I am having issues adding a proper test for functionality. Primarily, I do not know the code base enough and having multiple `dnstest.NewServer` with ResponseWriter does not work. From my testing these are "Singletons'' and only the last defined response writer is used for all servers

Signed-off-by: Jasper Bernhardt <jasper.bernhardt@live.de>
2024-07-01 11:20:12 -04:00
Lin-1997
3f388442cc fix: plugin/file: return error when parsing the file fails (#6699)
Signed-off-by: Lin-1997 <1204878199@qq.com>
2024-07-01 11:19:33 -04:00
Robbie Ostrow
771d64dbea [fix:documentation] Clarify autopath README (#6750)
Signed-off-by: Robbie Ostrow <ostrowr@users.noreply.github.com>
2024-07-01 11:18:35 -04:00
Takeshi Yoneda
a7ed346585 dnstap: uses pointer receiver for small response writer (#6644)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-26 15:08:47 -04:00
Manuel Alejandro de Brito Fontes
5b6d8e356c [plugin/forward] Strip local zone from IPV6 nameservers (#6635)
Signed-off-by: Alejandro de Brito Fontes <aledbf@gmail.com>
2024-04-26 13:12:25 -04:00