mirror of
https://github.com/coredns/coredns.git
synced 2026-07-16 20:50:11 -04:00
fix: accept scoped IPv6 addresses in transfer targets (#8204)
Signed-off-by: immanuwell <pchpr.00@list.ru>
This commit is contained in:
committed by
GitHub
parent
69e7a4be73
commit
45a20ddcf1
@@ -113,13 +113,13 @@ func HostPort(s, defaultPort string) (string, error) {
|
|||||||
port = defaultPort
|
port = defaultPort
|
||||||
}
|
}
|
||||||
if err != nil {
|
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 "", fmt.Errorf("must specify an IP address: `%s'", s)
|
||||||
}
|
}
|
||||||
return net.JoinHostPort(s, port), nil
|
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 "", fmt.Errorf("must specify an IP address: `%s'", addr)
|
||||||
}
|
}
|
||||||
return net.JoinHostPort(addr, port), nil
|
return net.JoinHostPort(addr, port), nil
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ func TestParseHostPort(t *testing.T) {
|
|||||||
{"8.8.8.8:", "8.8.8.8:53", false},
|
{"8.8.8.8:", "8.8.8.8:53", false},
|
||||||
{"8.8.8.8::53", "", true},
|
{"8.8.8.8::53", "", true},
|
||||||
{"resolv.conf", "", 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 {
|
for i, tc := range tests {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func TestParse(t *testing.T) {
|
|||||||
exp *Transfer
|
exp *Transfer
|
||||||
}{
|
}{
|
||||||
{`transfer example.net example.org {
|
{`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 {
|
transfer example.com example.edu {
|
||||||
to * 1.2.3.4
|
to * 1.2.3.4
|
||||||
@@ -24,7 +24,7 @@ func TestParse(t *testing.T) {
|
|||||||
&Transfer{
|
&Transfer{
|
||||||
xfrs: []*xfr{{
|
xfrs: []*xfr{{
|
||||||
Zones: []string{"example.net.", "example.org."},
|
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."},
|
Zones: []string{"example.com.", "example.edu."},
|
||||||
to: []string{"*", "1.2.3.4:53"},
|
to: []string{"*", "1.2.3.4:53"},
|
||||||
|
|||||||
Reference in New Issue
Block a user