19 lines
413 B
Go
19 lines
413 B
Go
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
|
|
package netpackets
|
|
|
|
// IsLocalRawIPv4 使用原始IP数据判断是否为本地IPv4
|
|
func IsLocalRawIPv4(ip []byte) bool {
|
|
if len(ip) != 4 {
|
|
return false
|
|
}
|
|
if ip[0] == 127 ||
|
|
ip[0] == 10 ||
|
|
(ip[0] == 172 && ip[1]&0xf0 == 16) ||
|
|
(ip[0] == 192 && ip[1] == 168) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|