From 9037ea369bae063a4daaaac64c0c4777f55990cc Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Sun, 5 Nov 2023 22:43:49 -0700 Subject: [PATCH] Allow IPv4 Link Local addresses (#50) * Allow IPv4 Link Local addresses Allow the use of link local addresses * Update sonyflake.go * Update sonyflake.go --- sonyflake.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonyflake.go b/sonyflake.go index 548b243..c88c464 100644 --- a/sonyflake.go +++ b/sonyflake.go @@ -178,8 +178,9 @@ func privateIPv4(interfaceAddrs types.InterfaceAddrs) (net.IP, error) { } func isPrivateIPv4(ip net.IP) bool { + // Allow private IP subnets (RFC1918) or link local (RFC3927) return ip != nil && - (ip[0] == 10 || ip[0] == 172 && (ip[1] >= 16 && ip[1] < 32) || ip[0] == 192 && ip[1] == 168) + (ip[0] == 10 || ip[0] == 172 && (ip[1] >= 16 && ip[1] < 32) || ip[0] == 192 && ip[1] == 168 || ip[0] == 169 && ip[1] == 254) } func lower16BitPrivateIP(interfaceAddrs types.InterfaceAddrs) (uint16, error) {