Refactor IP parsing to use appendIfNotExcluded for exclusion validation and error handling

This commit is contained in:
2026-08-12 16:29:09 +05:00
parent c22ef390ee
commit 407c9d961f
4 changed files with 53 additions and 9 deletions
+16
View File
@@ -0,0 +1,16 @@
package parser
func appendIfNotExcluded(ip string, ips []string, validator IPValidator) ([]string, error) {
if exclude, listIP, err := validator.IsExcluded(ip); err != nil {
return ips, err
} else if exclude {
if listIP == nil || len(listIP) == 0 {
return ips, nil
}
ips = append(ips, listIP...)
return ips, nil
}
ips = append(ips, ip)
return ips, nil
}