From 2722c581226bca167d745cc45565af8ec3823ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=80=9D=E6=95=8F?= Date: Thu, 25 Aug 2022 18:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tap.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tap.go b/tap.go index 6be7897..895b911 100644 --- a/tap.go +++ b/tap.go @@ -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]