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

Function parseCIDR

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

Source from the content-addressed store, hash-verified

504}
505
506func parseCIDR(raw string) (netip.Prefix, error) {
507 prefix, err := netip.ParsePrefix(raw)
508 if err != nil {
509 return netip.Prefix{}, fmt.Errorf("CIDR %q parse error during conversion from string: %v", raw, err)
510 }
511 if prefix.Addr().Zone() != "" {
512 return netip.Prefix{}, fmt.Errorf("CIDR %q with zone value is not allowed", raw)
513 }
514 if prefix.Addr().Is4In6() {
515 return netip.Prefix{}, fmt.Errorf("IPv4-mapped IPv6 address %q is not allowed", raw)
516 }
517 return prefix, nil
518}
519
520func parseIPAddr(raw string) (netip.Addr, error) {
521 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