测试
This commit is contained in:
parent
14ad5f7a50
commit
288bc1e699
36
netcard.go
36
netcard.go
|
@ -16,7 +16,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"
|
||||||
|
@ -92,21 +91,20 @@ func (cli *RPCClient) run() {
|
||||||
cliBuffer := <-cli.FrameChan
|
cliBuffer := <-cli.FrameChan
|
||||||
|
|
||||||
log.Printf("send to target %s source bytes: %d", waterutil.IPv4Destination(cliBuffer.BytesArray[0]), len(cliBuffer.BytesArray[0]))
|
log.Printf("send to target %s source bytes: %d", waterutil.IPv4Destination(cliBuffer.BytesArray[0]), len(cliBuffer.BytesArray[0]))
|
||||||
|
|
||||||
err := enc.Encode(cliBuffer.BytesArray)
|
err := enc.Encode(cliBuffer.BytesArray)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 发到对面的网卡
|
// 发到对面的网卡
|
||||||
err = stream.Send(&gen.Request{
|
err = stream.Send(&gen.Request{
|
||||||
|
@ -254,27 +252,27 @@ 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 err error
|
||||||
|
|
||||||
for wframe := range nc.FrameChan {
|
for wframe := range nc.FrameChan {
|
||||||
|
|
||||||
log.Printf("get wframes bytes len: %d", len(wframe))
|
log.Printf("get wframes bytes len: %d", len(wframe))
|
||||||
var buf = bytes.NewBuffer(wframe)
|
var buf = bytes.NewBuffer(wframe)
|
||||||
|
|
||||||
|
// zdec, err := zstd.NewReader(buf)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Panic(err)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// zdec.Close()
|
||||||
|
|
||||||
dec := gob.NewDecoder(buf)
|
dec := gob.NewDecoder(buf)
|
||||||
var bufs [][]byte
|
var bufs [][]byte
|
||||||
err := dec.Decode(&bufs)
|
err = dec.Decode(&bufs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
zdec, err := zstd.NewReader(buf)
|
|
||||||
if err != nil {
|
|
||||||
log.Panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
zdec.Close()
|
|
||||||
|
|
||||||
for _, buf := range bufs {
|
for _, buf := range bufs {
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
h.Write(buf)
|
h.Write(buf)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user