mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-29 23:36:25 -04:00
fix handling of empty buffer
This commit is contained in:
parent
61d9b04ca5
commit
4b45174650
@ -248,14 +248,6 @@ func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
|
|||||||
func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
|
func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
|
||||||
defer mb.Release()
|
defer mb.Release()
|
||||||
|
|
||||||
if mb.IsEmpty() {
|
|
||||||
b := buf.New()
|
|
||||||
defer b.Release()
|
|
||||||
|
|
||||||
eb, _ := w.seal(b)
|
|
||||||
return w.writer.WriteMultiBuffer(buf.NewMultiBufferValue(eb))
|
|
||||||
}
|
|
||||||
|
|
||||||
mb2Write := buf.NewMultiBufferCap(int32(len(mb)) + 1)
|
mb2Write := buf.NewMultiBufferCap(int32(len(mb)) + 1)
|
||||||
|
|
||||||
for !mb.IsEmpty() {
|
for !mb.IsEmpty() {
|
||||||
@ -276,6 +268,14 @@ func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||||
|
if mb.IsEmpty() {
|
||||||
|
b := buf.New()
|
||||||
|
defer b.Release()
|
||||||
|
|
||||||
|
eb, _ := w.seal(b)
|
||||||
|
return w.writer.WriteMultiBuffer(buf.NewMultiBufferValue(eb))
|
||||||
|
}
|
||||||
|
|
||||||
if w.transferType == protocol.TransferTypeStream {
|
if w.transferType == protocol.TransferTypeStream {
|
||||||
return w.writeStream(mb)
|
return w.writeStream(mb)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user