Skip to content

Commit

Permalink
WIP update quic-go to v0.42 (unreleased)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 9, 2024
1 parent 4f3d108 commit a1fabea
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
9 changes: 8 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package webtransport

import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -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
Expand All @@ -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")
}

Check warning on line 94 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L93-L94

Added lines #L93 - L94 were not covered by tests

u, err := url.Parse(urlStr)
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions webtransport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a1fabea

Please sign in to comment.