Merge pull request #95 from SiPearl/92-fix-failed-to-find-MAC-address-with-IP

#92 FindMACAddressWithIP expects Host IP without prefix, but is always true
This commit is contained in:
David Allen 2025-05-26 23:14:56 -06:00 committed by GitHub
commit de102ecc97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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