Add inline support for middleware/hosts (#1072)

This fix add inline support for middleware/hosts so that
it is possible to specify hosts file insides the Corefile:
```
hosts inline example.org {
    10.0.0.1 example.org
    fallthrough
}
```

This fix fixes 999.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2017-09-21 04:18:13 -07:00
committed by GitHub
parent aecf916377
commit 7109c6715c
5 changed files with 157 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ available hosts files that block access to advertising servers.
~~~
hosts [FILE [ZONES...]] {
[INLINE]
fallthrough
}
~~~
@@ -18,7 +19,10 @@ hosts [FILE [ZONES...]] {
* **FILE** the hosts file to read and parse. If the path is relative the path from the *root*
directive will be prepended to it. Defaults to /etc/hosts if omitted
* **ZONES** zones it should be authoritative for. If empty, the zones from the configuration block
are used.
are used.
* **INLINE** the hosts file contents inlined in Corefile. If there are any lines before fallthrough
then all of them will be treated as the additional content for hosts file. The specified hosts
file path will still be read but entries will be overrided.
* `fallthrough` If zone matches and no record can be generated, pass request to the next plugin.
## Examples
@@ -43,3 +47,12 @@ hosts example.hosts example.org example.net {
fallthrough
}
~~~
Load hosts file inlined in Corefile.
~~~
hosts example.hosts example.org {
10.0.0.1 example.org
fallthrough
}
~~~