mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
use all buffers
This commit is contained in:
parent
dd159cce6c
commit
97d886e1c9
@ -193,10 +193,6 @@ func (r *AuthenticationReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
||||
return mb, nil
|
||||
}
|
||||
|
||||
const (
|
||||
WriteSize = 1024
|
||||
)
|
||||
|
||||
type AuthenticationWriter struct {
|
||||
auth Authenticator
|
||||
writer buf.Writer
|
||||
@ -235,12 +231,13 @@ 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()
|
||||
mb2Write := buf.NewMultiBufferCap(len(mb) + 10)
|
||||
|
||||
for {
|
||||
b := buf.New()
|
||||
common.Must(b.Reset(func(bb []byte) (int, error) {
|
||||
return mb.Read(bb[:WriteSize])
|
||||
return mb.Read(bb[:payloadSize])
|
||||
}))
|
||||
eb, err := w.seal(b)
|
||||
b.Release()
|
||||
|
@ -43,7 +43,7 @@ func TestAuthenticationReaderWriter(t *testing.T) {
|
||||
}, PlainChunkSizeParser{}, cache, protocol.TransferTypeStream)
|
||||
|
||||
assert(writer.WriteMultiBuffer(buf.NewMultiBufferValue(payload)), IsNil)
|
||||
assert(cache.Len(), Equals, 83360)
|
||||
assert(cache.Len(), Equals, 82658)
|
||||
assert(writer.WriteMultiBuffer(buf.MultiBuffer{}), IsNil)
|
||||
assert(err, IsNil)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user