Files
waf-platform/EdgeHttpDNS/internal/utils/ip.go
2026-02-27 10:35:22 +08:00

19 lines
240 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])
}
return binary.BigEndian.Uint32(s)
}