Commit graph

24 commits

Author SHA1 Message Date
Ondřej Benkovský
2fa9821c7e
plugin/template : add support for extended DNS errors (#5659)
* plugin/template : add support for extended DNS errors

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-10-03 11:04:56 -04:00
Erik Johansson
0032be6a56
plugin/template: fix formatting with go fmt (#5622)
Signed-off-by: Erik Johansson <ejohansson@spotify.com>

Signed-off-by: Erik Johansson <ejohansson@spotify.com>
2022-09-15 15:48:38 -04:00
Erik Johansson
e93e932ce8
plugin/template: Add parseInt template function (#5609)
* plugin/template: Add parseInt template function

Signed-off-by: Erik Johansson <ejohansson@spotify.com>
2022-09-15 15:25:58 -04:00
Ondřej Benkovský
51f021c079
plugin/template : add view label into plugin metrics (#5620)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2022-09-15 09:36:49 -04:00
Chris O'Haver
4d1d9adb0e
fix and document zone-match regex-no-match case (#5180)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-05-13 23:23:28 -04:00
Chris O'Haver
49f0562f6c
plugin/template: Persist truncated state to client if CNAME lookup response is truncated (#4713)
* persist truncated state to client if cname lookup response is truncated

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-01-26 15:49:44 -05:00
Maxime Guyot
b3d08f9b21
plugin/template: Add client IP data (#4034)
Signed-off-by: Maxime Guyot <maxime@root314.com>
2020-08-10 10:38:18 +02:00
Andy Bursavich
1da96807ec
plugin/template: fix panic when missing next handler (#3672)
Signed-off-by: Andy Bursavich <abursavich@gmail.com>
2020-02-15 22:11:19 +01:00
Miek Gieben
dbd1c047cb
Run gostaticheck (#3325)
* Run gostaticheck

Run gostaticcheck on the codebase and fix almost all flagged items.

Only keep

* coremain/run.go:192:2: var appVersion is unused (U1000)
* plugin/chaos/setup.go:54:3: the surrounding loop is unconditionally terminated (SA4004)
* plugin/etcd/setup.go:103:3: the surrounding loop is unconditionally terminated (SA4004)
* plugin/pkg/replacer/replacer.go:274:13: argument should be pointer-like to avoid allocations (SA6002)
* plugin/route53/setup.go:124:28: session.New is deprecated: Use NewSession functions to create sessions instead. NewSession has the same functionality as New except an error can be returned when the func is called instead of waiting to receive an error until a request is made.  (SA1019)
* test/grpc_test.go:25:69: grpc.WithTimeout is deprecated: use DialContext and context.WithTimeout instead.  Will be supported throughout 1.x.  (SA1019)

The first one isn't true, as this is set via ldflags. The rest is
minor. The deprecation should be fixed at some point; I'll file some
issues.

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

* Make sure to plug in the plugins

import the plugins, that file that did this was removed, put it in the
reload test as this requires an almost complete coredns server.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-01 07:41:29 +01:00
John Belamaric
7cf73cc01d
plugin/template: support metadata (#2958)
* Enable use of metadata in templates

* Update README

* Don't stash away ctx, instead use a new func
2019-07-03 16:10:56 +01:00
Miek Gieben
53f3f0b666
Remove context.Context from request.Request (#2726)
* Remove context.Context from request.Request

This removes the context from request.Request and makes all the changes
in the code to make it compile again. It's all mechanical. It did
unearth some weirdness in that the context was kept in handler structs
which may cause havoc with concurrently handling of requests.

Fixes #2721

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

* Make test compile

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-26 14:37:30 +00:00
Isolus
7642995558 disable ra flag for several plugins (#2408)
* disable ra flag for several plugins

* removed unnecessary assignment

* removed more unnecessary assignments
2018-12-30 17:05:08 +01:00
Miek Gieben
ba1efee4f1
Default to scrubbing replies in the server (#2012)
Every plugin needs to deal with EDNS0 and should call Scrub to make a
message fit the client's buffer. Move this functionality into the server
and wrapping the ResponseWriter into a ScrubWriter that handles these
bits for us. Result:

Less code and faster, because multiple chained plugins could all be
calling scrub and SizeAndDo - now there is just one place.

Most tests in file/* and dnssec/* needed adjusting because in those unit
tests you don't see OPT RRs anymore. The DNSSEC signer was also looking
at the returned OPT RR to see if it needed to sign - as those are now
added by the server (and thus later), this needed to change slightly.

Scrub itself still exist (for backward compat reasons), but has been
made a noop. Scrub has been renamed to scrub as it should not be used by
external plugins.

Fixes: #2010

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-29 12:26:22 +01:00
Chris O'Haver
716791aa09
plugin/template: fix CNAME upstream handling (#1886) 2018-06-21 14:38:29 -04:00
Miek Gieben
5735292406
Do Compress only when need in request.Scrub (#1760)
* Remove Compress by default

Set Compress = true in Scrub only when the message doesn not fit the
advertized buffer. Doing compression is expensive, so try to avoid it.

Master vs this branch
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	   50000	     24774 ns/op

pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	  100000	     21960 ns/op

* and make it compile
2018-05-01 21:04:06 +01:00
Miek Gieben
2a28efa877
plugin/template: update metrics to include server (#1731)
Add server label to the metrics and update the README.
2018-04-27 19:37:12 +01:00
Miek Gieben
0930eb8beb
all: fix plugin import ordering (#1717)
Got a bit messed up with stb lib "context" usage.
2018-04-22 08:34:35 +01:00
Miek Gieben
8722336fff
global: move to context (#1699)
* global: move to context

Move from golang.org/x/net/context to std lib's context.

Change done with:

for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done
for i in **/*.go; do goimports -w $i; done

* drop from dns.pb.go as well
2018-04-20 11:01:06 +01:00
Chris O'Haver
2cad04ec10 plugin/template: add upstream option (#1529)
* add upstream

* docs

* tests
2018-02-16 09:45:25 +01:00
Miek Gieben
f91cb61086 Don't use standard lib context package (#1468)
With Go 1.9 you *can* include the std lib's context package and nothing
breaks. However we never officially made the move (and grpc also doesn't
ues the std lib's one).

Standardize all plugins on using the extern context package.

Fixes #1466
2018-01-30 09:19:37 -05:00
Miek Gieben
a19ea63d3a
plugin/template: small tweaks (#1366)
Small README updates, and fallthrough fixes (using less code)
2018-01-09 21:48:32 +00:00
Rene Treffer
0091e1c9dc Align plugin/template usage and syntax with other plugins (#1360)
* Align plugin/template usage and syntax with other plugins

* Use new fallthrough logic in plugin/template

* Use zone name normalization for plugin/template

* Test fallthrough parsing in plugin/template

* Rework scoping of match checks

Most matches are not plugin global but per template. The plugin does only a
very rough check while detailed checks are done per-template.

Per template checks include:
- Zones
- Class/Type
- Regex
- Fallthrough

* Remove trailing `.` from fully qualified domain names

* Register template metrics with zone/class/type instead of regex

* Remove trailing fqdn dot from multiple testcases
2018-01-09 21:30:58 +00:00
Miek Gieben
dd37627e8e
plugin/template: README tweaks (#1361)
* plugin/template: README tweaks

* Go gen it
2018-01-08 13:13:25 +00:00
Rene Treffer
a322d90f6f plugin/template (#1298)
* Add a template plugin

The template plugin matches the incoming query by class, type and regex
and templates a response with go templates.

* Fix go style errors

* Fix template README example

* Fix corefile example in plugin/template

* Clarify plugin/template/README.md

Add more details and external links where needed.

* Fix code issues in plugin/template

* Add template metrics

* Add section and template to template plugin metrics

* Fix style / remove extra newline on go imports

* Fix typo in plugin/template/README.md

* Update README.md

I've change the format a bit in a PR that I merged yesterday.

* Add authority section to plugin/template

* Fix naming of incoming query name in plugin/template/README.md

* Fix doc syntax in plugin/template/README.md

* Add authority section to plugin/template/README.md config overview

* Add metric labels to plugin/template/README.md metrics section

* Use request.Request to pass state to the template matcher
2018-01-08 10:52:25 +00:00