#92 making sure that the argument of net.ParseIP is a pure IP address (x.x.x.x), without any prefix

This commit is contained in:
jose-angel gomez-lopez 2025-05-26 10:15:00 +02:00
parent fcfe76295e
commit 17ec8b07a7
No known key found for this signature in database
GPG key ID: C30E1D79E260B436

View file

@ -167,9 +167,14 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams) ([]map[strin
// optionally, add the MACAddr property if we find a matching IP
// from the correct ethernet interface
mac, err := FindMACAddressWithIP(config, net.ParseIP(sr.Host))
host := sr.Host
str_protocol := "https://"
if strings.Contains(host, str_protocol) {
host = strings.TrimPrefix(sr.Host, str_protocol)
}
mac, err := FindMACAddressWithIP(config, net.ParseIP(host))
if err != nil {
log.Warn().Err(err).Msgf("failed to find MAC address with IP '%s'", sr.Host)
log.Warn().Err(err).Msgf("failed to find MAC address with IP '%s'", host)
}
if mac != "" {
data["MACAddr"] = mac