plugin/hosts: create inline map in setup (#3071)

* plugin/hosts: create inline map in setup

The inline map wasn't create in the setup.go fuction leading to a crash,
which is masked by a recover (but leads to a SERVFAIL, and not logging
the request).

Various other simplifications.

host plugin could use some test that actually cover these edgecases.

Signed-off-by: Miek Gieben <miek@miek.nl>

* PR review changes

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2019-07-31 19:37:09 +00:00
committed by GitHub
parent 45e17c325c
commit 07f016191d
3 changed files with 23 additions and 28 deletions

View File

@@ -15,6 +15,9 @@ The plugin reloads the content of the hosts file every 5 seconds. Upon reload, C
new definitions. Should the file be deleted, any inlined content will continue to be served. When
the file is restored, it will then again be used.
If you want to pass the request to the rest of the plugin chain if there is no match in the *hosts*
plugin, you must specify the `fallthrough` option.
This plugin can only be used once per Server Block.
## The hosts file
@@ -60,7 +63,9 @@ hosts [FILE [ZONES...]] {
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 overridden.
* `ttl` change the DNS TTL of the records generated (forward and reverse). The default is 3600 seconds (1 hour).
* `reload` change the period between each hostsfile reload. A time of zero seconds disable the feature. Examples of valid durations: "300ms", "1.5h" or "2h45m" are valid duration with units "ns" (nanosecond), "us" (or "µs" for microsecond), "ms" (millisecond), "s" (second), "m" (minute), "h" (hour).
* `reload` change the period between each hostsfile reload. A time of zero seconds disables the
feature. Examples of valid durations: "300ms", "1.5h" or "2h45m". See Go's
[time](https://godoc.org/time). package.
* `no_reverse` disable the automatic generation of the `in-addr.arpa` or `ip6.arpa` entries for the hosts
* `fallthrough` If zone matches and no record can be generated, pass request to the next plugin.
If **[ZONES...]** is omitted, then fallthrough happens for all zones for which the plugin