From 288bc1e699861d31948f34a4797ef36ba24a1dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=80=9D=E6=95=8F?= Date: Tue, 30 Aug 2022 11:36:13 +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 --- netcard.go | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/netcard.go b/netcard.go index ffa9096..a69c0b9 100644 --- a/netcard.go +++ b/netcard.go @@ -16,7 +16,6 @@ import ( "sync/atomic" "time" - "github.com/klauspost/compress/zstd" "github.com/songgao/packets/ethernet" "github.com/songgao/water" "github.com/songgao/water/waterutil" @@ -92,21 +91,20 @@ func (cli *RPCClient) run() { cliBuffer := <-cli.FrameChan log.Printf("send to target %s source bytes: %d", waterutil.IPv4Destination(cliBuffer.BytesArray[0]), len(cliBuffer.BytesArray[0])) - err := enc.Encode(cliBuffer.BytesArray) if err != nil { log.Panic(err) } // zstd compress - zenc, err := zstd.NewWriter(buf) - if err != nil { - log.Panic(err) - } - err = zenc.Flush() - if err != nil { - log.Println(err) - } + // zenc, err := zstd.NewWriter(buf) + // if err != nil { + // log.Panic(err) + // } + // err = zenc.Flush() + // if err != nil { + // log.Println(err) + // } // 发到对面的网卡 err = stream.Send(&gen.Request{ @@ -254,27 +252,27 @@ func (nc *NetCard) runRead() { func (nc *NetCard) runWrite() { var ifce *water.Interface = nc.ifce - // var err error + var err error for wframe := range nc.FrameChan { log.Printf("get wframes bytes len: %d", len(wframe)) var buf = bytes.NewBuffer(wframe) + // zdec, err := zstd.NewReader(buf) + // if err != nil { + // log.Panic(err) + // } + + // zdec.Close() + dec := gob.NewDecoder(buf) var bufs [][]byte - err := dec.Decode(&bufs) + err = dec.Decode(&bufs) if err != nil { log.Panic(err) } - zdec, err := zstd.NewReader(buf) - if err != nil { - log.Panic(err) - } - - zdec.Close() - for _, buf := range bufs { h := md5.New() h.Write(buf)