(section *ini.Section)
| 207 | } |
| 208 | |
| 209 | func 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 | |
| 235 | func resolveIP(ip string) (*net.IPAddr, error) { |
| 236 | return net.ResolveIPAddr("ip", ip) |
no test coverage detected