mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Fix windows interface matching
In windows pcap.Name differ from net.Interface Name, so instead we have to match by interface addrs
This commit is contained in:
+14
-7
@@ -232,7 +232,7 @@ func (l *Listener) PcapHandle(ifi pcap.Interface) (handle *pcap.Handle, err erro
|
||||
if l.TimestampType != "" && l.TimestampType != "go" {
|
||||
var ts pcap.TimestampSource
|
||||
ts, err = pcap.TimestampSourceFromString(l.TimestampType)
|
||||
fmt.Println("Setting custom Timestamp Source. Supported values: `simple`, ", inactive.SupportedTimestamps())
|
||||
fmt.Println("Setting custom Timestamp Source. Supported values: `go`, ", inactive.SupportedTimestamps())
|
||||
err = inactive.SetTimestampSource(ts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%q: supported timestamps: %q, interface: %q", err, inactive.SupportedTimestamps(), ifi.Name)
|
||||
@@ -517,11 +517,20 @@ func (l *Listener) setInterfaces() (err error) {
|
||||
}
|
||||
|
||||
for _, pi := range pifis {
|
||||
if len(pi.Addresses) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
var ni net.Interface
|
||||
for _, i := range ifis {
|
||||
if i.Name == pi.Name {
|
||||
ni = i
|
||||
break
|
||||
addrs, _ := i.Addrs()
|
||||
for _, a := range addrs {
|
||||
for _, pa := range pi.Addresses {
|
||||
if strings.HasPrefix(a.String(), pa.IP.String()) {
|
||||
ni = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,9 +546,7 @@ func (l *Listener) setInterfaces() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(pi.Addresses) != 0 {
|
||||
l.Interfaces = append(l.Interfaces, pi)
|
||||
}
|
||||
l.Interfaces = append(l.Interfaces, pi)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user