From 137a7b14b2854c3ee9827e0065fff163c7bbdb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=80=9D=E6=95=8F?= Date: Thu, 1 Sep 2022 15:12:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0TAP=E6=B5=8B=E8=AF=95(TODO=20=E8=A7=A3?= =?UTF-8?q?=E6=9E=90arp)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- netcard.go | 14 ++++++++------ utils.go | 4 ---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/netcard.go b/netcard.go index 346bf41..61efa44 100644 --- a/netcard.go +++ b/netcard.go @@ -126,8 +126,8 @@ func NewNetTunnel() *NetTunnel { payload := frame.Payload() // dst := net.IP(payload[16:20]).To4() - log.Printf("bytes len: %d type(ipv4): % x", len(rbuf), frame.Ethertype()) - log.Println(frame.Source(), net.IP(payload[12:16]).To4(), binary.BigEndian.Uint16(payload[20:22]), frame.Destination(), net.IP(payload[16:20]).To4(), binary.BigEndian.Uint16(payload[22:24])) + // log.Printf("bytes len: %d type(ipv4): % x", len(rbuf), frame.Ethertype()) + // log.Println(frame.Source(), net.IP(payload[12:16]).To4(), binary.BigEndian.Uint16(payload[20:22]), frame.Destination(), net.IP(payload[16:20]).To4(), binary.BigEndian.Uint16(payload[22:24])) ipv4key := binary.BigEndian.Uint32(payload[16:20]) if v, ok := nt.clients.Load(ipv4key); ok { @@ -149,10 +149,12 @@ func NewNetTunnel() *NetTunnel { go func() { for wbuf := range nt.writer { var frame ethernet.Frame = wbuf - copy(frame[0:6], nt.ifmac) - log.Printf("ifce write %d ", len(frame)) - payload := frame.Payload() - log.Println(frame.Source(), net.IP(payload[12:16]).To4(), binary.BigEndian.Uint16(payload[20:22]), frame.Destination(), net.IP(payload[16:20]).To4(), binary.BigEndian.Uint16(payload[22:24])) + // copy(frame[0:6], nt.ifmac) + + // payload := frame.Payload() + + // log.Printf("ifce write %d ", len(frame)) + // log.Println(frame.Source(), net.IP(payload[12:16]).To4(), binary.BigEndian.Uint16(payload[20:22]), frame.Destination(), net.IP(payload[16:20]).To4(), binary.BigEndian.Uint16(payload[22:24])) _, err := nt.ifce.Write(frame) if err != nil { diff --git a/utils.go b/utils.go index 53302df..7964471 100644 --- a/utils.go +++ b/utils.go @@ -9,7 +9,6 @@ import ( "net" "github.com/klauspost/compress/zstd" - "github.com/songgao/water/waterutil" ) func Compress(writer io.Writer, data [][]byte) { @@ -17,7 +16,6 @@ func Compress(writer io.Writer, data [][]byte) { // encode gob enc := gob.NewEncoder(writer) - log.Printf("send to target %s source bytes: %d", waterutil.IPv4Destination(data[0]), len(data[0])) err := enc.Encode(data) if err != nil { log.Panic(err) @@ -38,8 +36,6 @@ func Compress(writer io.Writer, data [][]byte) { func Decompress(data []byte) (frames [][]byte) { var err error - log.Printf("get data bytes len: %d", len(data)) - var buf = bytes.NewBuffer(data) var zdec *zstd.Decoder zdec, err = zstd.NewReader(buf)