This commit is contained in:
黄思敏 2022-08-26 10:54:43 +08:00
parent 10c5e7779d
commit b9fa5637af

View File

@ -13,7 +13,6 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/klauspost/compress/zstd"
"github.com/songgao/packets/ethernet" "github.com/songgao/packets/ethernet"
"github.com/songgao/water" "github.com/songgao/water"
"github.com/songgao/water/waterutil" "github.com/songgao/water/waterutil"
@ -85,14 +84,14 @@ func (cli *RPCClient) run() {
} }
// zstd compress // zstd compress
zenc, err := zstd.NewWriter(buf) // zenc, err := zstd.NewWriter(buf)
if err != nil { // if err != nil {
log.Panic(err) // log.Panic(err)
} // }
err = zenc.Flush() // err = zenc.Flush()
if err != nil { // if err != nil {
log.Println(err) // log.Println(err)
} // }
log.Printf("%v %d", cliBuffer, len(buf.Bytes())) log.Printf("%v %d", cliBuffer, len(buf.Bytes()))
// 发到对面的网卡 // 发到对面的网卡
@ -236,7 +235,7 @@ func (nc *NetCard) runRead() {
func (nc *NetCard) runWrite() { func (nc *NetCard) runWrite() {
var ifce *water.Interface = nc.ifce var ifce *water.Interface = nc.ifce
var err error
var buf = bytes.NewBuffer(nil) var buf = bytes.NewBuffer(nil)
for wframe := range nc.FrameChan { for wframe := range nc.FrameChan {
@ -244,11 +243,11 @@ func (nc *NetCard) runWrite() {
buf.Reset() buf.Reset()
buf.Write(wframe) buf.Write(wframe)
zdec, err := zstd.NewReader(buf) // zdec, err := zstd.NewReader(buf)
if err != nil { // if err != nil {
log.Panic(err) // log.Panic(err)
} // }
zdec.Close() // zdec.Close()
dec := gob.NewDecoder(buf) dec := gob.NewDecoder(buf)
var bufs [][]byte var bufs [][]byte