Add set EDNS0 with variable substitution (#937)

* Add set EDNS0 with variable substitution

* Change variable from $ to {}. Un-export constants

* Update README

* Change getRuleData() to ruleData(); Change to use string match from regexp
This commit is contained in:
Thong Huynh
2017-08-24 09:34:07 -07:00
committed by Miek Gieben
parent 5e9991556e
commit 3f05f7e6c0
7 changed files with 304 additions and 10 deletions

View File

@@ -41,8 +41,9 @@ Currently supported are `EDNS0_LOCAL` and `EDNS0_NSID`.
### `EDNS0_LOCAL`
This has two fields, code and data. A match is defined as having the same code. Data may be a string, or if
it starts with `0x` it will be treated as hex. Example:
This has two fields, code and data. A match is defined as having the same code. Data may be a string or a variable.
* A string data can be treated as hex if it starts with `0x`. Example:
~~~
rewrite edns0 local set 0xffee 0x61626364
@@ -54,6 +55,21 @@ rewrites the first local option with code 0xffee, setting the data to "abcd". Eq
rewrite edns0 local set 0xffee abcd
~~~
* A variable data is specified with a pair of curly brackets `{}`. Following are the supported variables:
* {qname}
* {qtype}
* {client_ip}
* {client_port}
* {protocol}
* {server_ip}
* {server_port}
Example:
~~~
rewrite edns0 local set 0xffee {client_ip}
~~~
### `EDNS0_NSID`
This has no fields; it will add an NSID option with an empty string for the NSID. If the option already exists