From a1fabea0849bdd71eaacf8c25c1eec847f9c81cc Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 9 Mar 2024 11:12:15 +0930 Subject: [PATCH] WIP update quic-go to v0.42 (unreleased) --- client.go | 9 ++++++++- go.mod | 2 +- go.sum | 4 ++-- server.go | 2 +- webtransport_test.go | 8 ++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index 86e841c..4d49381 100644 --- a/client.go +++ b/client.go @@ -2,6 +2,7 @@ package webtransport import ( "context" + "errors" "fmt" "net/http" "net/url" @@ -76,7 +77,7 @@ func (d *Dialer) init() { return true } if d.QuicConfig == nil { - d.QuicConfig = &quic.Config{} + d.QuicConfig = &quic.Config{EnableDatagrams: true} } if d.QuicConfig.MaxIncomingStreams == 0 { d.QuicConfig.MaxIncomingStreams = 100 @@ -86,6 +87,12 @@ func (d *Dialer) init() { func (d *Dialer) Dial(ctx context.Context, urlStr string, reqHdr http.Header) (*http.Response, *Session, error) { d.initOnce.Do(func() { d.init() }) + // Technically, this is not true. DATAGRAMs could be sent using the Capsule protocol. + // However, quic-go currently enforces QUIC datagram support if HTTP/3 datagrams are enabled. + if !d.QuicConfig.EnableDatagrams { + return nil, nil, errors.New("WebTransport requires DATAGRAM support, enable it via QuicConfig.EnableDatagrams") + } + u, err := url.Parse(urlStr) if err != nil { return nil, nil, err diff --git a/go.mod b/go.mod index 972ebda..91cb48b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/quic-go/webtransport-go go 1.21 require ( - github.com/quic-go/quic-go v0.41.0 + github.com/quic-go/quic-go v0.41.1-0.20240307003735-ac1268911e6a github.com/stretchr/testify v1.8.0 go.uber.org/mock v0.3.0 ) diff --git a/go.sum b/go.sum index af23ab9..6e94388 100644 --- a/go.sum +++ b/go.sum @@ -92,8 +92,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 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/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= -github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= +github.com/quic-go/quic-go v0.41.1-0.20240307003735-ac1268911e6a h1:sV/zFH1BAvpw84cpuPigs8vgpA+tLoAi85XfpWpvfN8= +github.com/quic-go/quic-go v0.41.1-0.20240307003735-ac1268911e6a/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= diff --git a/server.go b/server.go index 7b61346..90cf1c3 100644 --- a/server.go +++ b/server.go @@ -73,7 +73,7 @@ func (s *Server) init() error { // configure the http3.Server if s.H3.AdditionalSettings == nil { - s.H3.AdditionalSettings = make(map[uint64]uint64) + s.H3.AdditionalSettings = make(map[uint64]uint64, 1) } s.H3.AdditionalSettings[settingsEnableWebtransport] = 1 s.H3.EnableDatagrams = true diff --git a/webtransport_test.go b/webtransport_test.go index cd04fba..41188c4 100644 --- a/webtransport_test.go +++ b/webtransport_test.go @@ -71,7 +71,7 @@ func establishSession(t *testing.T, handler func(*webtransport.Session)) (sess * s := &webtransport.Server{ H3: http3.Server{ TLSConfig: tlsConf, - QuicConfig: &quic.Config{Tracer: getQlogger(t)}, + QuicConfig: &quic.Config{Tracer: getQlogger(t), EnableDatagrams: true}, }, } addHandler(t, s, handler) @@ -80,7 +80,7 @@ func establishSession(t *testing.T, handler func(*webtransport.Session)) (sess * d := webtransport.Dialer{ RoundTripper: &http3.RoundTripper{ TLSClientConfig: &tls.Config{RootCAs: certPool}, - QuicConfig: &quic.Config{Tracer: getQlogger(t)}, + QuicConfig: &quic.Config{Tracer: getQlogger(t), EnableDatagrams: true}, }, } defer d.Close() @@ -344,7 +344,7 @@ func TestMultipleClients(t *testing.T) { d := webtransport.Dialer{ RoundTripper: &http3.RoundTripper{ TLSClientConfig: &tls.Config{RootCAs: certPool}, - QuicConfig: &quic.Config{Tracer: getQlogger(t)}, + QuicConfig: &quic.Config{Tracer: getQlogger(t), EnableDatagrams: true}, }, } defer d.Close() @@ -524,7 +524,7 @@ func TestCheckOrigin(t *testing.T) { d := webtransport.Dialer{ RoundTripper: &http3.RoundTripper{ TLSClientConfig: &tls.Config{RootCAs: certPool}, - QuicConfig: &quic.Config{Tracer: getQlogger(t)}, + QuicConfig: &quic.Config{Tracer: getQlogger(t), EnableDatagrams: true}, }, } defer d.Close()