fix: fixed bug which prevented some interfaces wiht IPv6 only addresses from being detected.

This commit is contained in:
evilsocket 2018-02-20 15:19:28 +01:00
commit 8d0e4ed0b1

View file

@ -71,19 +71,19 @@ func FindInterface(name string) (*Endpoint, error) {
} }
// Also search by ip if needed. // Also search by ip if needed.
if name != "" { hasIPv4 := false
for _, a := range addrs { for _, a := range addrs {
if a.String() == name || strings.HasPrefix(a.String(), name) { hasIPv4 = IPv4Validator.MatchString(a.String())
doCheck = true if name != "" && (a.String() == name || strings.HasPrefix(a.String(), name)) {
break doCheck = true
}
} }
} }
if doCheck { if doCheck {
var e *Endpoint = nil var e *Endpoint = nil
// interface is in monitor mode (or it's just down and the user is dumb) // interface is in monitor mode (or it's just down and the user is dumb, or
if nAddrs == 0 { // it only has an IPv6 address).
if nAddrs == 0 || hasIPv4 == false {
e = NewEndpointNoResolve(MonitorModeAddress, mac, ifName, 0) e = NewEndpointNoResolve(MonitorModeAddress, mac, ifName, 0)
} else { } else {
// For every address of the interface. // For every address of the interface.