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)