Initial commit (code only without large binaries)
This commit is contained in:
18
EdgeNode/internal/utils/netpackets/utils.go
Normal file
18
EdgeNode/internal/utils/netpackets/utils.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user