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

Function parseCIDR

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

Source from the content-addressed store, hash-verified

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