plugin/bind: add zone for link-local IPv6 instead of skipping (#6547)

* add zone for link-local IPv6 instead of skipping

Signed-off-by: Till Riedel <riedel@teco.edu>

* revert changed error handling for IPs

Signed-off-by: Till Riedel <riedel@teco.edu>

---------

Signed-off-by: Till Riedel <riedel@teco.edu>
This commit is contained in:
Till Riedel 2024-10-01 15:47:56 +00:00 committed by GitHub
parent 144b0f5359
commit 6efa95ca98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -84,8 +84,15 @@ func listIP(args []string, ifaces []net.Interface) ([]string, error) {
}
for _, addr := range addrs {
if ipnet, ok := addr.(*net.IPNet); ok {
if ipnet.IP.To4() != nil || (!ipnet.IP.IsLinkLocalMulticast() && !ipnet.IP.IsLinkLocalUnicast()) {
all = append(all, ipnet.IP.String())
ipa, err := net.ResolveIPAddr("ip", ipnet.IP.String())
if err == nil {
if len(ipnet.IP) == net.IPv6len &&
(ipnet.IP.IsLinkLocalMulticast() || ipnet.IP.IsLinkLocalUnicast()) {
if ipa.Zone == "" {
ipa.Zone = iface.Name
}
}
all = append(all, ipa.String())
}
}
}