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