mirror of https://github.com/v2ray/v2ray-core
migrate int to int32
parent
4c2edeb18a
commit
7bafd7a1ab
|
@ -205,7 +205,7 @@ func (w *AuthenticationWriter) seal(b *buf.Buffer) (*buf.Buffer, error) {
|
||||||
eb := buf.New()
|
eb := buf.New()
|
||||||
common.Must(eb.Reset(func(bb []byte) (int, error) {
|
common.Must(eb.Reset(func(bb []byte) (int, error) {
|
||||||
w.sizeParser.Encode(uint16(encryptedSize), bb[:0])
|
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) {
|
if err := eb.AppendSupplier(func(bb []byte) (int, error) {
|
||||||
_, err := w.auth.Seal(bb[:0], b.Bytes())
|
_, 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 {
|
func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
|
||||||
defer mb.Release()
|
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))
|
mb2Write := buf.NewMultiBufferCap(int32(len(mb) + 10))
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -10,19 +10,19 @@ import (
|
||||||
|
|
||||||
// ChunkSizeDecoder is a utility class to decode size value from bytes.
|
// ChunkSizeDecoder is a utility class to decode size value from bytes.
|
||||||
type ChunkSizeDecoder interface {
|
type ChunkSizeDecoder interface {
|
||||||
SizeBytes() int
|
SizeBytes() int32
|
||||||
Decode([]byte) (uint16, error)
|
Decode([]byte) (uint16, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChunkSizeEncoder is a utility class to encode size value into bytes.
|
// ChunkSizeEncoder is a utility class to encode size value into bytes.
|
||||||
type ChunkSizeEncoder interface {
|
type ChunkSizeEncoder interface {
|
||||||
SizeBytes() int
|
SizeBytes() int32
|
||||||
Encode(uint16, []byte) []byte
|
Encode(uint16, []byte) []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlainChunkSizeParser struct{}
|
type PlainChunkSizeParser struct{}
|
||||||
|
|
||||||
func (PlainChunkSizeParser) SizeBytes() int {
|
func (PlainChunkSizeParser) SizeBytes() int32 {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ type AEADChunkSizeParser struct {
|
||||||
Auth *AEADAuthenticator
|
Auth *AEADAuthenticator
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *AEADChunkSizeParser) SizeBytes() int {
|
func (p *AEADChunkSizeParser) SizeBytes() int32 {
|
||||||
return 2 + p.Auth.Overhead()
|
return 2 + int32(p.Auth.Overhead())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte {
|
func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte {
|
||||||
|
@ -125,7 +125,7 @@ func (w *ChunkStreamWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||||
b := buf.New()
|
b := buf.New()
|
||||||
common.Must(b.Reset(func(buffer []byte) (int, error) {
|
common.Must(b.Reset(func(buffer []byte) (int, error) {
|
||||||
w.sizeEncoder.Encode(uint16(slice.Len()), buffer[:0])
|
w.sizeEncoder.Encode(uint16(slice.Len()), buffer[:0])
|
||||||
return w.sizeEncoder.SizeBytes(), nil
|
return int(w.sizeEncoder.SizeBytes()), nil
|
||||||
}))
|
}))
|
||||||
mb2Write.Append(b)
|
mb2Write.Append(b)
|
||||||
mb2Write.AppendMulti(slice)
|
mb2Write.AppendMulti(slice)
|
||||||
|
|
|
@ -88,7 +88,7 @@ func NewShakeSizeParser(nonce []byte) *ShakeSizeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*ShakeSizeParser) SizeBytes() int {
|
func (*ShakeSizeParser) SizeBytes() int32 {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue