From 3caf8a34d6a9f5eabbbfd3474f4a5e9a3ec40787 Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Mon, 30 Oct 2023 13:20:30 -0600 Subject: [PATCH 1/3] Allow IPv4 Link Local addresses Allow the use of link local addresses --- sonyflake.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonyflake.go b/sonyflake.go index 548b243..ba40e33 100644 --- a/sonyflake.go +++ b/sonyflake.go @@ -179,7 +179,7 @@ func privateIPv4(interfaceAddrs types.InterfaceAddrs) (net.IP, error) { func isPrivateIPv4(ip net.IP) bool { 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] == 269 && ip[1] == 254) } func lower16BitPrivateIP(interfaceAddrs types.InterfaceAddrs) (uint16, error) { From ee72e724204af32aebf077ecc6d690d98e2f9823 Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Mon, 30 Oct 2023 13:43:18 -0600 Subject: [PATCH 2/3] Update sonyflake.go --- sonyflake.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonyflake.go b/sonyflake.go index ba40e33..5d0c79f 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 (RFC 3927) return ip != nil && - (ip[0] == 10 || ip[0] == 172 && (ip[1] >= 16 && ip[1] < 32) || ip[0] == 192 && ip[1] == 168 || ip[0] == 269 && ip[1] == 254) + (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) { From 3850ccbdbd49a78fc7344b254c3f6c19f07f6f29 Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Mon, 30 Oct 2023 13:43:52 -0600 Subject: [PATCH 3/3] Update sonyflake.go --- sonyflake.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonyflake.go b/sonyflake.go index 5d0c79f..c88c464 100644 --- a/sonyflake.go +++ b/sonyflake.go @@ -178,7 +178,7 @@ func privateIPv4(interfaceAddrs types.InterfaceAddrs) (net.IP, error) { } func isPrivateIPv4(ip net.IP) bool { - // Allow private IP subnets (RFC1918) or link local (RFC 3927) + // 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] == 169 && ip[1] == 254) }