From 56c3462b76dc41de2fc3fecfcd2b8fc56a3390f7 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Sat, 28 Jun 2025 18:16:29 +0800 Subject: [PATCH] chore: update quic-go to 0.53.0 --- dns/doh.go | 12 ++++++------ dns/doq.go | 18 +++++++++--------- go.mod | 4 ++-- go.sum | 8 ++++---- transport/hysteria/core/client.go | 14 +++++++------- transport/hysteria/core/stream.go | 2 +- transport/hysteria/transport/client.go | 2 +- transport/tuic/common/congestion.go | 2 +- transport/tuic/common/stream.go | 4 ++-- transport/tuic/congestion/bbr_sender.go | 2 +- transport/tuic/congestion_v2/bbr_sender.go | 2 +- transport/tuic/server.go | 6 +++--- transport/tuic/v4/client.go | 18 +++++++++--------- transport/tuic/v4/packet.go | 8 ++++---- transport/tuic/v4/server.go | 4 ++-- transport/tuic/v5/client.go | 18 +++++++++--------- transport/tuic/v5/frag.go | 2 +- transport/tuic/v5/packet.go | 8 ++++---- transport/tuic/v5/server.go | 4 ++-- 19 files changed, 69 insertions(+), 69 deletions(-) diff --git a/dns/doh.go b/dns/doh.go index 7c804f26..a394e812 100644 --- a/dns/doh.go +++ b/dns/doh.go @@ -447,12 +447,12 @@ func (doh *dnsOverHTTPS) createTransport(ctx context.Context) (t http.RoundTripp return transport, nil } -// http3Transport is a wrapper over *http3.RoundTripper that tries to optimize +// http3Transport is a wrapper over *http3.Transport that tries to optimize // its behavior. The main thing that it does is trying to force use a single // connection to a host instead of creating a new one all the time. It also // helps mitigate race issues with quic-go. type http3Transport struct { - baseTransport *http3.RoundTripper + baseTransport *http3.Transport closed bool mu sync.RWMutex @@ -505,7 +505,7 @@ func (h *http3Transport) CloseIdleConnections() { // We should be able to fall back to H1/H2 in case if HTTP/3 is unavailable or // if it is too slow. In order to do that, this method will run two probes // in parallel (one for TLS, the other one for QUIC) and if QUIC is faster it -// will create the *http3.RoundTripper instance. +// will create the *http3.Transport instance. func (doh *dnsOverHTTPS) createTransportH3( ctx context.Context, tlsConfig *tls.Config, @@ -519,7 +519,7 @@ func (doh *dnsOverHTTPS) createTransportH3( return nil, err } - rt := &http3.RoundTripper{ + rt := &http3.Transport{ Dial: func( ctx context.Context, @@ -528,7 +528,7 @@ func (doh *dnsOverHTTPS) createTransportH3( _ string, tlsCfg *tlsC.Config, cfg *quic.Config, - ) (c quic.EarlyConnection, err error) { + ) (c *quic.Conn, err error) { return doh.dialQuic(ctx, addr, tlsCfg, cfg) }, DisableCompression: true, @@ -539,7 +539,7 @@ func (doh *dnsOverHTTPS) createTransportH3( return &http3Transport{baseTransport: rt}, nil } -func (doh *dnsOverHTTPS) dialQuic(ctx context.Context, addr string, tlsCfg *tlsC.Config, cfg *quic.Config) (quic.EarlyConnection, error) { +func (doh *dnsOverHTTPS) dialQuic(ctx context.Context, addr string, tlsCfg *tlsC.Config, cfg *quic.Config) (*quic.Conn, error) { ip, port, err := net.SplitHostPort(addr) if err != nil { return nil, err diff --git a/dns/doq.go b/dns/doq.go index f16300ef..a611265d 100644 --- a/dns/doq.go +++ b/dns/doq.go @@ -53,7 +53,7 @@ type dnsOverQUIC struct { // conn is the current active QUIC connection. It can be closed and // re-opened when needed. - conn quic.Connection + conn *quic.Conn connMu sync.RWMutex // bytesPool is a *sync.Pool we use to store byte buffers in. These byte @@ -157,7 +157,7 @@ func (doq *dnsOverQUIC) ResetConnection() { // exchangeQUIC attempts to open a QUIC connection, send the DNS message // through it and return the response it got from the server. func (doq *dnsOverQUIC) exchangeQUIC(ctx context.Context, msg *D.Msg) (resp *D.Msg, err error) { - var conn quic.Connection + var conn *quic.Conn conn, err = doq.getConnection(ctx, true) if err != nil { return nil, err @@ -169,7 +169,7 @@ func (doq *dnsOverQUIC) exchangeQUIC(ctx context.Context, msg *D.Msg) (resp *D.M return nil, fmt.Errorf("failed to pack DNS message for DoQ: %w", err) } - var stream quic.Stream + var stream *quic.Stream stream, err = doq.openStream(ctx, conn) if err != nil { return nil, err @@ -222,12 +222,12 @@ func (doq *dnsOverQUIC) getBytesPool() (pool *sync.Pool) { return doq.bytesPool } -// getConnection opens or returns an existing quic.Connection. useCached +// getConnection opens or returns an existing *quic.Conn. useCached // argument controls whether we should try to use the existing cached // connection. If it is false, we will forcibly create a new connection and // close the existing one if needed. -func (doq *dnsOverQUIC) getConnection(ctx context.Context, useCached bool) (quic.Connection, error) { - var conn quic.Connection +func (doq *dnsOverQUIC) getConnection(ctx context.Context, useCached bool) (*quic.Conn, error) { + var conn *quic.Conn doq.connMu.RLock() conn = doq.conn if conn != nil && useCached { @@ -282,7 +282,7 @@ func (doq *dnsOverQUIC) resetQUICConfig() { } // openStream opens a new QUIC stream for the specified connection. -func (doq *dnsOverQUIC) openStream(ctx context.Context, conn quic.Connection) (quic.Stream, error) { +func (doq *dnsOverQUIC) openStream(ctx context.Context, conn *quic.Conn) (*quic.Stream, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -302,7 +302,7 @@ func (doq *dnsOverQUIC) openStream(ctx context.Context, conn quic.Connection) (q } // openConnection opens a new QUIC connection. -func (doq *dnsOverQUIC) openConnection(ctx context.Context) (conn quic.Connection, err error) { +func (doq *dnsOverQUIC) openConnection(ctx context.Context) (conn *quic.Conn, err error) { // we're using bootstrapped address instead of what's passed to the function // it does not create an actual connection, but it helps us determine // what IP is actually reachable (when there're v4/v6 addresses). @@ -382,7 +382,7 @@ func (doq *dnsOverQUIC) closeConnWithError(err error) { } // readMsg reads the incoming DNS message from the QUIC stream. -func (doq *dnsOverQUIC) readMsg(stream quic.Stream) (m *D.Msg, err error) { +func (doq *dnsOverQUIC) readMsg(stream *quic.Stream) (m *D.Msg, err error) { pool := doq.getBytesPool() bufPtr := pool.Get().(*[]byte) diff --git a/go.mod b/go.mod index 92b4edd9..4bd156cc 100644 --- a/go.mod +++ b/go.mod @@ -23,11 +23,11 @@ require ( github.com/metacubex/chacha v0.1.5 github.com/metacubex/fswatch v0.1.1 github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 - github.com/metacubex/quic-go v0.52.1-0.20250522021943-aef454b9e639 + github.com/metacubex/quic-go v0.53.1-0.20250628094454-fda5262d1d9c github.com/metacubex/randv2 v0.2.0 github.com/metacubex/sing v0.5.4-0.20250605054047-54dc6097da29 github.com/metacubex/sing-mux v0.3.2 - github.com/metacubex/sing-quic v0.0.0-20250523120938-f1a248e5ec7f + github.com/metacubex/sing-quic v0.0.0-20250628100430-24f13f1e846e github.com/metacubex/sing-shadowsocks v0.2.11-0.20250621023810-0e9ef9dd0c92 github.com/metacubex/sing-shadowsocks2 v0.2.5-0.20250621023950-93d605a2143d github.com/metacubex/sing-shadowtls v0.0.0-20250503063515-5d9f966d17a2 diff --git a/go.sum b/go.sum index 2d850fbb..f089d652 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,8 @@ github.com/metacubex/gvisor v0.0.0-20250324165734-5857f47bd43b h1:RUh4OdVPz/jDrM github.com/metacubex/gvisor v0.0.0-20250324165734-5857f47bd43b/go.mod h1:8LpS0IJW1VmWzUm3ylb0e2SK5QDm5lO/2qwWLZgRpBU= github.com/metacubex/nftables v0.0.0-20250503052935-30a69ab87793 h1:1Qpuy+sU3DmyX9HwI+CrBT/oLNJngvBorR2RbajJcqo= github.com/metacubex/nftables v0.0.0-20250503052935-30a69ab87793/go.mod h1:RjRNb4G52yAgfR+Oe/kp9G4PJJ97Fnj89eY1BFO3YyA= -github.com/metacubex/quic-go v0.52.1-0.20250522021943-aef454b9e639 h1:L+1brQNzBhCCxWlicwfK1TlceemCRmrDE4HmcVHc29w= -github.com/metacubex/quic-go v0.52.1-0.20250522021943-aef454b9e639/go.mod h1:Kc6h++Q/zf3AxcUCevJhJwgrskJumv+pZdR8g/E/10k= +github.com/metacubex/quic-go v0.53.1-0.20250628094454-fda5262d1d9c h1:ABQzmOaZddM3q0OYeoZEc0XF+KW+dUdPNvY/c5rsunI= +github.com/metacubex/quic-go v0.53.1-0.20250628094454-fda5262d1d9c/go.mod h1:eWlAK3zsKI0P8UhYpXlIsl3mtW4D6MpMNuYLIu8CKWI= github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs= github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY= github.com/metacubex/sing v0.5.2/go.mod h1:ypf0mjwlZm0sKdQSY+yQvmsbWa0hNPtkeqyRMGgoN+w= @@ -121,8 +121,8 @@ github.com/metacubex/sing v0.5.4-0.20250605054047-54dc6097da29 h1:SD9q025FNTaepu github.com/metacubex/sing v0.5.4-0.20250605054047-54dc6097da29/go.mod h1:ypf0mjwlZm0sKdQSY+yQvmsbWa0hNPtkeqyRMGgoN+w= github.com/metacubex/sing-mux v0.3.2 h1:nJv52pyRivHcaZJKk2JgxpaVvj1GAXG81scSa9N7ncw= github.com/metacubex/sing-mux v0.3.2/go.mod h1:3rt1soewn0O6j89GCLmwAQFsq257u0jf2zQSPhTL3Bw= -github.com/metacubex/sing-quic v0.0.0-20250523120938-f1a248e5ec7f h1:mP3vIm+9hRFI0C0Vl3pE0NESF/L85FDbuB0tGgUii6I= -github.com/metacubex/sing-quic v0.0.0-20250523120938-f1a248e5ec7f/go.mod h1:JPTpf7fpnojsSuwRJExhSZSy63pVbp3VM39+zj+sAJM= +github.com/metacubex/sing-quic v0.0.0-20250628100430-24f13f1e846e h1:vGl4pQTL/4wZJGQgMOwIInPyI5KwJ1NmFOLrHwORGo0= +github.com/metacubex/sing-quic v0.0.0-20250628100430-24f13f1e846e/go.mod h1:B60FxaPHjR1SeQB0IiLrgwgvKsaoASfOWdiqhLjmMGA= github.com/metacubex/sing-shadowsocks v0.2.11-0.20250621023810-0e9ef9dd0c92 h1:Y9ebcKya6ow7VHoESCN5+l4zZvg5eaL2IhI5LLCQxQA= github.com/metacubex/sing-shadowsocks v0.2.11-0.20250621023810-0e9ef9dd0c92/go.mod h1:/squZ38pXrYjqtg8qn+joVvwbpGNYQNp8yxKsMVbCto= github.com/metacubex/sing-shadowsocks2 v0.2.5-0.20250621023950-93d605a2143d h1:Ey3A1tA8lVkRbK1FDmwuWj/57Nr8JMdpoVqe45mFzJg= diff --git a/transport/hysteria/core/client.go b/transport/hysteria/core/client.go index 03acb943..89f1eff6 100644 --- a/transport/hysteria/core/client.go +++ b/transport/hysteria/core/client.go @@ -41,7 +41,7 @@ type Client struct { tlsConfig *tlsC.Config quicConfig *quic.Config - quicSession quic.Connection + quicSession *quic.Conn reconnectMutex sync.Mutex closed bool @@ -103,7 +103,7 @@ func (c *Client) connectToServer(dialer utils.PacketDialer) error { return nil } -func (c *Client) handleControlStream(qs quic.Connection, stream quic.Stream) (bool, string, error) { +func (c *Client) handleControlStream(qs *quic.Conn, stream *quic.Stream) (bool, string, error) { // Send protocol version _, err := stream.Write([]byte{protocolVersion}) if err != nil { @@ -133,7 +133,7 @@ func (c *Client) handleControlStream(qs quic.Connection, stream quic.Stream) (bo return sh.OK, sh.Message, nil } -func (c *Client) handleMessage(qs quic.Connection) { +func (c *Client) handleMessage(qs *quic.Conn) { for { msg, err := qs.ReceiveDatagram(context.Background()) if err != nil { @@ -162,7 +162,7 @@ func (c *Client) handleMessage(qs quic.Connection) { } } -func (c *Client) openStreamWithReconnect(dialer utils.PacketDialer) (quic.Connection, quic.Stream, error) { +func (c *Client) openStreamWithReconnect(dialer utils.PacketDialer) (*quic.Conn, *wrappedQUICStream, error) { c.reconnectMutex.Lock() defer c.reconnectMutex.Unlock() if c.closed { @@ -298,7 +298,7 @@ func (c *Client) Close() error { } type quicConn struct { - Orig quic.Stream + Orig *wrappedQUICStream PseudoLocalAddr net.Addr PseudoRemoteAddr net.Addr Established bool @@ -360,8 +360,8 @@ type UDPConn interface { } type quicPktConn struct { - Session quic.Connection - Stream quic.Stream + Session *quic.Conn + Stream *wrappedQUICStream CloseFunc func() UDPSessionID uint32 MsgCh <-chan *udpMessage diff --git a/transport/hysteria/core/stream.go b/transport/hysteria/core/stream.go index 627b4789..d220758d 100644 --- a/transport/hysteria/core/stream.go +++ b/transport/hysteria/core/stream.go @@ -9,7 +9,7 @@ import ( // Handle stream close properly // Ref: https://github.com/libp2p/go-libp2p-quic-transport/blob/master/stream.go type wrappedQUICStream struct { - Stream quic.Stream + Stream *quic.Stream } func (s *wrappedQUICStream) StreamID() quic.StreamID { diff --git a/transport/hysteria/transport/client.go b/transport/hysteria/transport/client.go index 7fcc08e1..67f826a3 100644 --- a/transport/hysteria/transport/client.go +++ b/transport/hysteria/transport/client.go @@ -62,7 +62,7 @@ func (ct *ClientTransport) quicPacketConn(proto string, rAddr net.Addr, serverPo } } -func (ct *ClientTransport) QUICDial(proto string, server string, serverPorts string, tlsConfig *tlsC.Config, quicConfig *quic.Config, obfs obfsPkg.Obfuscator, hopInterval time.Duration, dialer utils.PacketDialer) (quic.Connection, error) { +func (ct *ClientTransport) QUICDial(proto string, server string, serverPorts string, tlsConfig *tlsC.Config, quicConfig *quic.Config, obfs obfsPkg.Obfuscator, hopInterval time.Duration, dialer utils.PacketDialer) (*quic.Conn, error) { serverUDPAddr, err := dialer.RemoteAddr(server) if err != nil { return nil, err diff --git a/transport/tuic/common/congestion.go b/transport/tuic/common/congestion.go index a0e2be68..afcf7a78 100644 --- a/transport/tuic/common/congestion.go +++ b/transport/tuic/common/congestion.go @@ -13,7 +13,7 @@ const ( DefaultConnectionReceiveWindow = 67108864 // 64 MB/s ) -func SetCongestionController(quicConn quic.Connection, cc string, cwnd int) { +func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) { if cwnd == 0 { cwnd = 32 } diff --git a/transport/tuic/common/stream.go b/transport/tuic/common/stream.go index e65f9a49..54f91d1c 100644 --- a/transport/tuic/common/stream.go +++ b/transport/tuic/common/stream.go @@ -9,7 +9,7 @@ import ( ) type quicStreamConn struct { - quic.Stream + *quic.Stream lock sync.Mutex lAddr net.Addr rAddr net.Addr @@ -62,6 +62,6 @@ func (q *quicStreamConn) RemoteAddr() net.Addr { var _ net.Conn = (*quicStreamConn)(nil) -func NewQuicStreamConn(stream quic.Stream, lAddr, rAddr net.Addr, closeDeferFn func()) net.Conn { +func NewQuicStreamConn(stream *quic.Stream, lAddr, rAddr net.Addr, closeDeferFn func()) net.Conn { return &quicStreamConn{Stream: stream, lAddr: lAddr, rAddr: rAddr, closeDeferFn: closeDeferFn} } diff --git a/transport/tuic/congestion/bbr_sender.go b/transport/tuic/congestion/bbr_sender.go index 5a863362..93f90ba8 100644 --- a/transport/tuic/congestion/bbr_sender.go +++ b/transport/tuic/congestion/bbr_sender.go @@ -20,7 +20,7 @@ const ( DefaultBBRMaxCongestionWindow = 10000 ) -func GetInitialPacketSize(quicConn quic.Connection) congestion.ByteCount { +func GetInitialPacketSize(quicConn *quic.Conn) congestion.ByteCount { return congestion.ByteCount(quicConn.Config().InitialPacketSize) } diff --git a/transport/tuic/congestion_v2/bbr_sender.go b/transport/tuic/congestion_v2/bbr_sender.go index d8852fbc..a515c2cc 100644 --- a/transport/tuic/congestion_v2/bbr_sender.go +++ b/transport/tuic/congestion_v2/bbr_sender.go @@ -930,6 +930,6 @@ func bdpFromRttAndBandwidth(rtt time.Duration, bandwidth Bandwidth) congestion.B return congestion.ByteCount(rtt) * congestion.ByteCount(bandwidth) / congestion.ByteCount(BytesPerSecond) / congestion.ByteCount(time.Second) } -func GetInitialPacketSize(quicConn quic.Connection) congestion.ByteCount { +func GetInitialPacketSize(quicConn *quic.Conn) congestion.ByteCount { return congestion.ByteCount(quicConn.Config().InitialPacketSize) } diff --git a/transport/tuic/server.go b/transport/tuic/server.go index d31a8625..98c9ee3d 100644 --- a/transport/tuic/server.go +++ b/transport/tuic/server.go @@ -69,7 +69,7 @@ func (s *Server) Close() error { type serverHandler struct { *Server - quicConn quic.EarlyConnection + quicConn *quic.Conn uuid uuid.UUID v4Handler common.ServerHandler @@ -138,7 +138,7 @@ func (s *serverHandler) handleMessage() (err error) { func (s *serverHandler) handleStream() (err error) { for { - var quicStream quic.Stream + var quicStream *quic.Stream quicStream, err = s.quicConn.AcceptStream(context.Background()) if err != nil { return err @@ -175,7 +175,7 @@ func (s *serverHandler) handleStream() (err error) { func (s *serverHandler) handleUniStream() (err error) { for { - var stream quic.ReceiveStream + var stream *quic.ReceiveStream stream, err = s.quicConn.AcceptUniStream(context.Background()) if err != nil { return err diff --git a/transport/tuic/v4/client.go b/transport/tuic/v4/client.go index b5b32917..afa83d82 100644 --- a/transport/tuic/v4/client.go +++ b/transport/tuic/v4/client.go @@ -42,7 +42,7 @@ type clientImpl struct { *ClientOption udp bool - quicConn quic.Connection + quicConn *quic.Conn connMutex sync.Mutex openStreams atomic.Int64 @@ -71,7 +71,7 @@ func (t *clientImpl) SetLastVisited(last time.Time) { t.lastVisited.Store(last) } -func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn common.DialFunc) (quic.Connection, error) { +func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn common.DialFunc) (*quic.Conn, error) { t.connMutex.Lock() defer t.connMutex.Unlock() if t.quicConn != nil { @@ -81,7 +81,7 @@ func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn co if err != nil { return nil, err } - var quicConn quic.Connection + var quicConn *quic.Conn if t.ReduceRtt { quicConn, err = transport.DialEarly(ctx, addr, t.TlsConfig, t.QuicConfig) } else { @@ -113,7 +113,7 @@ func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn co return quicConn, nil } -func (t *clientImpl) sendAuthentication(quicConn quic.Connection) (err error) { +func (t *clientImpl) sendAuthentication(quicConn *quic.Conn) (err error) { defer func() { t.deferQuicConn(quicConn, err) }() @@ -138,12 +138,12 @@ func (t *clientImpl) sendAuthentication(quicConn quic.Connection) (err error) { return nil } -func (t *clientImpl) handleUniStream(quicConn quic.Connection) (err error) { +func (t *clientImpl) handleUniStream(quicConn *quic.Conn) (err error) { defer func() { t.deferQuicConn(quicConn, err) }() for { - var stream quic.ReceiveStream + var stream *quic.ReceiveStream stream, err = quicConn.AcceptUniStream(context.Background()) if err != nil { return err @@ -189,7 +189,7 @@ func (t *clientImpl) handleUniStream(quicConn quic.Connection) (err error) { } } -func (t *clientImpl) handleMessage(quicConn quic.Connection) (err error) { +func (t *clientImpl) handleMessage(quicConn *quic.Conn) (err error) { defer func() { t.deferQuicConn(quicConn, err) }() @@ -237,14 +237,14 @@ func (t *clientImpl) handleMessage(quicConn quic.Connection) (err error) { } } -func (t *clientImpl) deferQuicConn(quicConn quic.Connection, err error) { +func (t *clientImpl) deferQuicConn(quicConn *quic.Conn, err error) { var netError net.Error if err != nil && errors.As(err, &netError) { t.forceClose(quicConn, err) } } -func (t *clientImpl) forceClose(quicConn quic.Connection, err error) { +func (t *clientImpl) forceClose(quicConn *quic.Conn, err error) { t.connMutex.Lock() defer t.connMutex.Unlock() if quicConn == nil { diff --git a/transport/tuic/v4/packet.go b/transport/tuic/v4/packet.go index 47484e78..f463e78c 100644 --- a/transport/tuic/v4/packet.go +++ b/transport/tuic/v4/packet.go @@ -15,13 +15,13 @@ import ( type quicStreamPacketConn struct { connId uint32 - quicConn quic.Connection + quicConn *quic.Conn inputConn *N.BufferedConn udpRelayMode common.UdpRelayMode maxUdpRelayPacketSize int - deferQuicConnFn func(quicConn quic.Connection, err error) + deferQuicConnFn func(quicConn *quic.Conn, err error) closeDeferFn func() writeClosed *atomic.Bool @@ -57,7 +57,7 @@ func (q *quicStreamPacketConn) close() (err error) { if err != nil { return } - var stream quic.SendStream + var stream *quic.SendStream stream, err = q.quicConn.OpenUniStream() if err != nil { return @@ -149,7 +149,7 @@ func (q *quicStreamPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err erro } switch q.udpRelayMode { case common.QUIC: - var stream quic.SendStream + var stream *quic.SendStream stream, err = q.quicConn.OpenUniStream() if err != nil { return diff --git a/transport/tuic/v4/server.go b/transport/tuic/v4/server.go index 2430866f..62ba5a58 100644 --- a/transport/tuic/v4/server.go +++ b/transport/tuic/v4/server.go @@ -28,7 +28,7 @@ type ServerOption struct { MaxUdpRelayPacketSize int } -func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid uuid.UUID) common.ServerHandler { +func NewServerHandler(option *ServerOption, quicConn *quic.Conn, uuid uuid.UUID) common.ServerHandler { return &serverHandler{ ServerOption: option, quicConn: quicConn, @@ -40,7 +40,7 @@ func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid type serverHandler struct { *ServerOption - quicConn quic.EarlyConnection + quicConn *quic.Conn uuid uuid.UUID authCh chan struct{} diff --git a/transport/tuic/v5/client.go b/transport/tuic/v5/client.go index d8660cad..ff6fbc3e 100644 --- a/transport/tuic/v5/client.go +++ b/transport/tuic/v5/client.go @@ -41,7 +41,7 @@ type clientImpl struct { *ClientOption udp bool - quicConn quic.Connection + quicConn *quic.Conn connMutex sync.Mutex openStreams atomic.Int64 @@ -70,7 +70,7 @@ func (t *clientImpl) SetLastVisited(last time.Time) { t.lastVisited.Store(last) } -func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn common.DialFunc) (quic.Connection, error) { +func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn common.DialFunc) (*quic.Conn, error) { t.connMutex.Lock() defer t.connMutex.Unlock() if t.quicConn != nil { @@ -80,7 +80,7 @@ func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn co if err != nil { return nil, err } - var quicConn quic.Connection + var quicConn *quic.Conn if t.ReduceRtt { quicConn, err = transport.DialEarly(ctx, addr, t.TlsConfig, t.QuicConfig) } else { @@ -110,7 +110,7 @@ func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn co return quicConn, nil } -func (t *clientImpl) sendAuthentication(quicConn quic.Connection) (err error) { +func (t *clientImpl) sendAuthentication(quicConn *quic.Conn) (err error) { defer func() { t.deferQuicConn(quicConn, err) }() @@ -139,12 +139,12 @@ func (t *clientImpl) sendAuthentication(quicConn quic.Connection) (err error) { return nil } -func (t *clientImpl) handleUniStream(quicConn quic.Connection) (err error) { +func (t *clientImpl) handleUniStream(quicConn *quic.Conn) (err error) { defer func() { t.deferQuicConn(quicConn, err) }() for { - var stream quic.ReceiveStream + var stream *quic.ReceiveStream stream, err = quicConn.AcceptUniStream(context.Background()) if err != nil { return err @@ -190,7 +190,7 @@ func (t *clientImpl) handleUniStream(quicConn quic.Connection) (err error) { } } -func (t *clientImpl) handleMessage(quicConn quic.Connection) (err error) { +func (t *clientImpl) handleMessage(quicConn *quic.Conn) (err error) { defer func() { t.deferQuicConn(quicConn, err) }() @@ -245,14 +245,14 @@ func (t *clientImpl) handleMessage(quicConn quic.Connection) (err error) { } } -func (t *clientImpl) deferQuicConn(quicConn quic.Connection, err error) { +func (t *clientImpl) deferQuicConn(quicConn *quic.Conn, err error) { var netError net.Error if err != nil && errors.As(err, &netError) { t.forceClose(quicConn, err) } } -func (t *clientImpl) forceClose(quicConn quic.Connection, err error) { +func (t *clientImpl) forceClose(quicConn *quic.Conn, err error) { t.connMutex.Lock() defer t.connMutex.Unlock() if quicConn == nil { diff --git a/transport/tuic/v5/frag.go b/transport/tuic/v5/frag.go index d680a5d0..7f6820ee 100644 --- a/transport/tuic/v5/frag.go +++ b/transport/tuic/v5/frag.go @@ -16,7 +16,7 @@ import ( // "-3" from quic-go's DatagramFrame.MaxDataLen var MaxFragSize = 1200 - PacketOverHead - 3 -func fragWriteNative(quicConn quic.Connection, packet Packet, buf *bytes.Buffer, fragSize int) (err error) { +func fragWriteNative(quicConn *quic.Conn, packet Packet, buf *bytes.Buffer, fragSize int) (err error) { fullPayload := packet.DATA off := 0 fragID := uint8(0) diff --git a/transport/tuic/v5/packet.go b/transport/tuic/v5/packet.go index 8281a11e..5fc706f9 100644 --- a/transport/tuic/v5/packet.go +++ b/transport/tuic/v5/packet.go @@ -17,13 +17,13 @@ import ( type quicStreamPacketConn struct { connId uint16 - quicConn quic.Connection + quicConn *quic.Conn inputConn *N.BufferedConn udpRelayMode common.UdpRelayMode maxUdpRelayPacketSize int - deferQuicConnFn func(quicConn quic.Connection, err error) + deferQuicConnFn func(quicConn *quic.Conn, err error) closeDeferFn func() writeClosed *atomic.Bool @@ -61,7 +61,7 @@ func (q *quicStreamPacketConn) close() (err error) { if err != nil { return } - var stream quic.SendStream + var stream *quic.SendStream stream, err = q.quicConn.OpenUniStream() if err != nil { return @@ -165,7 +165,7 @@ func (q *quicStreamPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err erro if err != nil { return } - var stream quic.SendStream + var stream *quic.SendStream stream, err = q.quicConn.OpenUniStream() if err != nil { return diff --git a/transport/tuic/v5/server.go b/transport/tuic/v5/server.go index 8454b64c..31bedf35 100644 --- a/transport/tuic/v5/server.go +++ b/transport/tuic/v5/server.go @@ -27,7 +27,7 @@ type ServerOption struct { MaxUdpRelayPacketSize int } -func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid uuid.UUID) common.ServerHandler { +func NewServerHandler(option *ServerOption, quicConn *quic.Conn, uuid uuid.UUID) common.ServerHandler { return &serverHandler{ ServerOption: option, quicConn: quicConn, @@ -39,7 +39,7 @@ func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid type serverHandler struct { *ServerOption - quicConn quic.EarlyConnection + quicConn *quic.Conn uuid uuid.UUID authCh chan struct{}