From c9274ac92a6f021240d82682002240cfceaecd5e Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Tue, 3 Aug 2021 17:42:13 +0300 Subject: [PATCH] Fix windows loopback Windows loopback do not have addresses --- capture/capture.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/capture/capture.go b/capture/capture.go index 2fc0be26..9190ce69 100644 --- a/capture/capture.go +++ b/capture/capture.go @@ -571,10 +571,6 @@ func (l *Listener) setInterfaces() (err error) { } for _, pi := range pifis { - if len(pi.Addresses) == 0 { - continue - } - var ni net.Interface for _, i := range ifis { addrs, _ := i.Addrs() @@ -586,14 +582,16 @@ func (l *Listener) setInterfaces() (err error) { } } } + + if len(addrs) == 0 && i.Name == pi.Name { + ni = i + break + } } if ni.Flags&net.FlagLoopback != 0 { l.loopIndex = ni.Index } - if ni.Flags&net.FlagUp == 0 { - continue - } if isDevice(l.host, pi) { l.Interfaces = []pcap.Interface{pi}