mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-07-18 17:08:06 +08:00
chore: update quic-go to 0.53.0
This commit is contained in:
12
dns/doh.go
12
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
|
||||
|
18
dns/doq.go
18
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)
|
||||
|
||||
|
4
go.mod
4
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
|
||||
|
8
go.sum
8
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=
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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{}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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{}
|
||||
|
Reference in New Issue
Block a user