plugin/rewrite: Add EDNS0 Unset Action (#7380)

* plugin/rewrite: EDNS0 unset action

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* plugin/rewrite: EDNS0 unset tests

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* plugin/rewrite: EDNS0 unset documentation

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* gofmt whitespace fixes

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

* plugin/rewrite: improve edns0 test coverage

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>

---------

Signed-off-by: Dennis Simmons <215134900+dennis-ix@users.noreply.github.com>
This commit is contained in:
Dennis Simmons
2025-06-20 00:49:37 +03:00
committed by GitHub
parent 9c51e1741c
commit b2a2a5f648
3 changed files with 178 additions and 2 deletions

View File

@@ -394,11 +394,12 @@ The values of FROM and TO can be any of the following, text value or numeric:
## EDNS0 Options
Using the FIELD edns0, you can set, append, or replace specific EDNS0 options in the request.
Using the FIELD edns0, you can set, append, replace, or unset specific EDNS0 options in the request.
* `replace` will modify any "matching" option with the specified option. The criteria for "matching" varies based on EDNS0 type.
* `append` will add the option only if no matching option exists
* `set` will modify a matching option or add one if none is found
* `unset` will remove the matching option if one exists
Currently supported are `EDNS0_LOCAL`, `EDNS0_NSID` and `EDNS0_SUBNET`.
@@ -444,10 +445,17 @@ some-plugin
rewrite edns0 local set 0xffee {some-plugin/some-label}
~~~
A local option may be removed by unsetting its code. Example:
~~~
rewrite edns0 local unset 0xffee
~~~
### EDNS0_NSID
This has no fields; it will add an NSID option with an empty string for the NSID. If the option already exists
and the action is `replace` or `set`, then the NSID in the option will be set to the empty string.
and the action is `replace` or `set`, then the NSID in the option will be set to the empty string.
The option can be removed with the `unset` action.
### EDNS0_SUBNET
@@ -463,6 +471,12 @@ rewrite edns0 subnet set 24 56
* If the query's source IP address is an IPv4 address, the first 24 bits in the IP will be the network subnet.
* If the query's source IP address is an IPv6 address, the first 56 bits in the IP will be the network subnet.
This option can be removed by using `unset`:
~~~
rewrite edns0 subnet unset
~~~
### EDNS0 Revert
Using the `revert` flag, you can revert the changes made by this rewrite call, so the response will not contain this option.