mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
plugin/host: don't append the names when reparsing hosts file (#3045)
The host plugin kept on adding entries instead of overwriting. Split the inline cache off from the /etc/hosts file cache and clear /etc/hosts file cache and re-parsing. A bunch of other cleanup as well. Use functions defined in the plugin package, don't re-parse strings if you don't have to and use To4() to check the family for IP addresses. Fix all test cases a carried entries are always fqdn-ed. Various smaller cleanup in unnessacry constants. Fixes: #3014 Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -2,7 +2,6 @@ package hosts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -12,20 +11,17 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
func (h *Hostsfile) parseReader(r io.Reader) {
|
||||
h.hmap = h.parse(r)
|
||||
}
|
||||
|
||||
func TestLookupA(t *testing.T) {
|
||||
h := Hosts{
|
||||
Next: test.ErrorHandler(),
|
||||
Hostsfile: &Hostsfile{
|
||||
Origins: []string{"."},
|
||||
hmap: newHostsMap(),
|
||||
hmap: newMap(),
|
||||
inline: newMap(),
|
||||
options: newOptions(),
|
||||
},
|
||||
}
|
||||
h.parseReader(strings.NewReader(hostsExample))
|
||||
h.hmap = h.parse(strings.NewReader(hostsExample))
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user