From 7bafd7a1abc23c03df98242a736164eb28dfef31 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 3 Apr 2018 11:32:03 +0200 Subject: [PATCH] migrate int to int32 --- common/crypto/auth.go | 4 ++-- common/crypto/chunk.go | 12 ++++++------ proxy/vmess/encoding/auth.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/crypto/auth.go b/common/crypto/auth.go index 8ac9e478..85a84a19 100644 --- a/common/crypto/auth.go +++ b/common/crypto/auth.go @@ -205,7 +205,7 @@ func (w *AuthenticationWriter) seal(b *buf.Buffer) (*buf.Buffer, error) { eb := buf.New() common.Must(eb.Reset(func(bb []byte) (int, error) { w.sizeParser.Encode(uint16(encryptedSize), bb[:0]) - return w.sizeParser.SizeBytes(), nil + return int(w.sizeParser.SizeBytes()), nil })) if err := eb.AppendSupplier(func(bb []byte) (int, error) { _, err := w.auth.Seal(bb[:0], b.Bytes()) @@ -221,7 +221,7 @@ func (w *AuthenticationWriter) seal(b *buf.Buffer) (*buf.Buffer, error) { func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error { defer mb.Release() - payloadSize := buf.Size - w.auth.Overhead() - w.sizeParser.SizeBytes() + payloadSize := buf.Size - int32(w.auth.Overhead()) - w.sizeParser.SizeBytes() mb2Write := buf.NewMultiBufferCap(int32(len(mb) + 10)) for { diff --git a/common/crypto/chunk.go b/common/crypto/chunk.go index 82e8a4ff..e6ea63d1 100755 --- a/common/crypto/chunk.go +++ b/common/crypto/chunk.go @@ -10,19 +10,19 @@ import ( // ChunkSizeDecoder is a utility class to decode size value from bytes. type ChunkSizeDecoder interface { - SizeBytes() int + SizeBytes() int32 Decode([]byte) (uint16, error) } // ChunkSizeEncoder is a utility class to encode size value into bytes. type ChunkSizeEncoder interface { - SizeBytes() int + SizeBytes() int32 Encode(uint16, []byte) []byte } type PlainChunkSizeParser struct{} -func (PlainChunkSizeParser) SizeBytes() int { +func (PlainChunkSizeParser) SizeBytes() int32 { return 2 } @@ -38,8 +38,8 @@ type AEADChunkSizeParser struct { Auth *AEADAuthenticator } -func (p *AEADChunkSizeParser) SizeBytes() int { - return 2 + p.Auth.Overhead() +func (p *AEADChunkSizeParser) SizeBytes() int32 { + return 2 + int32(p.Auth.Overhead()) } func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte { @@ -125,7 +125,7 @@ func (w *ChunkStreamWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { b := buf.New() common.Must(b.Reset(func(buffer []byte) (int, error) { w.sizeEncoder.Encode(uint16(slice.Len()), buffer[:0]) - return w.sizeEncoder.SizeBytes(), nil + return int(w.sizeEncoder.SizeBytes()), nil })) mb2Write.Append(b) mb2Write.AppendMulti(slice) diff --git a/proxy/vmess/encoding/auth.go b/proxy/vmess/encoding/auth.go index 05477661..2f23fa67 100644 --- a/proxy/vmess/encoding/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -88,7 +88,7 @@ func NewShakeSizeParser(nonce []byte) *ShakeSizeParser { } } -func (*ShakeSizeParser) SizeBytes() int { +func (*ShakeSizeParser) SizeBytes() int32 { return 2 }