Commit graph

168 commits

Author SHA1 Message Date
AdamKorcz
04d00b0083
fuzzing: fix broken oss-fuzz build ()
Signed-off-by: Adam Korczynski <adam@adalogics.com>
2024-10-24 14:33:58 -04:00
Jasper Bernhardt
2e9986c622
Add alternate option to forward plugin ()
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  (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
Manuel Alejandro de Brito Fontes
5b6d8e356c
[plugin/forward] Strip local zone from IPV6 nameservers ()
Signed-off-by: Alejandro de Brito Fontes <aledbf@gmail.com>
2024-04-26 13:12:25 -04:00
Snawoot
8e783897a2
forward: respect context ()
Signed-off-by: Vladislav Yarmak <vladislav-ex-src@vm-0.com>
2024-03-07 14:54:28 -05:00
Marius Kimmina
92ec849acb
plugin/tls: respect the path specified by root plugin ()
* plugin/tls: respect the path specified by root plugin

Signed-off-by: Marius Kimmina <mar.kimmina@gmail.com>

* improve readme

Signed-off-by: Marius Kimmina <mar.kimmina@gmail.com>

---------

Signed-off-by: Marius Kimmina <mar.kimmina@gmail.com>
2023-12-08 10:50:30 -05:00
Yuheng
90d55611a2
Plugin dnstap: add support for "extra" field in payload ()
* dnstap: add 'extra' field

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: add setup_test for 'extra' field

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* udnstap: update document and test

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: update setup_test for more coverage

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: add TapMessageWithMetadata function to Dnstap

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: adapt dnstap and forward plugins to use TapMessageWithMetadata

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* change TapMessageWithMetadata function

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* tab inconsistency fix

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* fix replacer to support empty state

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* add replacer test for empty status parameter

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: update unit test for 'extra' field

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* clean up code

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* gofmt fix & static analysis fix

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: refactor

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

---------

Signed-off-by: chenyuheng <chenyuheng99@qq.com>
2023-08-14 11:01:13 -07:00
Pat Downey
ea293da1d6
Fix forward metrics for backwards compatibility () 2023-07-04 16:35:55 +02:00
Chris O'Haver
d3965b8b60
Revert "plugin/tls: respect the path specified by root plugin ()" ()
This reverts commit d0375bc026.
2023-06-01 14:07:58 -04:00
Marius Kimmina
d0375bc026
plugin/tls: respect the path specified by root plugin ()
Signed-off-by: Marius Kimmina <mar.kimmina@gmail.com>
2023-06-01 08:56:57 -04:00
Justin
7231bb0881
plugin/forward: fix descriptions in README.md ()
Signed-off-by: Justin <cattyhouse@users.noreply.github.com>
2023-05-26 17:01:06 -04:00
Catena cyber
31ff926ea1
fuzz: fix forward plugin target ()
Signed-off-by: Philippe Antoine <contact@catenacyber.fr>
2023-05-25 09:09:56 -04:00
Pat Downey
f823825f8a
plugin/forward: Allow Proxy to be used outside of forward plugin. ()
* plugin/forward: Move Proxy into pkg/plugin/proxy, to allow forward.Proxy to be used outside of forward plugin.

Signed-off-by: Patrick Downey <patrick.downey@dioadconsulting.com>
2023-03-24 08:55:51 -04:00
Gerhard Tan
b7279d1f66
plugin/forward: fix broken tap plugins when dnstap plugins specified ()
* plugin/forward: fix broken tap plugins when dnstap plugins specified

---------

Signed-off-by: Gerhard Tan <gwohau.tan@gmail.com>
2023-01-30 14:38:15 -05:00
Chris O'Haver
04a30198c3
plugin/dnstap: Fix behavior when multiple dnstap plugins specified ()
* fix multiple dnstap plugins behavior

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-11-28 10:33:31 -05:00
Yong Tang
26aae951e7
plugin/forward: fix ticker leak in golang () 2022-10-11 15:28:24 +02:00
Vancl
4033d7aeba
plugin/forward: health_check needs to normalize a specified domain name ()
* plugin/forward: convert the specified domain of health_check to Fqdn
* plugin/forward: update readme for health check

Signed-off-by: vanceli <vanceli@tencent.com>
2022-08-15 10:16:15 -04:00
Chris O'Haver
513f27b9a9
plugin/forward: Enable multiple forward declarations ()
* enable multiple declarations of forward plugin

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-07-20 10:35:04 -04:00
Ondřej Benkovský
c2dbb7141a
add golangci-lint linter () 2022-07-10 11:06:33 -07:00
Ondřej Benkovský
dcc3d76018
remove unused coredns_forward_sockets_open metric ()
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-06-13 07:30:34 -07:00
RetoHaslerMGB
d594d61341
Correct timeout description () 2022-05-19 02:48:25 -07:00
hansedong
0622a6c66c
plugin/forward: configurable domain support for healthcheck ()
* plugin/forward: configurable domain support for healthcheck

Signed-off-by: hansedong <admin@yinxiaoluo.com>
2022-04-12 12:39:48 -04:00
Qasim Sarfraz
74b84a1377
update all +build statements ()
* update all +build statements

Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com>

* remove old +build style

Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com>
2022-03-18 07:11:14 -07:00
Yong Tang
aa7818e1d3
Update to avoid pseudo-random number ()
* Update to avoid pseudo-random number

This PR update the usage of rand so that non-global seed is used.

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

* Add concurrency-safe random source

See https://stackoverflow.com/questions/48958886/how-to-create-a-thread-safe-rand-source

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-03-16 12:24:58 -04:00
Chris O'Haver
f8a02aaf58
dont panic when from-zone cannot be normalized ()
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-02-17 15:13:18 -05:00
Tomas Hulata
b0edae07f1
Health-checks should respect force_tcp ()
* health check should respect force_tcp

Signed-off-by: tombokombo <tombo@sysart.tech>
2022-02-09 09:45:52 -05:00
Yong Tang
041e1eabc6
Fix a couple of code scanning alerts ()
This PR fixed a couple of code scanning alerts:

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-02-07 09:09:12 -05:00
OctoHuman
29f6d0a6b2
Docs: Add warning to use tls_servername ()
Signed-off-by: OctoHuman <17958767+OctoHuman@users.noreply.github.com>
2021-11-22 08:49:13 +01:00
Chris O'Haver
3288b111b2
Revert "Initial implementation of ForwardCRD plugin ()" ()
This reverts commit 2e6953c7db.
2021-11-12 13:19:16 -05:00
Christian Ang
2e6953c7db
Initial implementation of ForwardCRD plugin ()
* Add forwardcrd plugin README.md

Co-authored-by: Aidan Obley <aobley@vmware.com>

Signed-off-by: Christian Ang <angc@vmware.com>

* Create forwardcrd plugin

- Place forwardcrd before forward plugin in plugin list. This will avoid
forward from preventing the forwardcrd plugin from handling any queries
in the case of having a default upstream forwarder in a server block (as
is the case in the default kubernetes Corefile).

Co-authored-by: Aidan Obley <aobley@vmware.com>

Signed-off-by: Christian Ang <angc@vmware.com>

* Add Forward CRD

Signed-off-by: Christian Ang <angc@vmware.com>

* Add NewWithConfig to forward plugin

- allows external packages to instanciate forward plugins

Co-authored-by: Aidan Obley <aobley@vmware.com>

Signed-off-by: Christian Ang <angc@vmware.com>

* ForwardCRD plugin handles requests for Forward CRs

- add a Kubernetes controller that can read Forward CRs
- instances of the forward plugin are created based on Forward CRs from
the Kubernetes controller
- DNS requests are handled by calling matching Forward plugin instances
based on zone name
- Defaults to the kube-system namespace to align with Corefile RBAC

Signed-off-by: Christian Ang <angc@vmware.com>

Use klog v2 in forwardcrd plugin

* Refactor forward setup to use NewWithConfig

Co-authored-by: Christian Ang <angc@vmware.com>

Signed-off-by: Edwin Xie <exie@vmware.com>

* Use ParseInt instead of Atoi

- to ensure that the bitsize is 32 for later casting to uint32

Signed-off-by: Christian Ang <angc@vmware.com>

* Add @christianang to CODEOWNERS for forwardcrd

Signed-off-by: Christian Ang <angc@vmware.com>

Co-authored-by: Edwin Xie <exie@vmware.com>
2021-11-12 11:22:34 -05:00
Zou Nengren
5191959bd7
cleanup deprecated package io/ioutil ()
Signed-off-by: zounengren <zouyee1989@gmail.com>
2021-10-13 09:30:31 +02:00
coredns[bot]
5b65a58d48 auto go fmt
Signed-off-by: coredns[bot] <bot@bot.coredns.io>
2021-10-11 10:28:01 +00:00
Vector
0f5e7bdfb3
plugin/forward: Use new msg.Id for upstream queries ()
* restore 1.8.3 question revert logic; add tests ()

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Signed-off-by: Vector <815926354@qq.com>

* change origin message id

Signed-off-by: Vector <815926354@qq.com>
Signed-off-by: IIvyPy <815926354@qq.com>

* Revert "restore 1.8.3 question revert logic; add tests ()"

This reverts commit 95e44d91d0.

Signed-off-by: IIvyPy <815926354@qq.com>

Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
2021-10-08 19:34:22 +02:00
Ondřej Benkovský
e0110264cc
plugin/forward : add proxy address as tag ()
Signed-off-by: Ondrej Benkovsky <ondrej.benkovsky@wandera.com>
2021-07-16 14:35:39 +02:00
Chris O'Haver
09b63df9c1
fix cidr multi-zone check ()
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-06-10 10:50:20 +02:00
Chris O'Haver
d8a0d97df2
deprecate Normalize and MustNormalize ()
* deprecate normalize and mustnormalize

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* add runtime warning

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* elaborate runtime warning

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* include caller info

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-05-27 13:26:14 +02:00
Chris O'Haver
0348b019be
plugin/forward: Document and warn for unsupported FROM CIDR notations ()
* trap unsupported FROM cidr notations

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* make is a warning

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-05-20 09:24:36 +02:00
Miek Gieben
5f41d8eb1f
reverse zone: fix Normalize ()
Make normalize return multiple "hosts" (= reverse zones) when a
non-octet boundary cidr is given.

Added pkg/cidr package that holds the cidr calculation routines; felt
they didn't really fit dnsutil.

This change means the IPNet return parameter isn't needed, the hosts are
all correct. The tests that tests this is also removed: TestSplitHostPortReverse
The fallout was that zoneAddr _also_ doesn't need the IPNet member, that
in turn make it visible that zoneAddr in address.go duplicated a bunch
of stuff from register.go; removed/refactored that too.

Created a plugin.OriginsFromArgsOrServerBlock to help plugins do the
right things, by consuming ZONE arguments; this now expands reverse
zones correctly. This is mostly mechanical.

Remove the reverse test in plugin/kubernetes which is a copy-paste from
a core test (which has since been fixed).

Remove MustNormalize as it has no plugin users.

This change is not backwards compatible to plugins that have a ZONE
argument that they parse in the setup util.

All in-tree plugins have been updated.

Signed-off-by: Miek Gieben <miek@miek.nl>
2021-05-17 13:19:54 -07:00
Miek Gieben
ed3f287fe8
metrics: remove RR type ()
To combat label cardinality explosions remove the type from metrics.
This was most severe in the histogram for request duration, remove it
there.

It's also highlighted difference between grpc and forward code, where
forward did use type and grpc didn't; getting rid of all that "fixes"
that discrepancy

Move monitor.go back into the vars directory and make it private again.
Also name it slightly better

Fixes: 

Signed-off-by: Miek Gieben <miek@miek.nl>
2021-03-19 12:59:26 +01:00
Chris O'Haver
929aa3886e
add metadata section to docs ()
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-03-16 13:51:21 +01:00
Chris O'Haver
32cc745dc2
add forward/upstream metadata ()
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-03-16 13:34:22 +01:00
Maxime Ginters
b1173ed2a5
plugin/forward Add rcode and rtype to request_duration_seconds metric ()
* plugin/forward Add rcode and rtype to request_duration_seconds metric

Signed-off-by: Maxime Ginters <maxime.ginters@shopify.com>

* Control the cardinality of query type

Signed-off-by: Maxime Ginters <maxime.ginters@shopify.com>
2021-01-28 16:37:17 +01:00
Frank Riley
eba74389c4
Fix , fix out of order messages and fix forward perspective. ()
Signed-off-by: Frank Riley <fhriley@gmail.com>
2021-01-21 10:00:27 +01:00
Chris O'Haver
9cb53487ec
respond with REFUSED when max_concurrent is exceeded to avoid caching it ()
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-12-15 14:02:15 +01:00
Miek Gieben
8759d00edd
forward doc update ()
* forward: add example with multiple DoT upstreams

Remove Bugs section as this is a nice work around.

h/t https://twitter.com/mholt6/status/1284250606673080321

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

* Actually remove bugs section

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-11-03 06:32:49 -08:00
Miek Gieben
c840caf1ef
Speed up testing ()
* Speed up testing

* make notification run in the background, this recudes the test_readme
time from 18s to 0.10s
* reduce time for zone reload

* TestServeDNSConcurrent remove entirely. This took a whopping 58s for
  ... ? A few minutes staring didn't reveal wth it is actually testing.
  Making values smaller revealed race conditions in the tests. Remove
  entirely.

* Move many interval values to variables so we can reset them to short
  values for the tests.

* test_large_axfr: make the zone smaller. The number used 64K has no
  rational, make it 64/10 to speed up.
* TestProxyThreeWay: use client with shorter timeout

A few random tidbits in other tests.

Total time saved: 177s (almost 3m) - which makes it worthwhile again to
run the test locally:

this branch:

~~~
ok  	github.com/coredns/coredns/test	10.437s
cd plugin; time go t ./...
5,51s user 7,51s system 11,15s elapsed 744%CPU (
~~~

master:

~~~
ok  	github.com/coredns/coredns/test	35.252s
cd plugin; time go t ./...
157,64s user 15,39s system 50,05s elapsed 345%CPU ()
~~~
tests/ -25s
plugins/ -40s

This brings the total on 20s, and another 10s can be saved by fixing
dnstapio. Moving this to 5s would be even better, but 10s is also nice.

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

* Also 0.01

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-30 10:27:04 +01:00
Miek Gieben
c2e4f2f1ab
docs: move Also See to See Also ()
sed -i 's/Also See/See Also/' plugin/**/README.md

Some plugins did already use 'See Also', so it's all consistent now.

Fixes: 

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-28 10:56:35 -07:00
ZouYu
c58e4b09fc
Fix golint warnings ()
Include:
1. plugin/forward/type.go:8:2: const typeUdp should be typeUDP
2. plugin/forward/type.go:9:2: const typeTcp should be typeTCP
3. plugin/forward/type.go:10:2: const typeTls should be typeTLS
4. plugin/kubernetes/metrics.go:24:2: var DnsProgrammingLatency should be DNSProgrammingLatency
5. plugin/kubernetes/metrics_test.go:124:102: func parameter clusterIp should be clusterIP

Signed-off-by: zouyu <zouy.fnst@cn.fujitsu.com>
2020-10-28 07:39:56 +01:00
Miek Gieben
b3b8a7e4b7
plugin/dnstap: various cleanups ()
* plugin/dnstap: various cleanups

A recent issue made me look into this plugin, I suspect various other
cleanups (hopefully deletion of code) can be made as well

Remove identical functions ToClientQuery etc, and just use tap.Message
as the base type in plugin. Keep msg/ for a few helper functions that
may proof useful.

This remove the whole test directory as we will just check the things we
are interested in which gives much better feedback and keeps that code
closer together.

tapwr dir is also not needed, writer_test.go was just duplicating the
tests already done. This moves writer.go to the top directory.

Make the only user of dnstap, the forward plugin, use the newer code
also remove the test, a better test there would be a full e2e test to
see the correct thing happens.

Cleanup the Tapper interface and move it to dnstapio where it belongs,
remove higher level interfaces that are not used. This remove
dnstap.Tapper and dnstap.IORoutines.

Use the standard mechanism for getting access to a plugin and remove
shuffling the plugin into the context.

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

* use opts to get the correct proto

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

* Various fixes

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

* Remove bad addr test, as dnstap is only called from within coredns where these fields have been preparsed

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

* dnstap: remove saving the error

all these fields have been preparsed, no need for dnstap to be pedantic
and check (and save!) this error again.

Simplifies it a bit more.

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

* Update plugin/forward/dnstap.go

Co-authored-by: Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com>

* Code review

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

* add back in preferUDP

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

* nit

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

Co-authored-by: Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com>
2020-10-12 19:10:35 +02:00
Miek Gieben
b003d06003
For caddy v1 in our org ()
* For caddy v1 in our org

This RP changes all imports for caddyserver/caddy to coredns/caddy. This
is the v1 code of caddy.

For the coredns/caddy repo the following changes have been made:

* anything not needed by us is deleted
* all `telemetry` stuff is deleted
* all its import paths are also changed to point to coredns/caddy
* the v1 branch has been moved to the master branch
* a v1.1.0 tag has been added to signal the latest release

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

* Fix imports

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

* Group coredns/caddy with out plugins

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

* remove this file

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

* Relax import ordering

github.com/coredns is now also a coredns dep, this makes
github.com/coredns/caddy fit more natural in the list.

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

* Fix final import

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-24 18:14:41 +02:00
Ruslan Drozhdzh
f96a2f1f69
plugin/forward: fix panic when expire is configured as 0s ()
Signed-off-by: Ruslan Drozhdzh <rdrozhdzh@infoblox.com>
2020-09-15 14:36:39 +02:00