MCPcopy
hub / github.com/windtf/wireproxy / parseNetIP

Function parseNetIP

config.go:152–175  ·  view source on GitHub ↗
(section *ini.Section, keyName string)

Source from the content-addressed store, hash-verified

150}
151
152func parseNetIP(section *ini.Section, keyName string) ([]netip.Addr, error) {
153 key, err := parseString(section, keyName)
154 if err != nil {
155 if strings.Contains(err.Error(), "should not be empty") {
156 return []netip.Addr{}, nil
157 }
158 return nil, err
159 }
160
161 keys := strings.Split(key, ",")
162 var ips = make([]netip.Addr, 0, len(keys))
163 for _, str := range keys {
164 str = strings.TrimSpace(str)
165 if len(str) == 0 {
166 continue
167 }
168 ip, err := netip.ParseAddr(str)
169 if err != nil {
170 return nil, err
171 }
172 ips = append(ips, ip)
173 }
174 return ips, nil
175}
176
177func parseCIDRNetIP(section *ini.Section, keyName string) ([]netip.Addr, error) {
178 key, err := parseString(section, keyName)

Callers 1

ParseInterfaceFunction · 0.85

Calls 1

parseStringFunction · 0.85

Tested by

no test coverage detected