1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 18:00:43 +00:00

migrate int to int32

This commit is contained in:
Darien Raymond 2018-04-03 11:32:03 +02:00
parent 4c2edeb18a
commit 7bafd7a1ab
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 9 additions and 9 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -88,7 +88,7 @@ func NewShakeSizeParser(nonce []byte) *ShakeSizeParser {
}
}
func (*ShakeSizeParser) SizeBytes() int {
func (*ShakeSizeParser) SizeBytes() int32 {
return 2
}