mirror of
https://github.com/SagerNet/sing-shadowsocks.git
synced 2025-04-03 20:07:40 +03:00
Fix buffer usage
This commit is contained in:
parent
fed8d42732
commit
a9d165b21b
2 changed files with 3 additions and 3 deletions
|
@ -294,7 +294,7 @@ func (c *clientConn) writeRequest(payload []byte) error {
|
||||||
payloadLen := len(payload)
|
payloadLen := len(payload)
|
||||||
variableLengthHeaderLen += payloadLen
|
variableLengthHeaderLen += payloadLen
|
||||||
common.Must(binary.Write(fixedLengthBuffer, binary.BigEndian, uint16(variableLengthHeaderLen)))
|
common.Must(binary.Write(fixedLengthBuffer, binary.BigEndian, uint16(variableLengthHeaderLen)))
|
||||||
writer.WriteChunk(header, fixedLengthBuffer.Slice())
|
writer.WriteChunk(header, fixedLengthBuffer.Bytes())
|
||||||
|
|
||||||
variableLengthBuffer := buf.NewSize(variableLengthHeaderLen)
|
variableLengthBuffer := buf.NewSize(variableLengthHeaderLen)
|
||||||
err = M.SocksaddrSerializer.WriteAddrPort(variableLengthBuffer, c.destination)
|
err = M.SocksaddrSerializer.WriteAddrPort(variableLengthBuffer, c.destination)
|
||||||
|
@ -308,7 +308,7 @@ func (c *clientConn) writeRequest(payload []byte) error {
|
||||||
if payloadLen > 0 {
|
if payloadLen > 0 {
|
||||||
common.Must1(variableLengthBuffer.Write(payload[:payloadLen]))
|
common.Must1(variableLengthBuffer.Write(payload[:payloadLen]))
|
||||||
}
|
}
|
||||||
writer.WriteChunk(header, variableLengthBuffer.Slice())
|
writer.WriteChunk(header, variableLengthBuffer.Bytes())
|
||||||
variableLengthBuffer.Release()
|
variableLengthBuffer.Release()
|
||||||
|
|
||||||
err = writer.BufferedWriter(header.Len()).Flush()
|
err = writer.BufferedWriter(header.Len()).Flush()
|
||||||
|
|
|
@ -287,7 +287,7 @@ func (c *serverConn) writeResponse(payload []byte) (n int, err error) {
|
||||||
common.Must1(headerFixedChunk.Write(c.requestSalt))
|
common.Must1(headerFixedChunk.Write(c.requestSalt))
|
||||||
common.Must(binary.Write(headerFixedChunk, binary.BigEndian, uint16(payloadLen)))
|
common.Must(binary.Write(headerFixedChunk, binary.BigEndian, uint16(payloadLen)))
|
||||||
|
|
||||||
writer.WriteChunk(header, headerFixedChunk.Slice())
|
writer.WriteChunk(header, headerFixedChunk.Bytes())
|
||||||
headerFixedChunk.Release()
|
headerFixedChunk.Release()
|
||||||
c.requestSalt = nil
|
c.requestSalt = nil
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue