From 40edf1e566a0b3709139420aeba542d9b788b1d0 Mon Sep 17 00:00:00 2001 From: Uwe Krueger Date: Tue, 4 May 2021 10:05:45 +0200 Subject: plugin/rewrite: streamline the ResponseRule handling. (#4473) * 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 * revert policy Signed-off-by: Uwe Krueger Co-authored-by: Miek Gieben --- plugin/rewrite/class.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'plugin/rewrite/class.go') diff --git a/plugin/rewrite/class.go b/plugin/rewrite/class.go index 178cf8181..243a86449 100644 --- a/plugin/rewrite/class.go +++ b/plugin/rewrite/class.go @@ -30,18 +30,15 @@ func newClassRule(nextAction string, args ...string) (Rule, error) { } // Rewrite rewrites the current request. -func (rule *classRule) Rewrite(ctx context.Context, state request.Request) Result { +func (rule *classRule) Rewrite(ctx context.Context, state request.Request) (ResponseRules, Result) { if rule.fromClass > 0 && rule.toClass > 0 { if state.Req.Question[0].Qclass == rule.fromClass { state.Req.Question[0].Qclass = rule.toClass - return RewriteDone + return nil, RewriteDone } } - return RewriteIgnored + return nil, RewriteIgnored } // Mode returns the processing mode. func (rule *classRule) Mode() string { return rule.NextAction } - -// GetResponseRules return rules to rewrite the response with. Currently not implemented. -func (rule *classRule) GetResponseRules() []ResponseRule { return []ResponseRule{} } -- cgit v1.2.3 ing-length'>dave/bundler-string-length Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2022-08-21[breaking] `bun run <missing script>` should return a nonzero exit codeGravatar Jarred Sumner 1-1/+5
2022-08-21Support loading JavaScript files without extensionsGravatar Jarred Sumner 1-1/+7
2022-08-21Add a bench snippet for sha512Gravatar Jarred Sumner 3-0/+23
2022-08-21Remove usage of `fnctl64` so we can avoid the libc symbolGravatar Jarred Sumner 2-62/+83
2022-08-21Add a binding for creating atomic stringsGravatar Jarred Sumner 5-2/+37
2022-08-21Slightly optimize escapeHTMLescapeHTML8 & escapeHTML16Gravatar Jarred Sumner 2-80/+134
2022-08-20Update WebKitGravatar Jarred Sumner 1-0/+0
2022-08-20Export `createSyntheticModule`Gravatar Jarred Sumner 3-1/+22
2022-08-20wip support #!Gravatar Jarred Sumner 1-1/+6
2022-08-20fix(ReferenceError): expected type in getCode (#1120)Gravatar Hyro 1-1/+1
2022-08-20Fix running zig testsGravatar Jarred Sumner 1-3/+10
2022-08-20Fix crash on invalid JSXGravatar Jarred Sumner 1-1/+1
2022-08-20Add `code` to `ResolveError`Gravatar Jarred Sumner 1-0/+14
2022-08-20Add buffer.indexOf, includes and lastIndexOf (#1112)Gravatar Zilin Zhu 2-32/+237
2022-08-19fix buffer.slice(0, 0) (#1114)Gravatar Zilin Zhu 23-27/+58
2022-08-19fix buffer.copy (#1113)Gravatar Zilin Zhu 2-21/+35
2022-08-19Update build-idGravatar Jarred Sumner 1-1/+1
2022-08-19Make React SSR up to 3x fasterGravatar Jarred Sumner 1-238/+247
2022-08-192x faster `Bun.serve` with async function handlersGravatar Jarred Sumner 1-4/+13
2022-08-19Update bun init testbun-v0.1.10Gravatar Jarred Sumner 1-2/+2
2022-08-18Synchronously dispatch `close` eventGravatar Jarred Sumner 1-0/+5
2022-08-18Fix memory leak in `WebSocket`Gravatar Jarred Sumner 1-13/+4
2022-08-18Make `Request`, `Response` and `TextDecoder` not read-onlyGravatar Jarred Sumner 7-120/+180
2022-08-18Update build-idGravatar Jarred Sumner 1-1/+1
2022-08-18un-delete some codeGravatar Jarred Sumner 2-8/+15
2022-08-18Add string support to `Buffer.fill`Gravatar Jarred Sumner 7-77/+119
2022-08-18[node compat] Fix issue with `Buffer.compare` when called on the constructorGravatar Jarred Sumner 1-31/+42
2022-08-18Fix console.log printing `[native code]` for too many thingsGravatar Jarred Sumner 1-1/+6
2022-08-18Faster TextDecoderGravatar Jarred Sumner 24-369/+399
2022-08-18Fix Next.js regressionGravatar Jarred Sumner 1-12/+45
2022-08-18Fix `bun:wrap` not loadingGravatar Jarred Sumner 3-21/+41