Fix bug in target parsing

When a MAC address with uppercase letters was provided, parsing would
return an error because the parsing logic would only attempt to remove
normalized versions (all lowercase) from the target list. This would
leave the address with uppercase letters in the target list, which it
would then try to interpet as an Alias. This fixes the bug by using
the original address form when removing it from the target list.
This commit is contained in:
Ben Draut 2021-03-09 20:30:48 -07:00
commit 32eee7d94b
2 changed files with 20 additions and 4 deletions

View file

@ -101,10 +101,10 @@ func ParseTargets(targets string, aliasMap *data.UnsortedKV) (ips []net.IP, macs
// first isolate MACs and parse them
for _, mac := range macParser.FindAllString(targets, -1) {
mac = NormalizeMac(mac)
hw, err := net.ParseMAC(mac)
normalizedMac := NormalizeMac(mac)
hw, err := net.ParseMAC(normalizedMac)
if err != nil {
return nil, nil, fmt.Errorf("error while parsing MAC '%s': %s", mac, err)
return nil, nil, fmt.Errorf("error while parsing MAC '%s': %s", normalizedMac, err)
}
macs = append(macs, hw)