mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
fix lint warnings
This commit is contained in:
parent
251d6f6fcb
commit
f5d76c8eb0
@ -93,7 +93,12 @@ func (r *AuthenticationReader) readSize() error {
|
||||
|
||||
sizeBytes := r.sizeParser.SizeBytes()
|
||||
if r.buffer.Len() < sizeBytes {
|
||||
common.Must(r.buffer.Reset(buf.ReadFrom(r.buffer)))
|
||||
if r.buffer.IsEmpty() {
|
||||
r.buffer.Clear()
|
||||
} else {
|
||||
common.Must(r.buffer.Reset(buf.ReadFrom(r.buffer)))
|
||||
}
|
||||
|
||||
delta := sizeBytes - r.buffer.Len()
|
||||
if err := r.buffer.AppendSupplier(buf.ReadAtLeastFrom(r.reader, delta)); err != nil {
|
||||
return err
|
||||
|
@ -3,6 +3,7 @@ package crypto
|
||||
import (
|
||||
"io"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
@ -70,7 +71,7 @@ func (r *ChunkStreamReader) readSize() (uint16, error) {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
r.leftOver.Read(r.buffer)
|
||||
common.Must2(r.leftOver.Read(r.buffer))
|
||||
return r.sizeDecoder.Decode(r.buffer)
|
||||
}
|
||||
|
||||
@ -93,21 +94,23 @@ func (r *ChunkStreamReader) Read() (buf.MultiBuffer, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if size >= r.leftOver.Len() {
|
||||
leftOverLen := r.leftOver.Len()
|
||||
if size >= leftOverLen {
|
||||
mb := r.leftOver
|
||||
r.leftOverSize = size - r.leftOver.Len()
|
||||
r.leftOverSize = size - leftOverLen
|
||||
r.leftOver = nil
|
||||
return mb, nil
|
||||
}
|
||||
|
||||
mb := r.leftOver.SliceBySize(size)
|
||||
if mb.Len() != size {
|
||||
mbLen := mb.Len()
|
||||
if mbLen != size {
|
||||
b := buf.New()
|
||||
b.AppendSupplier(buf.ReadFullFrom(&r.leftOver, size-mb.Len()))
|
||||
common.Must(b.Reset(buf.ReadFullFrom(&r.leftOver, size-mbLen)))
|
||||
mb.Append(b)
|
||||
}
|
||||
|
||||
r.leftOverSize = 0
|
||||
|
||||
return mb, nil
|
||||
}
|
||||
|
||||
@ -131,10 +134,10 @@ func (w *ChunkStreamWriter) Write(mb buf.MultiBuffer) error {
|
||||
slice := mb.SliceBySize(sliceSize)
|
||||
|
||||
b := buf.New()
|
||||
b.AppendSupplier(func(buffer []byte) (int, error) {
|
||||
common.Must(b.AppendSupplier(func(buffer []byte) (int, error) {
|
||||
w.sizeEncoder.Encode(uint16(slice.Len()), buffer[:0])
|
||||
return w.sizeEncoder.SizeBytes(), nil
|
||||
})
|
||||
}))
|
||||
mb2Write.Append(b)
|
||||
mb2Write.AppendMulti(slice)
|
||||
|
||||
|
@ -637,6 +637,8 @@ func TestVMessNone(t *testing.T) {
|
||||
wg.Add(10)
|
||||
for i := 0; i < 10; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
@ -651,9 +653,9 @@ func TestVMessNone(t *testing.T) {
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := readFrom(conn, time.Second*20, 1024*1024)
|
||||
|
||||
assert(response, Equals, xor(payload))
|
||||
assert(conn.Close(), IsNil)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
Loading…
Reference in New Issue
Block a user