fix: improve IP normalization in normalizeIPOrCIDR function
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -149,10 +149,12 @@ func normalizeIPOrCIDR(raw string) (string, error) {
|
|||||||
_ = ip
|
_ = ip
|
||||||
return network.String(), nil
|
return network.String(), nil
|
||||||
}
|
}
|
||||||
if net.ParseIP(raw) == nil {
|
ip := net.ParseIP(raw)
|
||||||
|
if ip == nil {
|
||||||
return "", fmt.Errorf("invalid IP: %q", raw)
|
return "", fmt.Errorf("invalid IP: %q", raw)
|
||||||
}
|
}
|
||||||
return raw, nil
|
|
||||||
|
return ip.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildWhitelistYAML constructs the YAML content for the CrowdSec whitelist parser.
|
// buildWhitelistYAML constructs the YAML content for the CrowdSec whitelist parser.
|
||||||
|
|||||||
Reference in New Issue
Block a user