1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-01 06:55:25 -05:00

refine buffer interface

This commit is contained in:
Darien Raymond
2018-07-30 22:45:06 +02:00
parent a4030dd237
commit 206f52affc
14 changed files with 42 additions and 58 deletions

View File

@@ -69,14 +69,14 @@ func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ
buffer := buf.New()
defer buffer.Release()
buffer.AppendBytes(Version)
buffer.Write(c.requestBodyIV[:])
buffer.Write(c.requestBodyKey[:])
buffer.AppendBytes(c.responseHeader, byte(header.Option))
common.Must2(buffer.WriteBytes(Version))
common.Must2(buffer.Write(c.requestBodyIV[:]))
common.Must2(buffer.Write(c.requestBodyKey[:]))
common.Must2(buffer.WriteBytes(c.responseHeader, byte(header.Option)))
padingLen := dice.Roll(16)
security := byte(padingLen<<4) | byte(header.Security)
buffer.AppendBytes(security, byte(0), byte(header.Command))
common.Must2(buffer.WriteBytes(security, byte(0), byte(header.Command)))
if header.Command != protocol.RequestCommandMux {
if err := addrParser.WriteAddressPort(buffer, header.Address, header.Port); err != nil {