This commit is contained in:
黄思敏 2022-08-25 18:03:44 +08:00
parent a6adfa133e
commit 2722c58122

11
tap.go
View File

@ -7,6 +7,7 @@ import (
"flag"
"fmt"
"log"
"net"
"os/exec"
gen "slimming/proto/gen"
"strings"
@ -159,11 +160,17 @@ func (nc *NetCard) runRead() {
log.Fatal(err)
}
if rframe.Ethertype() != ethernet.IPv4 {
continue
}
log.Println(net.IP(rframe.Destination()).String())
var buffer *[][]byte
if buffer, ok = bytesMap[rframe.Destination().String()]; !ok {
if buffer, ok = bytesMap[net.IP(rframe.Destination()).String()]; !ok {
mbuffer := make([][]byte, 100)
buffer = &mbuffer
bytesMap[rframe.Destination().String()] = buffer
bytesMap[net.IP(rframe.Destination()).String()] = buffer
}
rframe = rframe[:n]