Browse Source

max padding len as variable

pull/1524/head^2
Darien Raymond 6 years ago
parent
commit
8a879deac1
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 7
      common/crypto/auth.go
  2. 1
      common/crypto/chunk.go
  3. 4
      proxy/vmess/encoding/auth.go

7
common/crypto/auth.go

@ -238,7 +238,12 @@ func (w *AuthenticationWriter) seal(b *buf.Buffer) (*buf.Buffer, error) {
func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
defer mb.Release()
payloadSize := buf.Size - int32(w.auth.Overhead()) - w.sizeParser.SizeBytes() - 64 /* padding buffer */
var maxPadding int32
if w.padding != nil {
maxPadding = int32(w.padding.MaxPaddingLen())
}
payloadSize := buf.Size - int32(w.auth.Overhead()) - w.sizeParser.SizeBytes() - maxPadding
mb2Write := buf.NewMultiBufferCap(int32(len(mb) + 10))
for {

1
common/crypto/chunk.go

@ -21,6 +21,7 @@ type ChunkSizeEncoder interface {
}
type PaddingLengthGenerator interface {
MaxPaddingLen() uint16
NextPaddingLen() uint16
}

4
proxy/vmess/encoding/auth.go

@ -111,3 +111,7 @@ func (s *ShakeSizeParser) Encode(size uint16, b []byte) []byte {
func (s *ShakeSizeParser) NextPaddingLen() uint16 {
return s.next() % 64
}
func (s *ShakeSizeParser) MaxPaddingLne() uint16 {
return 64
}

Loading…
Cancel
Save