aboutsummaryrefslogtreecommitdiff
path: root/plugin/template (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-05-17reverse zone: fix Normalize (#4621)Gravatar Miek Gieben 1-9/+1
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>
2020-09-24For caddy v1 in our org (#4018)Gravatar Miek Gieben 4-3/+4
* 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-08-10plugin/template: Add client IP data (#4034)Gravatar Maxime Guyot 3-1/+30
Signed-off-by: Maxime Guyot <maxime@root314.com>
2020-07-25using promauto package to ensure all created metrics are properly registered ↵Gravatar Zou Nengren 2-20/+4
(#4025) Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-03-31introduce metric naming test (#3789)Gravatar Zou Nengren 1-0/+3
* introduce metric naming test Signed-off-by: zounengren <zounengren@cmss.chinamobile.com> * Update metrics.go Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-02-15plugin/template: fix panic when missing next handler (#3672)Gravatar Andy Bursavich 1-1/+1
Signed-off-by: Andy Bursavich <abursavich@gmail.com>
2019-11-29Move to CODEOWNERS (#3489)Gravatar Miek Gieben 1-4/+0
* Move to CODEOWNERS No change in who own what; just a move to CODEOWNERS. This allows dreck cleanups. Added .dreck.yaml for alias and exec. Fixes: #3486 Signed-off-by: Miek Gieben <miek@miek.nl> * stickler bot Signed-off-by: Miek Gieben <miek@miek.nl> * sort the file Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-08Directive -> plugin (#3363)Gravatar Miek Gieben 1-1/+1
Caught my eye, we name things directive still, esp when talking about the prometheus *plugin*. Rename everything that needs to be plugin to 'plugin'. Also make sure Metrics is a H2 section (not H1). Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-01Run gostaticheck (#3325)Gravatar Miek Gieben 1-3/+3
* 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-09-20all: simply registering plugins (#3287)Gravatar Miek Gieben 1-6/+1
Abstract the caddy call and make it simpler. See #3261 for some part of the discussion. Go from: ~~~ go func init() { caddy.RegisterPlugin("any", caddy.Plugin{ ServerType: "dns", Action: setup, }) } ~~~ To: ~~~ go func init() { plugin.Register("any", setup) } ~~~ This requires some external documents in coredns.io to be updated as well; the old way still works, so it's backwards compatible. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-21typo fixes (#3169)Gravatar Chris O'Haver 1-1/+1
* spelling fixes * its/it's
2019-07-03plugin/template: support metadata (#2958)Gravatar John Belamaric 3-4/+125
* Enable use of metadata in templates * Update README * Don't stash away ctx, instead use a new func
2019-07-03Update Caddy to 1.0.1, and update import path (#2961)Gravatar Yong Tang 4-4/+4
* Update Caddy to 1.0.1, and update import path This fix updates caddy to 1.0.1 and also updates the import path to github.com/caddyserver/caddy This fix fixes 2959 Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Also update plugin.cfg Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update and bump zplugin.go Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-07-02plugins: set upstream unconditionally (#2956)Gravatar Miek Gieben 3-11/+3
`upstream` is not needed as a setting; just set if unconditionally and remove all documentation and tests for it. At some point we want remove the hanlding for `upstream` as well and error out on seeing it. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-06-01allow an empty response (#2855)Gravatar Chris O'Haver 2-11/+7
2019-03-26Remove context.Context from request.Request (#2726)Gravatar Miek Gieben 1-2/+2
* 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-04Move *proxy* to external (#2651)Gravatar Yong Tang 1-7/+7
* Move *proxy* to external move the proxy plugin into coredns/proxy and remove it as a default plugin. Link the proxy to deprecated in plugin.cfg coredns/proxy doesn't compile because of the vendoring :( Signed-off-by: Miek Gieben <miek@miek.nl> * Add github.com/coredns/proxy Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-02-17Update A/PTR template README examples (#2553)Gravatar Brian Bao 1-6/+6
2019-01-13Default to upstream to self (#2436)Gravatar Miek Gieben 3-24/+10
* Default to upstream to self This is a backwards incompatible change. This is a massive (cleanup) PR where we default to resolving external names by the coredns process itself, instead of directly forwarding them to some upstream. This ignores any arguments `upstream` may have had and makes it depend on proxy/forward configuration in the Corefile. This allows resolved upstream names to be cached and we have better healthchecking of the upstreams. It also means there is only one way to resolve names, by either using the proxy or forward plugin. The proxy/forward lookup.go functions have been removed. This also lessen the dependency on proxy, meaning deprecating proxy will become easier. Some tests have been removed as well, or moved to the top-level test directory as they now require a full coredns process instead of just the plugin. For the etcd plugin, the entire StubZone resolving is *dropped*! This was a hacky (but working) solution to say the least. If someone cares deeply it can be brought back (maybe)? The pkg/upstream is now very small and almost does nothing. Also the New() function was changed to return a pointer to upstream.Upstream. It also returns only one parameter, so any stragglers using it will encounter a compile error. All documentation has been adapted. This affected the following plugins: * etcd * file * auto * secondary * federation * template * route53 A followup PR will make any upstream directives with arguments an error, right now they are ignored. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix etcd build - probably still fails unit test Signed-off-by: Miek Gieben <miek@miek.nl> * Slightly smarter lookup check in upstream Signed-off-by: Miek Gieben <miek@miek.nl> * Compilez Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-30disable ra flag for several plugins (#2408)Gravatar Isolus 1-1/+1
* disable ra flag for several plugins * removed unnecessary assignment * removed more unnecessary assignments
2018-09-19Ensure Re-register of metrics variables after a reload (#2080)Gravatar Francois Tur 1-7/+1
* - ensure plugins that use prometheus.MustRegister, re-register after reload - removing once.Do on the startup function was simplest way to do it. * - fix underscored names (advice of bot) * - tune existing UT for reload, and add a test verifying failing reload does not prevent correct registering for metrics * - ensure different ports for tests that can run in same time ..
2018-08-29Default to scrubbing replies in the server (#2012)Gravatar Miek Gieben 1-2/+0
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-14Typo fixes (#2031)Gravatar Karsten Weiss 1-5/+5
2018-07-19Clean up tests logging (#1979)Gravatar Miek Gieben 1-0/+5
* Clean up tests logging This cleans up the travis logs so you can see the failures better. Older tests in tests/ would call log.SetOutput(ioutil.Discard) in a haphazard way. This add log.Discard and put an `init` function in each package's dir (no way to do this globally). The cleanup in tests/ is clear. All plugins also got this init function to have some uniformity and kill any (future) logging there in the tests as well. There is a one-off in pkg/healthcheck because that does log. Signed-off-by: Miek Gieben <miek@miek.nl> * bring back original log_test.go Signed-off-by: Miek Gieben <miek@miek.nl> * suppress logging here as well Signed-off-by: Miek Gieben <miek@miek.nl>
2018-06-21plugin/template: fix CNAME upstream handling (#1886)Gravatar Chris O'Haver 3-4/+26
2018-06-15plugin/forward: add REFUSED test (#1878)Gravatar Miek Gieben 1-1/+1
add a test to see if we copy the rcode correctly. Some minor cleanup in import ordering and renaming NewUpstream to New as we already are in the upstream package.
2018-05-25RFC dont have a hyphen (#1837)Gravatar Miek Gieben 1-2/+2
2018-05-21plugin/template: Support NODATA responses (#1816)Gravatar Tobias Schmidt 2-2/+10
A NODATA response has no answers and rcode NOERROR, but should have a SOA record in the authority section.
2018-05-01Do Compress only when need in request.Scrub (#1760)Gravatar Miek Gieben 1-1/+2
* 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-04-27plugin/template: update metrics to include server (#1731)Gravatar Miek Gieben 3-19/+20
Add server label to the metrics and update the README.
2018-04-22all: fix plugin import ordering (#1717)Gravatar Miek Gieben 2-4/+2
Got a bit messed up with stb lib "context" usage.
2018-04-20global: move to context (#1699)Gravatar Miek Gieben 2-2/+4
* 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-01plugin/metrics: add MustRegister function (#1648)Gravatar Miek Gieben 1-10/+1
This registers the Collectors iff the metrics plugin has been loaded. Safes a bunch of code in each and every plugin's setup code.
2018-02-16plugin/template: add upstream option (#1529)Gravatar Chris O'Haver 4-1/+33
* add upstream * docs * tests
2018-02-08Add OWNERS file (#1486)Gravatar Miek Gieben 1-0/+4
This should have everyone, but the process was quite manual. The rename from middleware -> plugin also meant I had to do some extra digging on who actually submitted the PR. I also double checked the current list of people with commit access. Every plugin now has an OWNERS, except *reverse*. I'll file a bug for that.
2018-01-30Don't use standard lib context package (#1468)Gravatar Miek Gieben 2-2/+2
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-15Fix several typos (#1395)Gravatar Yong Tang 2-3/+3
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-01-15Fix SOA examples in plugin/template README (#1391)Gravatar Tobias Schmidt 1-11/+13
SOA records are returned in the authority section, not as answer.
2018-01-10Update README.md (#1373)Gravatar cricketliu 1-13/+13
Just some textual cleanup: A few misspellings and a few clarifications.
2018-01-10Doc (#1369)Gravatar Miek Gieben 1-2/+4
* Constent atx headers * Regen manual pages
2018-01-09pkg/fall: make Zero and Root vars not funcs (#1367)Gravatar Miek Gieben 1-12/+11
These can be just vars. Think that was intended as well.
2018-01-09plugin/template: small tweaks (#1366)Gravatar Miek Gieben 5-51/+46
Small README updates, and fallthrough fixes (using less code)
2018-01-09Align plugin/template usage and syntax with other plugins (#1360)Gravatar Rene Treffer 6-131/+409
* 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-08plugin/template: README tweaks (#1361)Gravatar Miek Gieben 2-13/+13
* plugin/template: README tweaks * Go gen it
2018-01-08plugin/template (#1298)Gravatar Rene Treffer 6-0/+964
* 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