From 45a20ddcf1d36acdb2277b5131f1d29002ad993b Mon Sep 17 00:00:00 2001 From: Immanuel Tikhonov <122638311+immanuwell@users.noreply.github.com> Date: Sun, 28 Jun 2026 09:26:12 +0400 Subject: [PATCH] fix: accept scoped IPv6 addresses in transfer targets (#8204) Signed-off-by: immanuwell --- plugin/pkg/parse/host.go | 4 ++-- plugin/pkg/parse/host_test.go | 2 ++ plugin/transfer/setup_test.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/pkg/parse/host.go b/plugin/pkg/parse/host.go index f3f750aa7..029d4f258 100644 --- a/plugin/pkg/parse/host.go +++ b/plugin/pkg/parse/host.go @@ -113,13 +113,13 @@ func HostPort(s, defaultPort string) (string, error) { port = defaultPort } if err != nil { - if net.ParseIP(s) == nil { + if net.ParseIP(stripZone(s)) == nil { return "", fmt.Errorf("must specify an IP address: `%s'", s) } return net.JoinHostPort(s, port), nil } - if net.ParseIP(addr) == nil { + if net.ParseIP(stripZone(addr)) == nil { return "", fmt.Errorf("must specify an IP address: `%s'", addr) } return net.JoinHostPort(addr, port), nil diff --git a/plugin/pkg/parse/host_test.go b/plugin/pkg/parse/host_test.go index 0b5f6f1ff..a1063fdfe 100644 --- a/plugin/pkg/parse/host_test.go +++ b/plugin/pkg/parse/host_test.go @@ -103,6 +103,8 @@ func TestParseHostPort(t *testing.T) { {"8.8.8.8:", "8.8.8.8:53", false}, {"8.8.8.8::53", "", true}, {"resolv.conf", "", true}, + {"fe80::1%ens3", "[fe80::1%ens3]:53", false}, + {"[fd01::1%ens3]:153", "[fd01::1%ens3]:153", false}, } for i, tc := range tests { diff --git a/plugin/transfer/setup_test.go b/plugin/transfer/setup_test.go index ebfe99c06..a0eb39f87 100644 --- a/plugin/transfer/setup_test.go +++ b/plugin/transfer/setup_test.go @@ -14,7 +14,7 @@ func TestParse(t *testing.T) { exp *Transfer }{ {`transfer example.net example.org { - to 1.2.3.4 5.6.7.8:1053 [1::2]:34 + to 1.2.3.4 5.6.7.8:1053 [1::2]:34 [fe80::1%eth0]:53 } transfer example.com example.edu { to * 1.2.3.4 @@ -24,7 +24,7 @@ func TestParse(t *testing.T) { &Transfer{ xfrs: []*xfr{{ Zones: []string{"example.net.", "example.org."}, - to: []string{"1.2.3.4:53", "5.6.7.8:1053", "[1::2]:34"}, + to: []string{"1.2.3.4:53", "5.6.7.8:1053", "[1::2]:34", "[fe80::1%eth0]:53"}, }, { Zones: []string{"example.com.", "example.edu."}, to: []string{"*", "1.2.3.4:53"},