MCPcopy Index your code
hub / github.com/windtf/wireproxy / parseAllowedIPs

Function parseAllowedIPs

config.go:209–233  ·  view source on GitHub ↗
(section *ini.Section)

Source from the content-addressed store, hash-verified

207}
208
209func parseAllowedIPs(section *ini.Section) ([]netip.Prefix, error) {
210 key, err := parseString(section, "AllowedIPs")
211 if err != nil {
212 if strings.Contains(err.Error(), "should not be empty") {
213 return []netip.Prefix{}, nil
214 }
215 return nil, err
216 }
217
218 keys := strings.Split(key, ",")
219 var ips = make([]netip.Prefix, 0, len(keys))
220 for _, str := range keys {
221 str = strings.TrimSpace(str)
222 if len(str) == 0 {
223 continue
224 }
225 prefix, err := netip.ParsePrefix(str)
226 if err != nil {
227 return nil, err
228 }
229
230 ips = append(ips, prefix)
231 }
232 return ips, nil
233}
234
235func resolveIP(ip string) (*net.IPAddr, error) {
236 return net.ResolveIPAddr("ip", ip)

Callers 1

ParsePeersFunction · 0.85

Calls 1

parseStringFunction · 0.85

Tested by

no test coverage detected