aboutsummaryrefslogtreecommitdiff
path: root/plugin/rewrite/rewrite.go (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-04-13[rewrite] Introduce cname target rewrite rule to rewrite plugin (#6004)Gravatar Amila Senadheera 1-0/+2
* 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-06-26Fix out-of-index issue in rewrite plugin (#5462)Gravatar Yong Tang 1-0/+3
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 1-0/+3
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 1-1/+4
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-05-04plugin/rewrite: streamline the ResponseRule handling. (#4473)Gravatar Uwe Krueger 1-21/+13
* 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-23Rewrite SRV targets and additional names in response (#4287)Gravatar slick-nic 1-6/+7
* 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>
2019-10-01Run gostaticheck (#3325)Gravatar Miek Gieben 1-1/+0
* 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-26fix mis-spelling (#3310)Gravatar xieyanker 1-1/+1
Signed-off-by: xieyanker <xjsisnice@gmail.com>
2019-07-12plugin/rewrite: fix domain length validation (#2995)Gravatar Ruslan Drozhdzh 1-4/+3
* unit test * fix domain length validation * code optimization * remove unit test
2019-06-25Run gofmt -s and golint on the codebase (#2918)Gravatar Miek Gieben 1-2/+2
* 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>
2018-08-29plugin/rewrite: add handling of TTL field rewrites (#2048)Gravatar Paul G 1-9/+10
Resolves: #1981 Signed-off-by: Paul Greenberg <greenpau@outlook.com>
2018-07-13plugin/rewrite: prevent illegal names (#1972)Gravatar Miek Gieben 1-0/+7
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-08plugin/rewrite - extend edns0 local variable support with metadata (#1928)Gravatar Francois Tur 1-2/+2
* - 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 1-2/+5
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 1-2/+2
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 1-8/+0
delete unused tests and fix import lines. Signed-off-by: Miek Gieben <miek@miek.nl>
2018-06-29plugin/metadata: add metadata plugin (#1894)Gravatar Eugen Kleiner 1-2/+2
* 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-04-27plugin/rewrite: handle continue in response rewrite (#1740)Gravatar Chris O'Haver 1-1/+4
* handle continue in response rewrite * add test
2018-04-25plugin/rewrite: tweak parse error messaging, add tests (#1737)Gravatar Chris O'Haver 1-1/+6
* tweak parse error messaging, add tests * looser err msg checking
2018-04-22all: fix plugin import ordering (#1717)Gravatar Miek Gieben 1-2/+1
Got a bit messed up with stb lib "context" usage.
2018-04-20global: move to context (#1699)Gravatar Miek Gieben 1-1/+1
* 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-01-18feature: plugin/rewrite: rewrite ANSWER SECTION (#1318)Gravatar Paul Greenberg 1-1/+8
Resolves: #1313
2017-12-14plugin/rewrite: fix flow control logic for all rule types (#1308)Gravatar Paul Greenberg 1-2/+2
Resolves: #1307
2017-12-13plugin/rewrite: regular expression and substring match/replace (#1296) (#1297)Gravatar Paul Greenberg 1-2/+2
2017-09-22go lint/vet/misspell cleanup (#1105)Gravatar Yong Tang 1-1/+1
This fix address several issues related to golint/vet/misspell. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-09-20Modify the rewrite plugin to write multiple EDNS0 options (#936) (#1096)Gravatar Thong Huynh 1-9/+41
* Add processing mode * Add processing mode * Update UTs * Update README.md * Change to use the constant Stop * Fix README per review comments
2017-09-14Remove the word middleware (#1067)Gravatar Miek Gieben 1-0/+86
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat