Commit Graph

14 Commits

Author SHA1 Message Date
Yong Tang
d5c1188843 plugin/rewrite: Limit rewrite cname recursion (#8570)
This PR limit rewrite cname recursion with the existing DNS server loop counter.
The issu was that rewrite cname can recurse indefinitely through internal lookups, causing crash at the end

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-09-22 06:23:20 -07:00
Ncesam
e1f4d0cb90 plugin/rewrite: normalize exact cname rewrite targets and preserve all records (#8285)
Signed-off-by: ncesam <rybushkin09@bk.ru>
2026-07-15 18:06:03 -07:00
Ville Vesilehto
6af8fd46fe lint(revive): fix unnecessary-stmt violations (#7978) 2026-03-29 17:02:03 -07:00
hide
78524a7921 fix(rewrite): fix cname target rewrite for CNAME chains (#7853)
* fix(rewrite): fix cname target rewrite for CNAME chains

This fix corrects the cname target rewrite to handle CNAME chains:
- Preserves only the CNAME records before matching the rule
- Rewrites only the CNAME target that matches the rule
- Includes all records from the re-resolved upstream response

Signed-off-by: hide <hide@hide.net.eu.org>

* docs(rewrite): document how answer records are handled in CNAME target rewrite

Signed-off-by: hide <hide@hide.net.eu.org>

* fix(rewrite): simplify slice append per staticcheck S1011

Signed-off-by: hide <hide@hide.net.eu.org>

* docs(rewrite): add extra line between code and paragraph

Signed-off-by: hide <hide@hide.net.eu.org>

---------

Signed-off-by: hide <hide@hide.net.eu.org>
Co-authored-by: hide <hide@hide.net.eu.org>
2026-02-21 16:10:35 -05:00
Ville Vesilehto
b723bd94d4 fix(plugins): add regex length limit (#7802) 2026-01-05 09:48:48 -08:00
Charlie Vieth
2883b6340f plugin/rewrite: pre-compile CNMAE rewrite regexp (#7697)
This commit changes the CNAME rewrite rule to use a pre-compiled regexp
when the match type is RegexMatch instead of compiling it on-the-fly for
each request. This will also allow for invalid regexp patterns to be
identified during setup instead of causing a panic when the rule is
first invoked.

Signed-off-by: Charlie Vieth <charlie.vieth@gmail.com>
2025-11-19 22:27:29 -05:00
Ville Vesilehto
5cf4c80ac0 chore(lint): update to golangci-lint v2.6.0 (#7645)
Update to the latest golangci-lint version and use built-in modernize
linter, instead of a custom CI step.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-10-30 14:07:16 +02:00
Ville Vesilehto
39abf5aeba chore(lint): modernize Go (#7536)
Use modern Go constructs through the modernize analyzer from the
golang.org/x/tools package.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-09-10 13:08:27 -07:00
Ville Vesilehto
1ea6a7f682 fix(plugin): guard nil lookups across plugins (#7494) 2025-09-02 13:46:47 -07:00
Yannick Epstein
13da7f749c fix(rewrite): truncated upstream response (#7277)
Forward information that a upstream response is truncated when rewriting
a CNAME. Otherwise, the cache plugin stores the truncated resonse,
making it impossible to receive the full response as a client via TCP.

Signed-off-by: Yannick Epstein <yannicke@spotify.com>
2025-05-01 10:59:15 -04:00
Manuel Rüger
76ba39ffe9 chore: Upgrade to golangci-lint v2 (#7236)
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2025-04-04 14:27:39 -04:00
Amila Senadheera
ff40400065 rewrite: fix multi request concurrency issue in cname rewrite (#6407)
* fix concurrent issue with cname rewrite plugin

Signed-off-by: amila <amila.15@cse.mrt.ac.lk>

* add nil check before deref, add AAAA type test case

Signed-off-by: amila <amila.15@cse.mrt.ac.lk>

---------

Signed-off-by: amila <amila.15@cse.mrt.ac.lk>
2023-12-09 07:53:52 -05:00
Zhizhen He
2fe5890d8b Fix typos (#6235)
* Fix typos and add todo to fix spelling of dnsutil.MaximumDefaulTTL

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-08-10 11:06:48 -04:00
Amila Senadheera
8e8231d627 [rewrite] Introduce cname target rewrite rule to rewrite plugin (#6004)
* 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>
2023-04-13 08:19:36 -04:00