Add error checking to lookup host (#1847)

This commit is contained in:
Laurence Jones 2022-10-31 18:38:01 +00:00 committed by GitHub
parent 344b1dc559
commit 668627f890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,7 @@ func GetExprEnv(ctx map[string]interface{}) map[string]interface{} {
"XMLGetNodeValue": XMLGetNodeValue,
"IpToRange": IpToRange,
"IsIPV6": IsIPV6,
"LookupHost": net.LookupHost,
"LookupHost": LookupHost,
"GetDecisionsCount": GetDecisionsCount,
"GetDecisionsSinceCount": GetDecisionsSinceCount,
"Sprintf": fmt.Sprintf,
@ -281,3 +281,12 @@ func GetDecisionsSinceCount(value string, since string) int {
}
return count
}
func LookupHost(value string) []string {
addresses , err := net.LookupHost(value)
if err != nil {
log.Errorf("Failed to lookup host '%s' : %s", value, err)
return []string{}
}
return addresses
}