Skip to content

Commit 9426b60

Browse files
committed
TUN-7227: Migrate to devincarr/quic-go
The lucas-clemente/quic-go package moved namespaces and our branch went stale, this new fork provides support for the new quic-go repo and applies the max datagram frame size change. Until the max datagram frame size support gets upstreamed into quic-go, this can be used to unblock go 1.20 support as the old lucas-clemente/quic-go will not get go 1.20 support.
1 parent ff9621b commit 9426b60

File tree

506 files changed

+26520
-41963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

506 files changed

+26520
-41963
lines changed

connection/quic.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"time"
1717

1818
"github.com/google/uuid"
19-
"github.com/lucas-clemente/quic-go"
2019
"github.com/pkg/errors"
20+
"github.com/quic-go/quic-go"
2121
"github.com/rs/zerolog"
2222
"go.opentelemetry.io/otel/attribute"
2323
"go.opentelemetry.io/otel/trace"
@@ -67,6 +67,7 @@ type QUICConnection struct {
6767

6868
// NewQUICConnection returns a new instance of QUICConnection.
6969
func NewQUICConnection(
70+
ctx context.Context,
7071
quicConfig *quic.Config,
7172
edgeAddr net.Addr,
7273
localAddr net.IP,
@@ -83,7 +84,7 @@ func NewQUICConnection(
8384
return nil, err
8485
}
8586

86-
session, err := quic.Dial(udpConn, edgeAddr, edgeAddr.String(), tlsConfig, quicConfig)
87+
session, err := quic.Dial(ctx, udpConn, edgeAddr, tlsConfig, quicConfig)
8788
if err != nil {
8889
// close the udp server socket in case of error connecting to the edge
8990
udpConn.Close()

connection/quic_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
"github.com/gobwas/ws/wsutil"
1818
"github.com/google/uuid"
19-
"github.com/lucas-clemente/quic-go"
2019
"github.com/pkg/errors"
20+
"github.com/quic-go/quic-go"
2121
"github.com/rs/zerolog"
2222
"github.com/stretchr/testify/assert"
2323
"github.com/stretchr/testify/require"
@@ -32,9 +32,8 @@ import (
3232
var (
3333
testTLSServerConfig = quicpogs.GenerateTLSConfig()
3434
testQUICConfig = &quic.Config{
35-
ConnectionIDLength: 16,
36-
KeepAlivePeriod: 5 * time.Second,
37-
EnableDatagrams: true,
35+
KeepAlivePeriod: 5 * time.Second,
36+
EnableDatagrams: true,
3837
}
3938
)
4039

@@ -43,13 +42,6 @@ var _ ReadWriteAcker = (*streamReadWriteAcker)(nil)
4342
// TestQUICServer tests if a quic server accepts and responds to a quic client with the acceptance protocol.
4443
// It also serves as a demonstration for communication with the QUIC connection started by a cloudflared.
4544
func TestQUICServer(t *testing.T) {
46-
// Start a UDP Listener for QUIC.
47-
udpAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0")
48-
require.NoError(t, err)
49-
udpListener, err := net.ListenUDP(udpAddr.Network(), udpAddr)
50-
require.NoError(t, err)
51-
defer udpListener.Close()
52-
5345
// This is simply a sample websocket frame message.
5446
wsBuf := &bytes.Buffer{}
5547
wsutil.WriteClientBinary(wsBuf, []byte("Hello"))
@@ -145,8 +137,14 @@ func TestQUICServer(t *testing.T) {
145137
test := test // capture range variable
146138
t.Run(test.desc, func(t *testing.T) {
147139
ctx, cancel := context.WithCancel(context.Background())
148-
149-
quicListener, err := quic.Listen(udpListener, testTLSServerConfig, testQUICConfig)
140+
// Start a UDP Listener for QUIC.
141+
udpAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0")
142+
require.NoError(t, err)
143+
udpListener, err := net.ListenUDP(udpAddr.Network(), udpAddr)
144+
require.NoError(t, err)
145+
defer udpListener.Close()
146+
quicTransport := &quic.Transport{Conn: udpListener, ConnectionIDLength: 16}
147+
quicListener, err := quicTransport.Listen(testTLSServerConfig, testQUICConfig)
150148
require.NoError(t, err)
151149

152150
serverDone := make(chan struct{})
@@ -187,7 +185,7 @@ func (fakeControlStream) IsStopped() bool {
187185
func quicServer(
188186
ctx context.Context,
189187
t *testing.T,
190-
listener quic.Listener,
188+
listener *quic.Listener,
191189
dest string,
192190
connectionType quicpogs.ConnectionType,
193191
metadata []quicpogs.Metadata,
@@ -713,7 +711,10 @@ func testQUICConnection(udpListenerAddr net.Addr, t *testing.T, index uint8) *QU
713711
}
714712
// Start a mock httpProxy
715713
log := zerolog.New(os.Stdout)
714+
ctx, cancel := context.WithCancel(context.Background())
715+
defer cancel()
716716
qc, err := NewQUICConnection(
717+
ctx,
717718
testQUICConfig,
718719
udpListenerAddr,
719720
nil,

datagramsession/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type Session struct {
5151

5252
func (s *Session) Serve(ctx context.Context, closeAfterIdle time.Duration) (closedByRemote bool, err error) {
5353
go func() {
54-
// QUIC implementation copies data to another buffer before returning https://github.com/lucas-clemente/quic-go/blob/v0.24.0/session.go#L1967-L1975
54+
// QUIC implementation copies data to another buffer before returning https://github.com/quic-go/quic-go/blob/v0.24.0/session.go#L1967-L1975
5555
// This makes it safe to share readBuffer between iterations
5656
const maxPacketSize = 1500
5757
readBuffer := make([]byte, maxPacketSize)

go.mod

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ require (
2020
github.com/google/uuid v1.3.0
2121
github.com/gorilla/websocket v1.4.2
2222
github.com/json-iterator/go v1.1.12
23-
github.com/lucas-clemente/quic-go v0.28.1
2423
github.com/mattn/go-colorable v0.1.13
2524
github.com/miekg/dns v1.1.50
2625
github.com/mitchellh/go-homedir v1.1.0
2726
github.com/pkg/errors v0.9.1
2827
github.com/prometheus/client_golang v1.13.0
2928
github.com/prometheus/client_model v0.2.0
29+
github.com/quic-go/quic-go v0.0.0-00010101000000-000000000000
3030
github.com/rs/zerolog v1.20.0
3131
github.com/stretchr/testify v1.8.1
3232
github.com/urfave/cli/v2 v2.3.0
@@ -57,7 +57,6 @@ require (
5757
github.com/beorn7/perks v1.0.1 // indirect
5858
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect
5959
github.com/cespare/xxhash/v2 v2.1.2 // indirect
60-
github.com/cheekybits/genny v1.0.0 // indirect
6160
github.com/cloudflare/circl v1.2.1-0.20220809205628-0a9554f37a47 // indirect
6261
github.com/coredns/caddy v1.1.1 // indirect
6362
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
@@ -72,29 +71,29 @@ require (
7271
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
7372
github.com/gobwas/httphead v0.0.0-20200921212729-da3d93bc3c58 // indirect
7473
github.com/gobwas/pool v0.2.1 // indirect
74+
github.com/golang/mock v1.6.0 // indirect
7575
github.com/golang/protobuf v1.5.2 // indirect
76+
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
7677
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
7778
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
7879
github.com/klauspost/compress v1.15.11 // indirect
7980
github.com/kr/text v0.2.0 // indirect
8081
github.com/kylelemons/godebug v1.1.0 // indirect
81-
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
82-
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
83-
github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
84-
github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1 // indirect
8582
github.com/mattn/go-isatty v0.0.16 // indirect
8683
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
8784
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
8885
github.com/modern-go/reflect2 v1.0.2 // indirect
89-
github.com/nxadm/tail v1.4.8 // indirect
90-
github.com/onsi/ginkgo v1.16.5 // indirect
86+
github.com/onsi/ginkgo/v2 v2.4.0 // indirect
9187
github.com/onsi/gomega v1.23.0 // indirect
9288
github.com/opentracing/opentracing-go v1.2.0 // indirect
9389
github.com/pmezard/go-difflib v1.0.0 // indirect
9490
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
9591
github.com/prometheus/common v0.37.0 // indirect
9692
github.com/prometheus/procfs v0.8.0 // indirect
93+
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
94+
github.com/quic-go/qtls-go1-20 v0.2.2 // indirect
9795
github.com/russross/blackfriday/v2 v2.1.0 // indirect
96+
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
9897
golang.org/x/mod v0.8.0 // indirect
9998
golang.org/x/oauth2 v0.4.0 // indirect
10099
golang.org/x/text v0.9.0 // indirect
@@ -103,26 +102,21 @@ require (
103102
google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd // indirect
104103
google.golang.org/grpc v1.51.0 // indirect
105104
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
106-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
107105
gopkg.in/yaml.v2 v2.4.0 // indirect
108106
)
109107

110108
replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d
111109

112-
replace github.com/lucas-clemente/quic-go => github.com/chungthuang/quic-go v0.27.1-0.20220809135021-ca330f1dec9f
113-
114110
// Avoid 'CVE-2022-21698'
115111
replace github.com/prometheus/golang_client => github.com/prometheus/golang_client v1.12.1
116112

117113
replace gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
118114

115+
replace github.com/quic-go/quic-go => github.com/devincarr/quic-go v0.0.0-20230502200822-d1f4edacbee7
116+
119117
// Post-quantum tunnel RTG-1339
120118
replace (
121-
// Branches go1.18 go1.19 go1.20 on github.com/cloudflare/qtls-pq
122-
github.com/marten-seemann/qtls-go1-18 => github.com/cloudflare/qtls-pq v0.0.0-20230103171413-e7a2fb559a0e
123-
github.com/marten-seemann/qtls-go1-19 => github.com/cloudflare/qtls-pq v0.0.0-20230103171656-05e84f90909e
124-
github.com/marten-seemann/qtls-go1-20 => github.com/cloudflare/qtls-pq v0.0.0-20230215110727-8b4e1699c2a8
125-
github.com/quic-go/qtls-go1-18 => github.com/cloudflare/qtls-pq v0.0.0-20230103171413-e7a2fb559a0e
126-
github.com/quic-go/qtls-go1-19 => github.com/cloudflare/qtls-pq v0.0.0-20230103171656-05e84f90909e
127-
github.com/quic-go/qtls-go1-20 => github.com/cloudflare/qtls-pq v0.0.0-20230215110727-8b4e1699c2a8
119+
// Branches go1.19 go1.20 on github.com/cloudflare/qtls-pq
120+
github.com/quic-go/qtls-go1-19 => github.com/cloudflare/qtls-pq v0.0.0-20230320123031-3faac1a945b2
121+
github.com/quic-go/qtls-go1-20 => github.com/cloudflare/qtls-pq v0.0.0-20230320122459-4ed280d0d633
128122
)

0 commit comments

Comments
 (0)