aboutsummaryrefslogtreecommitdiff
path: root/plugin/rewrite (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-08-10Fix typos (#6235)Gravatar Zhizhen He 2-2/+2
* Fix typos and add todo to fix spelling of dnsutil.MaximumDefaulTTL Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-04-13[rewrite] Introduce cname target rewrite rule to rewrite plugin (#6004)Gravatar Amila Senadheera 7-5/+362
* cname target rewrite part in answer sec tion Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * upstream request Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * fix looping issue Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * support exact, prefix, suffix, substring, and regex types for cname rewrite Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * support any qtype, corrected prefix, suffix, substring types behavior Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * unit tests added, mocked the upstream call Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * fix lint errors Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * add newline to fix test issue Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * add default rewrite type, add readme Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * readme grammar fix Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * reuse rewrite types Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * comment fixed Signed-off-by: amila <amila.15@cse.mrt.ac.lk> --------- Signed-off-by: amila <amila.15@cse.mrt.ac.lk>
2022-09-08plugin/view: Advanced routing interface and new 'view' plugin (#5538)Gravatar Chris O'Haver 1-1/+1
* introduce new interface "dnsserver.Viewer", that allows a plugin implementing it to decide if a query should be routed into its server block. * add new plugin "view", that uses the new interface to enable a user to define expression based conditions that must be met for a query to be routed to its server block. Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-08-17plugin/rewrite: Allow configuring min and max TTL values when rewriting TTL ↵Gravatar AndreasHuber-CH 3-23/+93
(#5508)
2022-08-14Add PTR records to supported types (#5565)Gravatar Alex 2-1/+43
* Add PTR records to supported types Signed-off-by: Alex Bulatov <xbulat@gmail.com> * Add extra line Signed-off-by: Alex Bulatov <xbulat@gmail.com> * Fix title Signed-off-by: Alex Bulatov <xbulat@gmail.com> Signed-off-by: Alex Bulatov <xbulat@gmail.com>
2022-07-21remove redundant continue in test (#5529)Gravatar Abirdcfly 1-1/+0
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-07-10add golangci-lint linter (#5499)Gravatar Ondřej Benkovský 6-14/+0
2022-06-26Fix out-of-index issue in rewrite plugin (#5462)Gravatar Yong Tang 2-0/+4
This PR fixes another out-of-index issue in rewrite to avoid security vuln. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-06-25Fix a crash in rewrite plugin when rule type is missing (#5459)Gravatar Yong Tang 2-47/+35
2022-03-18update all +build statements (#5271)Gravatar Qasim Sarfraz 1-1/+1
* 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-01[plugin/rewrite] Refactor to satisfy security scan (#5214)Gravatar Yong Tang 1-7/+8
this PR re-arrange the logic to avoid a false positive DAST scan. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-02-01plugin/rewrite: Write failures with ResponseReverter (#5150)Gravatar Chris O'Haver 1-1/+11
* write failures with ResponseReverter instead of letting server write them Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix comment Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-08-31restore 1.8.3 question revert logic; add tests (#4840)Gravatar Chris O'Haver 2-1/+57
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
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