diff --git a/netcard.go b/netcard.go index a69c0b9..1387dc2 100644 --- a/netcard.go +++ b/netcard.go @@ -16,6 +16,7 @@ import ( "sync/atomic" "time" + "github.com/klauspost/compress/zstd" "github.com/songgao/packets/ethernet" "github.com/songgao/water" "github.com/songgao/water/waterutil" @@ -97,14 +98,14 @@ func (cli *RPCClient) run() { } // 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{ @@ -259,14 +260,14 @@ func (nc *NetCard) runWrite() { 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) - // } + var zdec *zstd.Decoder + zdec, err = zstd.NewReader(buf) + if err != nil { + log.Panic(err) + } + zdec.Close() - // zdec.Close() - - dec := gob.NewDecoder(buf) + dec := gob.NewDecoder(zdec) var bufs [][]byte err = dec.Decode(&bufs) if err != nil {