Skip to content

Commit

Permalink
Allow IPv4 Link Local addresses (#50)
Browse files Browse the repository at this point in the history
* Allow IPv4 Link Local addresses

Allow the use of link local addresses

* Update sonyflake.go

* Update sonyflake.go
  • Loading branch information
fcrisciani authored Nov 6, 2023
1 parent fc2f84a commit 9037ea3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sonyflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9037ea3

Please sign in to comment.