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
|
continue
|
||||||
}
|
}
|
||||||
dst := getByteFull()
|
dst := getByteFull()
|
||||||
n, err = cSess.CstpPickCmp.Uncompress(pl.Data[8:], (*dst)[8:])
|
nn, err := cSess.CstpPickCmp.Uncompress(pl.Data[8:], *dst)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
putByte(dst)
|
putByte(dst)
|
||||||
base.Debug("cstp decompress error", n)
|
base.Error("cstp decompress error", err, nn)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
copy((*dst)[:8], pl.Data[:8])
|
binary.BigEndian.PutUint16(pl.Data[4:6], uint16(nn))
|
||||||
binary.BigEndian.PutUint16((*dst)[4:6], uint16(n))
|
pl.Data = append(pl.Data[:8], (*dst)[:nn]...)
|
||||||
pl.Data = append(pl.Data[:0], (*dst)[:n+8]...)
|
|
||||||
putByte(dst)
|
putByte(dst)
|
||||||
fallthrough
|
fallthrough
|
||||||
case 0x00: // DATA
|
case 0x00: // DATA
|
||||||
|
|
|
@ -74,16 +74,15 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dst := getByteFull()
|
dst := getByteFull()
|
||||||
n, err = cSess.DtlsPickCmp.Uncompress(pl.Data[1:], (*dst)[1:])
|
nn, err := cSess.DtlsPickCmp.Uncompress(pl.Data[1:], *dst)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Debug("dtls decompress error, size is ", n)
|
|
||||||
putByte(dst)
|
putByte(dst)
|
||||||
|
base.Error("dtls decompress error", err, n)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
n = n + 1
|
pl.Data = append(pl.Data[:1], (*dst)[:nn]...)
|
||||||
pl.Data = append(pl.Data[:0], (*dst)[:n]...)
|
|
||||||
putByte(dst)
|
putByte(dst)
|
||||||
|
n = nn + 1
|
||||||
fallthrough
|
fallthrough
|
||||||
case 0x00: // DATA
|
case 0x00: // DATA
|
||||||
// 去除数据头
|
// 去除数据头
|
||||||
|
|
Loading…
Reference in New Issue