mirror of
https://github.com/sony/sonyflake.git
synced 2026-12-01 01:29:31 +00:00
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 <f.crisciani@gmail.com>
This commit is contained in:
1 parent
fc2f84a086
commit
a0558cef64
1 file changed
+2
-1
+2
-1
@@ -178,8 +178,9 @@ func privateIPv4(interfaceAddrs types.InterfaceAddrs) (net.IP, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isPrivateIPv4(ip net.IP) bool {
|
func isPrivateIPv4(ip net.IP) bool {
|
||||||
|
// Allow private IP addresses (RFC1918) and link-local addresses (RFC3927)
|
||||||
return ip != nil &&
|
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) {
|
func lower16BitPrivateIP(interfaceAddrs types.InterfaceAddrs) (uint16, error) {
|
||||||
|
|||||||
Reference in new issue
Block a user