Allow no interfaces in network fingerprinter

This commit is contained in:
Alex Dadgar 2015-11-18 19:01:39 -08:00
parent ceeabe63f7
commit cf4a44352f
2 changed files with 6 additions and 1 deletions

View file

@ -64,6 +64,11 @@ func (f *NetworkFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
return false, fmt.Errorf("Error while detecting network interface during fingerprinting: %v", err) return false, fmt.Errorf("Error while detecting network interface during fingerprinting: %v", err)
} }
// No interface could be found
if intf == nil {
return false, nil
}
if ip, err = f.ipAddress(intf); err != nil { if ip, err = f.ipAddress(intf); err != nil {
return false, fmt.Errorf("Unable to find IP address of interface: %s, err: %v", intf.Name, err) return false, fmt.Errorf("Unable to find IP address of interface: %s, err: %v", intf.Name, err)
} }
@ -229,7 +234,7 @@ func (f *NetworkFingerprint) findInterface(deviceName string) (*net.Interface, e
} }
if len(interfaces) == 0 { if len(interfaces) == 0 {
return nil, errors.New("No network interfaces were detected") return nil, nil
} }
return &interfaces[0], nil return &interfaces[0], nil
} }

0
main.go Normal file → Executable file
View file