mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-08 10:46:37 +08:00
19 lines
296 B
Go
19 lines
296 B
Go
package builtins
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
func MatchCIDR(ip string, cidr *net.IPNet) bool {
|
|
ipAddr := net.ParseIP(ip)
|
|
if ipAddr == nil {
|
|
return false
|
|
}
|
|
return cidr.Contains(ipAddr)
|
|
}
|
|
|
|
func CompileCIDR(cidr string) (*net.IPNet, error) {
|
|
_, ipNet, err := net.ParseCIDR(cidr)
|
|
return ipNet, err
|
|
}
|