Browse Source

refine auth writer

pull/1008/head
Darien Raymond 7 years ago
parent
commit
8d0a74b3fa
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 15
      common/crypto/auth.go

15
common/crypto/auth.go

@ -204,12 +204,20 @@ func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
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(len(mb) + 1)
for {
for !mb.IsEmpty() {
b := mb.SplitFirst()
if b == nil {
b = buf.New()
continue
}
eb, err := w.seal(b)
b.Release()
@ -218,9 +226,6 @@ func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
return err
}
mb2Write.Append(eb)
if mb.IsEmpty() {
break
}
}
return w.writer.WriteMultiBuffer(mb2Write)

Loading…
Cancel
Save