mirror of
https://github.com/netbirdio/go-netroute.git
synced 2026-05-22 17:11:07 -07:00
Merge pull request #29 from maxosprojects/fix-phys-addr-len-mismatch
fix(phys-addr-length): fix physical address length mismatch
This commit is contained in:
+7
-1
@@ -193,12 +193,18 @@ func getIface(index uint32) *net.Interface {
|
||||
return nil
|
||||
}
|
||||
|
||||
physAddrLen := int(ifRow.PhysAddrLen)
|
||||
if len(ifRow.PhysAddr) < physAddrLen && physAddrLen >= 0 {
|
||||
physAddrLen = len(ifRow.PhysAddr)
|
||||
}
|
||||
physAddr := ifRow.PhysAddr[:physAddrLen]
|
||||
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
for _, iface := range ifaces {
|
||||
if bytes.Equal(iface.HardwareAddr, ifRow.PhysAddr[:]) {
|
||||
if bytes.Equal(iface.HardwareAddr, physAddr) {
|
||||
return &iface
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user