From 7f3eeb4e6bdb55885453daac47e9ba847a9f5fe9 Mon Sep 17 00:00:00 2001 From: YUNRU Date: Wed, 17 Jul 2024 09:51:10 +0800 Subject: [PATCH] fix: connection doesn't allow setting of receive buffer size. Not a *net.UDPConn?. --- transport/internet/splithttp/client.go | 2 +- transport/internet/splithttp/dialer.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 5876389e514b..2a467d7dab93 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -119,7 +119,7 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, } req.Header = c.transportConfig.GetRequestHeader() - if c.isH2 { + if c.isH2 || c.isH3 { resp, err := c.upload.Do(req) if err != nil { return err diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 3397ac9b011a..9f98da3d96fa 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -86,12 +86,13 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in var uploadTransport http.RoundTripper if isH3 { + dest.Network = net.Network_UDP quicConfig := &quic.Config{ HandshakeIdleTimeout: 10 * time.Second, MaxIdleTimeout: 90 * time.Second, KeepAlivePeriod: 3 * time.Second, + Allow0RTT: true, } - dest.Network = net.Network_UDP roundTripper := &http3.RoundTripper{ TLSClientConfig: gotlsConfig, QUICConfig: quicConfig, @@ -100,11 +101,11 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in if err != nil { return nil, err } - udpAddr,err := net.ResolveUDPAddr("udp",conn.RemoteAddr().String()) + udpAddr, err := net.ResolveUDPAddr("udp", conn.RemoteAddr().String()) if err != nil { return nil, err } - return quic.DialEarly(ctx, conn.(net.PacketConn), udpAddr, tlsCfg, cfg) + return quic.DialEarly(ctx, conn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn), udpAddr, tlsCfg, cfg) }, } downloadTransport = roundTripper