fix: tuic client use pool-based bytes.Buffer
This commit is contained in:
parent
0da09c5ddd
commit
b80e7c3c92
1 changed files with 9 additions and 4 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/metacubex/quic-go"
|
"github.com/metacubex/quic-go"
|
||||||
|
|
||||||
N "github.com/Dreamacro/clash/common/net"
|
N "github.com/Dreamacro/clash/common/net"
|
||||||
|
"github.com/Dreamacro/clash/common/pool"
|
||||||
"github.com/Dreamacro/clash/component/dialer"
|
"github.com/Dreamacro/clash/component/dialer"
|
||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
||||||
|
@ -119,7 +120,8 @@ func (t *Client) getQuicConn(ctx context.Context) (quic.Connection, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
buf := &bytes.Buffer{}
|
buf := pool.GetBuffer()
|
||||||
|
defer pool.PutBuffer(buf)
|
||||||
err = NewAuthenticate(t.Token).WriteTo(buf)
|
err = NewAuthenticate(t.Token).WriteTo(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -262,7 +264,8 @@ func (t *Client) DialContext(ctx context.Context, metadata *C.Metadata) (net.Con
|
||||||
defer func() {
|
defer func() {
|
||||||
t.deferQuicConn(quicConn, err)
|
t.deferQuicConn(quicConn, err)
|
||||||
}()
|
}()
|
||||||
buf := &bytes.Buffer{}
|
buf := pool.GetBuffer()
|
||||||
|
defer pool.PutBuffer(buf)
|
||||||
err = NewConnect(NewAddress(metadata)).WriteTo(buf)
|
err = NewConnect(NewAddress(metadata)).WriteTo(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -448,7 +451,8 @@ func (q *quicStreamPacketConn) close() (err error) {
|
||||||
}()
|
}()
|
||||||
q.client.udpInputMap.Delete(q.connId)
|
q.client.udpInputMap.Delete(q.connId)
|
||||||
_ = q.inputConn.Close()
|
_ = q.inputConn.Close()
|
||||||
buf := &bytes.Buffer{}
|
buf := pool.GetBuffer()
|
||||||
|
defer pool.PutBuffer(buf)
|
||||||
err = NewDissociate(q.connId).WriteTo(buf)
|
err = NewDissociate(q.connId).WriteTo(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -503,7 +507,8 @@ func (q *quicStreamPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err erro
|
||||||
q.client.deferQuicConn(q.quicConn, err)
|
q.client.deferQuicConn(q.quicConn, err)
|
||||||
}()
|
}()
|
||||||
addr.String()
|
addr.String()
|
||||||
buf := &bytes.Buffer{}
|
buf := pool.GetBuffer()
|
||||||
|
defer pool.PutBuffer(buf)
|
||||||
addrPort, err := netip.ParseAddrPort(addr.String())
|
addrPort, err := netip.ParseAddrPort(addr.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue