测试
This commit is contained in:
parent
14ad5f7a50
commit
288bc1e699
36
netcard.go
36
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user