Skip to content

Commit

Permalink
[plugin/forward] Strip local zone from IPV6 nameservers (coredns#6635)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro de Brito Fontes <[email protected]>
  • Loading branch information
aledbf authored Apr 26, 2024
1 parent c15fe97 commit 5b6d8e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions plugin/forward/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ nameserver 10.10.255.253`), 0666); err != nil {
}
defer os.Remove(resolv)

const resolvIPV6 = "resolv-ipv6.conf"
if err := os.WriteFile(resolvIPV6,
[]byte(`nameserver 0388:d254:7aec:6892:9f7f:e93b:5806:1b0f%en0`), 0666); err != nil {
t.Fatalf("Failed to write %v file: %s", resolvIPV6, err)
}
defer os.Remove(resolvIPV6)

tests := []struct {
input string
shouldErr bool
Expand All @@ -153,6 +160,8 @@ nameserver 10.10.255.253`), 0666); err != nil {
{`forward . ` + resolv, false, "", []string{"10.10.255.252:53", "10.10.255.253:53"}},
// fail
{`forward . /dev/null`, true, "no nameservers", nil},
// IPV6 with local zone
{`forward . ` + resolvIPV6, false, "", []string{"[0388:d254:7aec:6892:9f7f:e93b:5806:1b0f]:53"}},
}

for i, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion plugin/pkg/parse/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func tryFile(s string) ([]string, error) {

servers := []string{}
for _, s := range c.Servers {
servers = append(servers, net.JoinHostPort(s, c.Port))
servers = append(servers, net.JoinHostPort(stripZone(s), c.Port))
}
return servers, nil
}
Expand Down

0 comments on commit 5b6d8e3

Please sign in to comment.