From f65f1d850f6ae7a4115605f2892a2f69cdfb5bc5 Mon Sep 17 00:00:00 2001 From: WofWca Date: Thu, 21 Nov 2024 17:31:56 +0400 Subject: [PATCH] improvement: use IsLinkLocalUnicast in IsLocal Looking at the code, this commit appears to change behavior, because `IsLocal` will now return `true` for IPv6 link-local unicast addresses. --- common/util/util.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/util/util.go b/common/util/util.go index 57170cf..a180692 100644 --- a/common/util/util.go +++ b/common/util/util.go @@ -60,15 +60,15 @@ func IsLocal(ip net.IP) bool { if ip.IsPrivate() { return true } + // Dynamic Configuration as per https://tools.ietf.org/htm/rfc3927 + if ip.IsLinkLocalUnicast() { + return true + } if ip4 := ip.To4(); ip4 != nil { // Carrier-Grade NAT as per https://tools.ietf.org/htm/rfc6598 if ip4[0] == 100 && ip4[1]&0xc0 == 64 { return true } - // Dynamic Configuration as per https://tools.ietf.org/htm/rfc3927 - if ip4[0] == 169 && ip4[1] == 254 { - return true - } } return false }