Skip to content

Commit a0558ce

Browse files
Link local (#53)
* Allow IPv4 Link Local addresses (#50) * Allow IPv4 Link Local addresses Allow the use of link local addresses * Update sonyflake.go * Update sonyflake.go * Update a comment --------- Co-authored-by: Flavio Crisciani <[email protected]>
1 parent fc2f84a commit a0558ce

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: sonyflake.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ func privateIPv4(interfaceAddrs types.InterfaceAddrs) (net.IP, error) {
178178
}
179179

180180
func isPrivateIPv4(ip net.IP) bool {
181+
// Allow private IP addresses (RFC1918) and link-local addresses (RFC3927)
181182
return ip != nil &&
182-
(ip[0] == 10 || ip[0] == 172 && (ip[1] >= 16 && ip[1] < 32) || ip[0] == 192 && ip[1] == 168)
183+
(ip[0] == 10 || ip[0] == 172 && (ip[1] >= 16 && ip[1] < 32) || ip[0] == 192 && ip[1] == 168 || ip[0] == 169 && ip[1] == 254)
183184
}
184185

185186
func lower16BitPrivateIP(interfaceAddrs types.InterfaceAddrs) (uint16, error) {

0 commit comments

Comments
 (0)