in tcpdumpw/pkg/filter/ip_filter_provider.go [42:85]
func (p *IPFilterProvider) getIPsAndNETs(
_ context.Context,
) (
[]string, /* IPs */
[]string, /* NETs */
) {
if *p.ipv4Filter.Raw == "" && *p.ipv6Filter.Raw == "" {
return []string{}, []string{}
}
rawIPs := stringFormatter.Format("{0},{1}",
*p.ipv4Filter.Raw, *p.ipv6Filter.Raw)
allIPsOrNETs := strings.Split(rawIPs, ",")
IPs := []string{}
NETs := []string{}
for _, IPorNET := range allIPsOrNETs {
if IPorNET == "" || strings.EqualFold(IPorNET, "DISABLED") {
continue
} else if strings.EqualFold(IPorNET, "ALL") || strings.EqualFold(IPorNET, "ANY") {
NETs = append(NETs, defaultIPv4Net)
NETs = append(NETs, defaultIPv6Net)
} else if addr, err := netip.ParseAddr(IPorNET); err == nil {
if addr.Is4() || addr.Is6() {
IPs = append(IPs, addr.String())
}
} else if net, err := netip.ParsePrefix(IPorNET); err == nil {
if !net.IsValid() {
continue
}
NETs = append(NETs, net.String())
addr := net.Addr()
if addr.Is4() {
p.compatFilters.AddIPv4Ranges(IPorNET)
} else {
p.compatFilters.AddIPv6Ranges(IPorNET)
}
}
}
// ALL returned IPs and Networks are SAFE
return IPs, NETs
}