Check for FlagUp when selecting iface

Fix iface selection on windows
This commit is contained in:
Yuki Nagato 2022-06-18 17:59:12 -07:00
commit 94c0ac34f7
2 changed files with 8 additions and 6 deletions

3
.gitignore vendored
View file

@ -15,4 +15,5 @@ stage/
/snap /snap
.idea .idea
bettercap.exe *.exe
.vscode/

View file

@ -261,7 +261,7 @@ func FindInterface(name string) (*Endpoint, error) {
fmt.Printf("wtf of the day: %s", err) fmt.Printf("wtf of the day: %s", err)
continue continue
} }
if iface.Flags&net.FlagUp != 0 {
for _, address := range addrs { for _, address := range addrs {
ip := address.String() ip := address.String()
if !strings.HasPrefix(ip, "127.0.0.1") && IPv4BlockValidator.MatchString(ip) { if !strings.HasPrefix(ip, "127.0.0.1") && IPv4BlockValidator.MatchString(ip) {
@ -269,6 +269,7 @@ func FindInterface(name string) (*Endpoint, error) {
} }
} }
} }
}
return nil, ErrNoIfaces return nil, ErrNoIfaces
} }