MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / parseNet

Function parseNet

internal/appfetch/appfetch.go:122–139  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

120}
121
122func parseNet(s string) (*net.IPNet, error) {
123 if strings.Contains(s, "/") {
124 _, n, err := net.ParseCIDR(s)
125 if err != nil {
126 return nil, fmt.Errorf("bad CIDR %q", s)
127 }
128 return n, nil
129 }
130 ip := net.ParseIP(s)
131 if ip == nil {
132 return nil, fmt.Errorf("bad IP %q", s)
133 }
134 bits := 128
135 if ip.To4() != nil {
136 ip, bits = ip.To4(), 32
137 }
138 return &net.IPNet{IP: ip, Mask: net.CIDRMask(bits, bits)}, nil
139}
140
141type originKey struct{}
142

Callers 2

newFetcherFunction · 0.85
NewPosterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected