Files
waf-platform/EdgeHttpDNS/internal/utils/ip.go
2026-03-22 17:37:40 +08:00

22 lines
271 B
Go

package utils
import (
"encoding/binary"
"net"
)
func IP2Long(ip string) uint32 {
s := net.ParseIP(ip)
if s == nil {
return 0
}
if len(s) == 16 {
return binary.BigEndian.Uint32(s[12:16])
}
if len(s) < 4 {
return 0
}
return binary.BigEndian.Uint32(s)
}