mirror of https://github.com/bjdgyc/anylink.git
优化压缩的代码
This commit is contained in:
parent
768e137ff9
commit
9533ecd6c5
|
@ -72,15 +72,14 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
|
|||
continue
|
||||
}
|
||||
dst := getByteFull()
|
||||
n, err = cSess.CstpPickCmp.Uncompress(pl.Data[8:], (*dst)[8:])
|
||||
nn, err := cSess.CstpPickCmp.Uncompress(pl.Data[8:], *dst)
|
||||
if err != nil {
|
||||
putByte(dst)
|
||||
base.Debug("cstp decompress error", n)
|
||||
base.Error("cstp decompress error", err, nn)
|
||||
continue
|
||||
}
|
||||
copy((*dst)[:8], pl.Data[:8])
|
||||
binary.BigEndian.PutUint16((*dst)[4:6], uint16(n))
|
||||
pl.Data = append(pl.Data[:0], (*dst)[:n+8]...)
|
||||
binary.BigEndian.PutUint16(pl.Data[4:6], uint16(nn))
|
||||
pl.Data = append(pl.Data[:8], (*dst)[:nn]...)
|
||||
putByte(dst)
|
||||
fallthrough
|
||||
case 0x00: // DATA
|
||||
|
|
|
@ -74,16 +74,15 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
|
|||
continue
|
||||
}
|
||||
dst := getByteFull()
|
||||
n, err = cSess.DtlsPickCmp.Uncompress(pl.Data[1:], (*dst)[1:])
|
||||
nn, err := cSess.DtlsPickCmp.Uncompress(pl.Data[1:], *dst)
|
||||
if err != nil {
|
||||
base.Debug("dtls decompress error, size is ", n)
|
||||
putByte(dst)
|
||||
base.Error("dtls decompress error", err, n)
|
||||
continue
|
||||
}
|
||||
n = n + 1
|
||||
pl.Data = append(pl.Data[:0], (*dst)[:n]...)
|
||||
pl.Data = append(pl.Data[:1], (*dst)[:nn]...)
|
||||
putByte(dst)
|
||||
|
||||
n = nn + 1
|
||||
fallthrough
|
||||
case 0x00: // DATA
|
||||
// 去除数据头
|
||||
|
|
Loading…
Reference in New Issue