aboutsummaryrefslogtreecommitdiff
path: root/plugin/rewrite (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-05-04plugin/rewrite: streamline the ResponseRule handling. (#4473)Gravatar Uwe Krueger 13-514/+882
* plugin/rewrite: streamline the ResponseRule handling. The functionality of a response rule is now completely encapsulated behind a `ResponseRule` interface. This significantly simplifies the complete processing flow, it enables more flexible response handling and it is possible to eliminate lots of state flags, ifs and switches. Based on the new flexibility the pull request also enables to support a response name rewrite for all name rewrite types. To be compatible, an explicit `answer auto` option is added to support a best effort response rewrite (name and value). Additionally now all name rewrite rules support additional name and value reponse rewrite options. Using this feature it is also possible now to rewrite a complete sub domain hierarchy to a single domain name combined with a correct rewrite (#2389). Signed-off-by: Uwe Krueger <uwe.krueger@sap.com> * revert policy Signed-off-by: Uwe Krueger <uwe.krueger@sap.com> Co-authored-by: Miek Gieben <miek@miek.nl>
2021-02-24auto go fmtv1.8.2Gravatar coredns-auto-go-fmt[bot] 4-23/+25
2021-02-23auto remove trailing whitespacesGravatar coredns-auto-trailing-whitespaces[bot] 1-5/+5
2021-02-23Rewrite SRV targets and additional names in response (#4287)Gravatar slick-nic 9-129/+318
* Rewrite plugin - rewrite SRV targets and names in response answer and additional records Signed-off-by: Nic Colledge <nic@njcolledge.net> * Added README content to describe new behaviour Signed-off-by: Nic Colledge <nic@njcolledge.net> * Added more record types to rewrite handling based on PR/Issue feedback Signed-off-by: Nic Colledge <nic@njcolledge.net> * Updated README.md for plugin Signed-off-by: Nic Colledge <nic@njcolledge.net> * Updated unit tests. Small refactor of getTarget... function. Signed-off-by: Nic Colledge <nic@njcolledge.net> * Refactor to add response value rewrite as answer value option Signed-off-by: Nic Colledge <nic@njcolledge.net> * Removed TODO comment, added test for NAPTR record. Signed-off-by: Nic Colledge <nic@njcolledge.net>
2021-02-01plugin/rewrite: copy msg before rewritting (#4443)Gravatar Miek Gieben 1-1/+4
Copy the msg to prevent messing with the (via the pointer) original created message that may be stored in the cache or anything other data store. Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-24For caddy v1 in our org (#4018)Gravatar Miek Gieben 3-5/+3
* 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-01Fix some typos in comments. (#4100)Gravatar Hu Shuai 3-16/+16
Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
2020-01-31presubmit: test README.md sections (#3644)Gravatar Miek Gieben 1-0/+2
Automatically submitted.
2019-12-29doc: fix generated manual pages (#3571)Gravatar Miek Gieben 1-14/+0
Went over all generated manual pages and fixed some markdown issues, mostly escaping "_" to avoid underlining entire paragraphs. Some textual fixes in route53 and other cloud DNS plugins. Regenerated the markdown with mmark. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-11-29Move to CODEOWNERS (#3489)Gravatar Miek Gieben 1-6/+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-01Run gostaticheck (#3325)Gravatar Miek Gieben 4-6/+2
* 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-27cleanup code by lint (#3312)Gravatar Guangming Wang 3-11/+4
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-09-26fix mis-spelling (#3310)Gravatar xieyanker 2-2/+2
Signed-off-by: xieyanker <xjsisnice@gmail.com>
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-25fuzz: revert setup function (#3189)Gravatar Miek Gieben 1-1/+1
This can't be used in its current form; revert the entire PR. Revert "fuzzing: allow setup function to be called (#3175)" This reverts commit 62451fd3eb68cef5dcdafe6e4228f08cf52d84fc.
2019-08-25fuzz: use gofuzz build tag instead of fuzz (#3185)Gravatar Muhammad Falak R Wani 1-1/+1
* fuzz: use gofuzz build tag instead of fuzz Since go-fuzz does not support Go modules yet, vendor dependencies. Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> * fuzz: avoid vendoring code for go-fuzz Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2019-08-24fuzzing: allow setup function to be called (#3175)Gravatar Miek Gieben 1-1/+1
This allows to fuzzing of more interesting targets that require setup. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-07-14rewrite: remove condition file (#3003)Gravatar Charlie Vieth 1-111/+0
Nothing it declares is used by CoreDNS and it does not appear to be used by any third-party packages (according to godoc.org).
2019-07-12plugin/rewrite: fix domain length validation (#2995)Gravatar Ruslan Drozhdzh 2-19/+3
* unit test * fix domain length validation * code optimization * remove unit test
2019-07-03Update Caddy to 1.0.1, and update import path (#2961)Gravatar Yong Tang 3-3/+3
* 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-06-25Run gofmt -s and golint on the codebase (#2918)Gravatar Miek Gieben 4-61/+64
* Run gofmt -s and golint on the codebase Run golint and fix everythign it flagged (except the context arg ordering), mostly edits in the rewrite plugin. Signed-off-by: Miek Gieben <miek@miek.nl> * ... and ofcourse the test as well Signed-off-by: Miek Gieben <miek@miek.nl>
2019-05-31Update README.md (#2856)Gravatar Cricket Liu 1-48/+48
General syntactic cleanup.
2019-02-27Fix error string should not be capitalized (#2608)Gravatar Nguyen Quang Huy 2-3/+3
From [Golang coding convention](https://github.com/golang/go/wiki/CodeReviewComments#error-strings) Co-Authored-By: Nguyen Van Trung [trungnvfet@outlook.com](mailto:trungnvfet@outlook.com) Signed-off-by: Nguyen Quang Huy [huynq0911@gmail.com](mailto:huynq0911@gmail.com)
2019-02-20Remove some duplicate worlds (#2582)Gravatar Nguyen Phuong An 2-2/+2
Signed-off-by: Nguyen Phuong An <AnNP@vn.fujitsu.com>
2019-02-17Fix some typos (#2560)Gravatar Nguyen Quang Huy 1-1/+1
* Fix some typos Corect some words for reading more easily * Update NOERROR response code NOERROR is a response code so I revert the typo checking for it
2019-02-12pkg/replace: make it more efficient. (#2544)Gravatar Miek Gieben 1-4/+6
* pkg/replace: make it more efficient. Remove the map that is allocated on every write and make it more static, but just defining a function that gets called for a label and returns its value. Remove the interface definition and just implement what is needed in our case. Add benchmark test for replace as well. Extend metadata test to test multiple values (pretty sure this didn't work, but there wasn't a test for it, so can't be sure). Update all callers to use it - concurrent use should be fine as we pass everything by value. Benchmarks in replacer: new: BenchmarkReplacer-4 300000 4717 ns/op 240 B/op 8 allocs/op old: BenchmarkReplacer-4 300000 4368 ns/op 384 B/op 11 allocs/op Added benchmark function to the old code to test it. ~~~ func BenchmarkReplacer(b *testing.B) { w := dnstest.NewRecorder(&test.ResponseWriter{}) r := new(dns.Msg) r.SetQuestion("example.org.", dns.TypeHINFO) r.MsgHdr.AuthenticatedData = true b.ResetTimer() b.ReportAllocs() repl := New(context.TODO(), r, w, "") for i := 0; i < b.N; i++ { repl.Replace("{type} {name} {size}") } } ~~~ New code contains (of course a different one). The amount of ops is more, which might be good to look at some more. For all the allocations is seems it was quite performant. This looks to be 50% faster, and there is less allocations in log plugin: old: BenchmarkLogged-4 20000 70526 ns/op new: BenchmarkLogged-4 30000 57558 ns/op Signed-off-by: Miek Gieben <miek@miek.nl> * Stickler bot Signed-off-by: Miek Gieben <miek@miek.nl> * Improve test coverage Signed-off-by: Miek Gieben <miek@miek.nl> * typo Signed-off-by: Miek Gieben <miek@miek.nl> * Add test for malformed log lines Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-06Use Trim(Prefix/Suffix) instead of Trim(Left/Right) in rewrite prefix plugin ↵Gravatar Daniel Garcia 2-22/+37
(#2364) (#2372)
2018-12-06Fix EDNS0 compliance (#2357)Gravatar Miek Gieben 1-0/+9
* Fix EDNS0 compliance Do SizeAndDo in the server (ScrubWriter) and remove all uses of this from the plugins. Also *always* do it. This is to get into compliance for https://dnsflagday.net/. The pkg/edns0 now exports the EDNS0 options we understand; this is exported to allow plugins add things there. The *rewrite* plugin used this to add custom EDNS0 option codes that the server needs to understand. This also needs a new release of miekg/dns because it triggered a race-condition that was basicly there forever. See: * https://github.com/miekg/dns/issues/857 * https://github.com/miekg/dns/pull/859 Running a test instance and pointing the https://ednscomp.isc.org/ednscomp to it shows the tests are now fixed: ~~~ EDNS Compliance Tester Checking: 'miek.nl' as at 2018-12-01T17:53:15Z miek.nl. @147.75.204.203 (drone.coredns.io.): dns=ok edns=ok edns1=ok edns@512=ok ednsopt=ok edns1opt=ok do=ok ednsflags=ok docookie=ok edns512tcp=ok optlist=ok miek.nl. @2604:1380:2002:a000::1 (drone.coredns.io.): dns=ok edns=ok edns1=ok edns@512=ok ednsopt=ok edns1opt=ok do=ok ednsflags=ok docookie=ok edns512tcp=ok optlist=ok All Ok Codes ok - test passed. ~~~ Signed-off-by: Miek Gieben <miek@miek.nl> Signed-off-by: Miek Gieben <miek@miek.nl> * typos in comments Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-06Use TrimPrefix instead of TrimLeft in rewrite prefix plugin (#2364) (#2370)Gravatar Daniel Garcia 2-1/+29
2018-11-13plugin/log - Support for Metadata (#2251)Gravatar Francois Tur 1-1/+2
* - add metadata support to Log * - adapt ctx after rebase
2018-10-31Revert "log/forward plugins: Extend dns query logging (#2240)" (#2256)Gravatar Miek Gieben 1-1/+1
This reverts commit 8045aa279b510793a7c083a50de66e1df8871564.
2018-10-29log/forward plugins: Extend dns query logging (#2240)Gravatar Dzmitry Razhanski 1-1/+1
Automatically submitted.
2018-10-23plugin/rewrite: add closing dot for suffix rewrite rule (#2070)Gravatar Paul G 4-34/+196
* add closing dot for suffix rewrite rule * improve rule syntax checks Resolves: #1881
2018-09-22plugin/rewrite: silence these tests (#2120)Gravatar Miek Gieben 1-16/+3
* plugin/rewrite: silence these tests The old Unix saying: no news, is good news. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix da tests Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-17Move suffix example out of EDNS0 section (#2102)Gravatar Chris O'Haver 1-6/+6
2018-08-29plugin/rewrite: add handling of TTL field rewrites (#2048)Gravatar Paul G 6-25/+453
Resolves: #1981 Signed-off-by: Paul Greenberg <greenpau@outlook.com>
2018-08-23Add suffix example to docs (#2049)Gravatar Chris O'Haver 1-0/+6
2018-08-14Typo fixes (#2031)Gravatar Karsten Weiss 1-1/+1
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-07-13plugin/rewrite: prevent illegal names (#1972)Gravatar Miek Gieben 6-10/+63
Log and returns an error when the name rewrite creates a name that is illegal. Add test in name_test.go to see if an error is returned. Possible followup could be the only check this if a name-rewrite is done. Fixes: #1638 Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-09Remove trailing whitespace (#1955)Gravatar Miek Gieben 1-3/+3
Prevent future; "remove trailing whitespace" PR, but adding a simple presubmit that checks for this. This presubmit flagged quite some offenders, remove all trailing whitespace from. Apart from that there aren't any other changes. Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-08- compliance with metadata contract. If metadata value is empty, ignore ↵Gravatar Francois Tur 2-3/+6
rewrite - like if metadata does not exist. (#1953)
2018-07-08plugin/rewrite - extend edns0 local variable support with metadata (#1928)Gravatar Francois Tur 7-20/+88
* - add support of metadata values for edns0 local variables * - comments from review. * - simplify label check. Add UT * - enhance check for Labels, add UT - remove IsMetadataSet * - edns0 variable - if variable is not found just ignore the rewrite.
2018-07-02plugin/rewrite: use request.Request and other cleanups (#1920)Gravatar Miek Gieben 11-311/+191
This was done anyway, but only deep in the functions, just do this everywhere; allows for shorter code and request.Request allows for caching as well. Cleanups, make it more Go like. * remove unneeded switches * remove testdir (why was this there??) * simplify the logic * remove unneeded variables * put short functions on a single line * fix documentation. * spin off wire funcs in wire.go, make them functions. Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-01plugin/metadata: metadata is just label=value (#1914)Gravatar Miek Gieben 7-42/+130
This revert 17d807f0 and re-adds the metadata plugin as a plugin that just sets a label to a value function. Add package documentation on how to use the metadata package. Make it clear that any caching is up to the Func implemented. There are now - no in tree users. We could add the request metadata by default under names that copy request.Request, i.e request/ip - remote IP request/port - remote port Variables.go has been deleted. Signed-off-by: Miek Gieben <miek@miek.nl>
2018-06-30plugin/rewrite: cleanup (#1916)Gravatar Miek Gieben 5-112/+4
delete unused tests and fix import lines. Signed-off-by: Miek Gieben <miek@miek.nl>
2018-06-29plugin/metadata: some cleanups (#1906)Gravatar Miek Gieben 1-1/+2
* plugin/metadata: some cleanups Name to provider.go as that's what being defined right now in the file. Use request.Request because that's done in variables.go anyway. Name the main storage M, because there is no further meaning behind. Remove superfluous methods Signed-off-by: Miek Gieben <miek@miek.nl> * Fix test Signed-off-by: Miek Gieben <miek@miek.nl>
2018-06-29plugin/metadata: add metadata plugin (#1894)Gravatar Eugen Kleiner 7-130/+41
* plugin/metadata: add metadata plugin * plugin/metadata: Add MD struct, refactor code, fix doc * plugin/metadata: simplify metadata key * plugin/metadata: improve setup_test * Support of metadata by rewrite plugin. Move calculated variables to metadata. * Move variables from metadata to pkg, add UTs, READMEs change, metadata small fixes * Add client port validation to variables_test * plugin/metadata: improve README * plugin/metadata: rename methods * plugin/metadata: Update Metadataer interface, update doc, cosmetic code changes * plugin/metadata: move colllisions check to OnStartup(). Fix default variables metadataer. * plugin/metadata: Fix comment for method setValue * plugin/metadata: change variables order to fix linter warning * plugin/metadata: rename Metadataer to Provider
2018-06-18Plugin/Rewrite - review documentation of "append" (#1877)Gravatar Francois Tur 1-2/+2
* - ensure description of 'append' match what is encoded. * - fix description based on review comments
2018-05-24generate doc for 1.1.3 (#1832)Gravatar Miek Gieben 1-2/+3