Some minor fix (#430)

* fix typo pading to padding

* reorder common/buf/buffer.go code layout

* delete unused common/stack

Co-authored-by: Chinsyo <chinsyo@sina.cn>
This commit is contained in:
Chinsyo
2020-11-18 04:23:30 +08:00
committed by GitHub
co-authored by Chinsyo
parent dc78733196
commit 32e0e6e484
4 changed files with 24 additions and 35 deletions
+4 -4
View File
@@ -90,8 +90,8 @@ func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ
common.Must(buffer.WriteByte(c.responseHeader))
common.Must(buffer.WriteByte(byte(header.Option)))
padingLen := dice.Roll(16)
security := byte(padingLen<<4) | byte(header.Security)
paddingLen := dice.Roll(16)
security := byte(paddingLen<<4) | byte(header.Security)
common.Must2(buffer.Write([]byte{security, byte(0), byte(header.Command)}))
if header.Command != protocol.RequestCommandMux {
@@ -100,8 +100,8 @@ func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ
}
}
if padingLen > 0 {
common.Must2(buffer.ReadFullFrom(rand.Reader, int32(padingLen)))
if paddingLen > 0 {
common.Must2(buffer.ReadFullFrom(rand.Reader, int32(paddingLen)))
}
{
+3 -3
View File
@@ -233,7 +233,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
s.responseHeader = buffer.Byte(33) // 1 byte
request.Option = bitmask.Byte(buffer.Byte(34)) // 1 byte
padingLen := int(buffer.Byte(35) >> 4)
paddingLen := int(buffer.Byte(35) >> 4)
request.Security = parseSecurityType(buffer.Byte(35) & 0x0F)
// 1 bytes reserved
request.Command = protocol.RequestCommand(buffer.Byte(37))
@@ -250,8 +250,8 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
}
}
if padingLen > 0 {
if _, err := buffer.ReadFullFrom(decryptor, int32(padingLen)); err != nil {
if paddingLen > 0 {
if _, err := buffer.ReadFullFrom(decryptor, int32(paddingLen)); err != nil {
if !s.isAEADRequest {
burnErr := s.userValidator.BurnTaintFuse(fixedSizeAuthID[:])
if burnErr != nil {