From 0a98be94a78e088c211c7bb58a84d71287e37b34 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 1 Aug 2023 00:06:22 +0200 Subject: [PATCH] Update quic-go to fix two regressions --- go.mod | 2 +- go.sum | 4 ++-- .../github.com/quic-go/quic-go/connection.go | 2 ++ .../quic-go/quic-go/http3/client.go | 4 ++-- .../quic-go/internal/handshake/conn.go | 21 +++++++++++++++++++ .../internal/handshake/crypto_setup.go | 9 ++++++++ vendor/modules.txt | 2 +- 7 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 vendor/github.com/quic-go/quic-go/internal/handshake/conn.go diff --git a/go.mod b/go.mod index e68b17a143..c5fe8869ed 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/kardianos/service v1.2.2 github.com/miekg/dns v1.1.55 github.com/powerman/check v1.7.0 - github.com/quic-go/quic-go v0.37.0 + github.com/quic-go/quic-go v0.37.1 golang.org/x/crypto v0.11.0 golang.org/x/net v0.12.0 golang.org/x/sys v0.10.0 diff --git a/go.sum b/go.sum index 88dc820896..e35debea4a 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,8 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/qtls-go1-20 v0.3.0 h1:NrCXmDl8BddZwO67vlvEpBTwT89bJfKYygxv4HQvuDk= github.com/quic-go/qtls-go1-20 v0.3.0/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.37.0 h1:wf/Ym2yeWi98oQn4ahiBSqdnaXVxNQGj2oBQFgiVChc= -github.com/quic-go/quic-go v0.37.0/go.mod h1:XtCUOCALTTWbPyd0IxFfHf6h0sEMubRFvEYHl3QxKw8= +github.com/quic-go/quic-go v0.37.1 h1:M+mcsFq9KoxVjCetIwH65TvusW1UdRBc6zmxI6pkeD0= +github.com/quic-go/quic-go v0.37.1/go.mod h1:XtCUOCALTTWbPyd0IxFfHf6h0sEMubRFvEYHl3QxKw8= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= diff --git a/vendor/github.com/quic-go/quic-go/connection.go b/vendor/github.com/quic-go/quic-go/connection.go index bb4d691eee..eede6929e0 100644 --- a/vendor/github.com/quic-go/quic-go/connection.go +++ b/vendor/github.com/quic-go/quic-go/connection.go @@ -315,6 +315,8 @@ var newConnection = func( } cs := handshake.NewCryptoSetupServer( clientDestConnID, + conn.LocalAddr(), + conn.RemoteAddr(), params, tlsConf, conf.Allow0RTT, diff --git a/vendor/github.com/quic-go/quic-go/http3/client.go b/vendor/github.com/quic-go/quic-go/http3/client.go index d53391f080..cc2400e2c0 100644 --- a/vendor/github.com/quic-go/quic-go/http3/client.go +++ b/vendor/github.com/quic-go/quic-go/http3/client.go @@ -429,8 +429,8 @@ func (c *client) doRequest(req *http.Request, conn quic.EarlyConnection, str qui // Check that the server doesn't send more data in DATA frames than indicated by the Content-Length header (if set). // See section 4.1.2 of RFC 9114. var httpStr Stream - if _, ok := req.Header["Content-Length"]; ok && req.ContentLength >= 0 { - httpStr = newLengthLimitedStream(hstr, req.ContentLength) + if _, ok := res.Header["Content-Length"]; ok && res.ContentLength >= 0 { + httpStr = newLengthLimitedStream(hstr, res.ContentLength) } else { httpStr = hstr } diff --git a/vendor/github.com/quic-go/quic-go/internal/handshake/conn.go b/vendor/github.com/quic-go/quic-go/internal/handshake/conn.go new file mode 100644 index 0000000000..54af823ba2 --- /dev/null +++ b/vendor/github.com/quic-go/quic-go/internal/handshake/conn.go @@ -0,0 +1,21 @@ +package handshake + +import ( + "net" + "time" +) + +type conn struct { + localAddr, remoteAddr net.Addr +} + +var _ net.Conn = &conn{} + +func (c *conn) Read([]byte) (int, error) { return 0, nil } +func (c *conn) Write([]byte) (int, error) { return 0, nil } +func (c *conn) Close() error { return nil } +func (c *conn) RemoteAddr() net.Addr { return c.remoteAddr } +func (c *conn) LocalAddr() net.Addr { return c.localAddr } +func (c *conn) SetReadDeadline(time.Time) error { return nil } +func (c *conn) SetWriteDeadline(time.Time) error { return nil } +func (c *conn) SetDeadline(time.Time) error { return nil } diff --git a/vendor/github.com/quic-go/quic-go/internal/handshake/crypto_setup.go b/vendor/github.com/quic-go/quic-go/internal/handshake/crypto_setup.go index 66ed04d6bf..b528f08ebf 100644 --- a/vendor/github.com/quic-go/quic-go/internal/handshake/crypto_setup.go +++ b/vendor/github.com/quic-go/quic-go/internal/handshake/crypto_setup.go @@ -6,6 +6,7 @@ import ( "crypto/tls" "errors" "fmt" + "net" "sync" "sync/atomic" "time" @@ -104,6 +105,7 @@ func NewCryptoSetupClient( // NewCryptoSetupServer creates a new crypto setup for the server func NewCryptoSetupServer( connID protocol.ConnectionID, + localAddr, remoteAddr net.Addr, tp *wire.TransportParameters, tlsConf *tls.Config, allow0RTT bool, @@ -125,6 +127,13 @@ func NewCryptoSetupServer( quicConf := &qtls.QUICConfig{TLSConfig: tlsConf} qtls.SetupConfigForServer(quicConf, cs.allow0RTT, cs.getDataForSessionTicket, cs.accept0RTT) + if quicConf.TLSConfig.GetConfigForClient != nil { + gcfc := quicConf.TLSConfig.GetConfigForClient + quicConf.TLSConfig.GetConfigForClient = func(info *tls.ClientHelloInfo) (*tls.Config, error) { + info.Conn = &conn{localAddr: localAddr, remoteAddr: remoteAddr} + return gcfc(info) + } + } cs.tlsConf = quicConf.TLSConfig cs.conn = qtls.QUICServer(quicConf) diff --git a/vendor/modules.txt b/vendor/modules.txt index 5931f32c3d..885eabfdda 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -109,7 +109,7 @@ github.com/quic-go/qpack # github.com/quic-go/qtls-go1-20 v0.3.0 ## explicit; go 1.20 github.com/quic-go/qtls-go1-20 -# github.com/quic-go/quic-go v0.37.0 +# github.com/quic-go/quic-go v0.37.1 ## explicit; go 1.20 github.com/quic-go/quic-go github.com/quic-go/quic-go/http3