MCPcopy Create free account
hub / github.com/cel-expr/cel-go / parseCIDR

Function parseCIDR

ext/network.go:480–492  ·  view source on GitHub ↗
(raw string)

Source from the content-addressed store, hash-verified

478}
479
480func parseCIDR(raw string) (netip.Prefix, error) {
481 prefix, err := netip.ParsePrefix(raw)
482 if err != nil {
483 return netip.Prefix{}, fmt.Errorf("CIDR %q parse error during conversion from string: %v", raw, err)
484 }
485 if prefix.Addr().Zone() != "" {
486 return netip.Prefix{}, fmt.Errorf("CIDR %q with zone value is not allowed", raw)
487 }
488 if prefix.Addr().Is4In6() {
489 return netip.Prefix{}, fmt.Errorf("IPv4-mapped IPv6 address %q is not allowed", raw)
490 }
491 return prefix, nil
492}
493
494func parseIPAddr(raw string) (netip.Addr, error) {
495 addr, err := netip.ParseAddr(raw)

Callers 4

netCIDRStringFunction · 0.85
netIsCIDRFunction · 0.85
checkCIDRFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected