Skip to content

Commit

Permalink
Merge pull request #992 from buger/fix/989-duplicate
Browse files Browse the repository at this point in the history
Issue was introduced while fixing windows c9274ac

Added exception for Windows, which by default allows interfaces without IPs.
Interface name check moved higher, so if interface namee or IP match, rest of check will be ignored.

Additionally windows npcap loopback mechanism can now be picked by specifying 127.0.0.1 or loopback IP.

Fix #989
  • Loading branch information
buger committed Aug 12, 2021
2 parents 11d61dc + 9bdf272 commit 42d8990
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,27 @@ func (l *Listener) setInterfaces() (err error) {
return
}

if runtime.GOOS != "windows" {
if len(pi.Addresses) == 0 {
continue
}

if ni.Flags&net.FlagUp == 0 {
continue
}
}

l.Interfaces = append(l.Interfaces, pi)
}
return
}

func isDevice(addr string, ifi pcap.Interface) bool {
// Windows npcap loopback have no IPs
if addr == "127.0.0.1" && ifi.Name == `\Device\NPF_Loopback` {
return true
}

if addr == ifi.Name {
return true
}
Expand Down

0 comments on commit 42d8990

Please sign in to comment.