set the QUIC version for integration tests using a command line flag

This commit is contained in:
Marten Seemann 2023-04-22 12:29:26 +02:00
parent 0dbe595d9f
commit 2b0a03a988
21 changed files with 2471 additions and 2595 deletions

View file

@ -20,19 +20,24 @@ jobs:
- run: go version - run: go version
- name: set qlogger - name: set qlogger
if: env.DEBUG == 'true' if: env.DEBUG == 'true'
run: echo "QLOGFLAG=-- -qlog" >> $GITHUB_ENV run: echo "QLOGFLAG= -qlog" >> $GITHUB_ENV
- name: Run tests - name: Run other tests
run: | run: |
go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace -skip-package self,versionnegotiation integrationtests go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace -skip-package self,versionnegotiation integrationtests
go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/versionnegotiation ${{ env.QLOGFLAG }} go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/versionnegotiation -- ${{ env.QLOGFLAG }}
go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self ${{ env.QLOGFLAG }} - name: Run self tests, using draft-29
run: go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self -- -version=draft29 ${{ env.QLOGFLAG }}
- name: Run self tests, using QUIC v1
run: go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self -- -version=1 ${{ env.QLOGFLAG }}
- name: Run self tests, using QUIC v2
run: go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self -- -version=2 ${{ env.QLOGFLAG }}
- name: Run tests (32 bit) - name: Run tests (32 bit)
env: env:
GOARCH: 386 GOARCH: 386
run: | run: |
go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace -skip-package self,versionnegotiation integrationtests go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace -skip-package self,versionnegotiation integrationtests
go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/versionnegotiation ${{ env.QLOGFLAG }} go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/versionnegotiation -- ${{ env.QLOGFLAG }}
go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self ${{ env.QLOGFLAG }} go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self -- ${{ env.QLOGFLAG }}
- name: save qlogs - name: save qlogs
if: ${{ always() && env.DEBUG == 'true' }} if: ${{ always() && env.DEBUG == 'true' }}
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2

View file

@ -33,7 +33,6 @@ const (
var defaultQuicConfig = &quic.Config{ var defaultQuicConfig = &quic.Config{
MaxIncomingStreams: -1, // don't allow the server to create bidirectional streams MaxIncomingStreams: -1, // don't allow the server to create bidirectional streams
KeepAlivePeriod: 10 * time.Second, KeepAlivePeriod: 10 * time.Second,
Versions: []protocol.VersionNumber{protocol.Version1},
} }
type dialFunc func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) type dialFunc func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
@ -74,9 +73,10 @@ var _ roundTripCloser = &client{}
func newClient(hostname string, tlsConf *tls.Config, opts *roundTripperOpts, conf *quic.Config, dialer dialFunc) (roundTripCloser, error) { func newClient(hostname string, tlsConf *tls.Config, opts *roundTripperOpts, conf *quic.Config, dialer dialFunc) (roundTripCloser, error) {
if conf == nil { if conf == nil {
conf = defaultQuicConfig.Clone() conf = defaultQuicConfig.Clone()
} else if len(conf.Versions) == 0 { }
if len(conf.Versions) == 0 {
conf = conf.Clone() conf = conf.Clone()
conf.Versions = []quic.VersionNumber{defaultQuicConfig.Versions[0]} conf.Versions = []quic.VersionNumber{protocol.SupportedVersions[0]}
} }
if len(conf.Versions) != 1 { if len(conf.Versions) != 1 {
return nil, errors.New("can only use a single QUIC version for dialing a HTTP/3 connection") return nil, errors.New("can only use a single QUIC version for dialing a HTTP/3 connection")

View file

@ -65,7 +65,7 @@ var _ = Describe("Client", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
var dialAddrCalled bool var dialAddrCalled bool
dialAddr = func(_ context.Context, _ string, tlsConf *tls.Config, quicConf *quic.Config) (quic.EarlyConnection, error) { dialAddr = func(_ context.Context, _ string, tlsConf *tls.Config, quicConf *quic.Config) (quic.EarlyConnection, error) {
Expect(quicConf).To(Equal(defaultQuicConfig)) Expect(quicConf.MaxIncomingStreams).To(Equal(defaultQuicConfig.MaxIncomingStreams))
Expect(tlsConf.NextProtos).To(Equal([]string{NextProtoH3})) Expect(tlsConf.NextProtos).To(Equal([]string{NextProtoH3}))
Expect(quicConf.Versions).To(Equal([]protocol.VersionNumber{protocol.Version1})) Expect(quicConf.Versions).To(Equal([]protocol.VersionNumber{protocol.Version1}))
dialAddrCalled = true dialAddrCalled = true

View file

@ -9,17 +9,12 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = Describe("Connection ID lengths tests", func() { var _ = Describe("Connection ID lengths tests", func() {
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
It("retransmits the CONNECTION_CLOSE packet", func() { It("retransmits the CONNECTION_CLOSE packet", func() {
server, err := quic.ListenAddr( server, err := quic.ListenAddr(
"localhost:0", "localhost:0",
@ -51,7 +46,7 @@ var _ = Describe("Connection ID lengths tests", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -78,5 +73,3 @@ var _ = Describe("Connection ID lengths tests", func() {
} }
}) })
}) })
}
})

View file

@ -32,9 +32,7 @@ func (c *connIDGenerator) ConnectionIDLen() int {
} }
var _ = Describe("Connection ID lengths tests", func() { var _ = Describe("Connection ID lengths tests", func() {
randomConnIDLen := func() int { randomConnIDLen := func() int { return 4 + int(mrand.Int31n(15)) }
return 4 + int(mrand.Int31n(15))
}
runServer := func(conf *quic.Config) quic.Listener { runServer := func(conf *quic.Config) quic.Listener {
GinkgoWriter.Write([]byte(fmt.Sprintf("Using %d byte connection ID for the server\n", conf.ConnectionIDLength))) GinkgoWriter.Write([]byte(fmt.Sprintf("Using %d byte connection ID for the server\n", conf.ConnectionIDLength)))
@ -77,46 +75,32 @@ var _ = Describe("Connection ID lengths tests", func() {
} }
It("downloads a file using a 0-byte connection ID for the client", func() { It("downloads a file using a 0-byte connection ID for the client", func() {
serverConf := getQuicConfig(&quic.Config{ serverConf := getQuicConfig(&quic.Config{ConnectionIDLength: randomConnIDLen()})
ConnectionIDLength: randomConnIDLen(),
Versions: []protocol.VersionNumber{protocol.Version1},
})
clientConf := getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{protocol.Version1},
})
ln := runServer(serverConf) ln := runServer(serverConf)
defer ln.Close() defer ln.Close()
runClient(ln.Addr(), clientConf)
runClient(ln.Addr(), getQuicConfig(nil))
}) })
It("downloads a file when both client and server use a random connection ID length", func() { It("downloads a file when both client and server use a random connection ID length", func() {
serverConf := getQuicConfig(&quic.Config{ serverConf := getQuicConfig(&quic.Config{ConnectionIDLength: randomConnIDLen()})
ConnectionIDLength: randomConnIDLen(),
Versions: []protocol.VersionNumber{protocol.Version1},
})
clientConf := getQuicConfig(&quic.Config{
ConnectionIDLength: randomConnIDLen(),
Versions: []protocol.VersionNumber{protocol.Version1},
})
ln := runServer(serverConf) ln := runServer(serverConf)
defer ln.Close() defer ln.Close()
runClient(ln.Addr(), clientConf)
runClient(ln.Addr(), getQuicConfig(nil))
}) })
It("downloads a file when both client and server use a custom connection ID generator", func() { It("downloads a file when both client and server use a custom connection ID generator", func() {
serverConf := getQuicConfig(&quic.Config{ serverConf := getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{protocol.Version1},
ConnectionIDGenerator: &connIDGenerator{length: randomConnIDLen()}, ConnectionIDGenerator: &connIDGenerator{length: randomConnIDLen()},
}) })
clientConf := getQuicConfig(&quic.Config{ clientConf := getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{protocol.Version1},
ConnectionIDGenerator: &connIDGenerator{length: randomConnIDLen()}, ConnectionIDGenerator: &connIDGenerator{length: randomConnIDLen()},
}) })
ln := runServer(serverConf) ln := runServer(serverConf)
defer ln.Close() defer ln.Close()
runClient(ln.Addr(), clientConf) runClient(ln.Addr(), clientConf)
}) })
}) })

View file

@ -12,7 +12,6 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/wire" "github.com/quic-go/quic-go/internal/wire"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
@ -20,10 +19,6 @@ import (
) )
var _ = Describe("Datagram test", func() { var _ = Describe("Datagram test", func() {
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
const num = 100 const num = 100
var ( var (
@ -40,10 +35,7 @@ var _ = Describe("Datagram test", func() {
ln, err := quic.Listen( ln, err := quic.Listen(
serverConn, serverConn,
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{EnableDatagrams: enableDatagram}),
EnableDatagrams: enableDatagram,
Versions: []protocol.VersionNumber{version},
}),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -117,10 +109,7 @@ var _ = Describe("Datagram test", func() {
raddr, raddr,
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{EnableDatagrams: true}),
EnableDatagrams: true,
Versions: []protocol.VersionNumber{version},
}),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(conn.ConnectionState().SupportsDatagrams).To(BeTrue()) Expect(conn.ConnectionState().SupportsDatagrams).To(BeTrue())
@ -156,10 +145,7 @@ var _ = Describe("Datagram test", func() {
raddr, raddr,
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{EnableDatagrams: true}),
EnableDatagrams: true,
Versions: []protocol.VersionNumber{version},
}),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(conn.ConnectionState().SupportsDatagrams).To(BeFalse()) Expect(conn.ConnectionState().SupportsDatagrams).To(BeFalse())
@ -177,10 +163,7 @@ var _ = Describe("Datagram test", func() {
raddr, raddr,
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{EnableDatagrams: true}),
EnableDatagrams: true,
Versions: []protocol.VersionNumber{version},
}),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(conn.ConnectionState().SupportsDatagrams).To(BeFalse()) Expect(conn.ConnectionState().SupportsDatagrams).To(BeFalse())
@ -190,5 +173,3 @@ var _ = Describe("Datagram test", func() {
<-time.After(10 * time.Millisecond) <-time.After(10 * time.Millisecond)
}) })
}) })
}
})

View file

@ -10,7 +10,6 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -26,12 +25,12 @@ var _ = Describe("Drop Tests", func() {
ln quic.Listener ln quic.Listener
) )
startListenerAndProxy := func(dropCallback quicproxy.DropCallback, version protocol.VersionNumber) { startListenerAndProxy := func(dropCallback quicproxy.DropCallback) {
var err error var err error
ln, err = quic.ListenAddr( ln, err = quic.ListenAddr(
"localhost:0", "localhost:0",
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
serverPort := ln.Addr().(*net.UDPAddr).Port serverPort := ln.Addr().(*net.UDPAddr).Port
@ -51,10 +50,6 @@ var _ = Describe("Drop Tests", func() {
Expect(ln.Close()).To(Succeed()) Expect(ln.Close()).To(Succeed())
}) })
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
for _, d := range directions { for _, d := range directions {
direction := d direction := d
@ -82,7 +77,7 @@ var _ = Describe("Drop Tests", func() {
atomic.AddInt32(&numDroppedPackets, 1) atomic.AddInt32(&numDroppedPackets, 1)
} }
return drop return drop
}, version) })
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
@ -104,7 +99,7 @@ var _ = Describe("Drop Tests", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer conn.CloseWithError(0, "") defer conn.CloseWithError(0, "")
@ -125,5 +120,3 @@ var _ = Describe("Drop Tests", func() {
} }
} }
}) })
}
})

View file

@ -9,7 +9,6 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -17,15 +16,12 @@ import (
var _ = Describe("early data", func() { var _ = Describe("early data", func() {
const rtt = 80 * time.Millisecond const rtt = 80 * time.Millisecond
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
It("sends 0.5-RTT data", func() { It("sends 0.5-RTT data", func() {
ln, err := quic.ListenAddrEarly( ln, err := quic.ListenAddrEarly(
"localhost:0", "localhost:0",
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
done := make(chan struct{}) done := make(chan struct{})
@ -56,7 +52,7 @@ var _ = Describe("early data", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptUniStream(context.Background()) str, err := conn.AcceptUniStream(context.Background())
@ -68,5 +64,3 @@ var _ = Describe("early data", func() {
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
}) })
}
})

View file

@ -15,7 +15,6 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/wire" "github.com/quic-go/quic-go/internal/wire"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
@ -27,7 +26,7 @@ var directions = []quicproxy.Direction{quicproxy.DirectionIncoming, quicproxy.Di
type applicationProtocol struct { type applicationProtocol struct {
name string name string
run func(protocol.VersionNumber) run func()
} }
var _ = Describe("Handshake drop tests", func() { var _ = Describe("Handshake drop tests", func() {
@ -39,11 +38,10 @@ var _ = Describe("Handshake drop tests", func() {
data := GeneratePRData(5000) data := GeneratePRData(5000)
const timeout = 2 * time.Minute const timeout = 2 * time.Minute
startListenerAndProxy := func(dropCallback quicproxy.DropCallback, doRetry bool, longCertChain bool, version protocol.VersionNumber) { startListenerAndProxy := func(dropCallback quicproxy.DropCallback, doRetry bool, longCertChain bool) {
conf := getQuicConfig(&quic.Config{ conf := getQuicConfig(&quic.Config{
MaxIdleTimeout: timeout, MaxIdleTimeout: timeout,
HandshakeIdleTimeout: timeout, HandshakeIdleTimeout: timeout,
Versions: []protocol.VersionNumber{version},
RequireAddressValidation: func(net.Addr) bool { return doRetry }, RequireAddressValidation: func(net.Addr) bool { return doRetry },
}) })
var tlsConf *tls.Config var tlsConf *tls.Config
@ -68,7 +66,7 @@ var _ = Describe("Handshake drop tests", func() {
clientSpeaksFirst := &applicationProtocol{ clientSpeaksFirst := &applicationProtocol{
name: "client speaks first", name: "client speaks first",
run: func(version protocol.VersionNumber) { run: func() {
serverConnChan := make(chan quic.Connection) serverConnChan := make(chan quic.Connection)
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -88,7 +86,6 @@ var _ = Describe("Handshake drop tests", func() {
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
MaxIdleTimeout: timeout, MaxIdleTimeout: timeout,
HandshakeIdleTimeout: timeout, HandshakeIdleTimeout: timeout,
Versions: []protocol.VersionNumber{version},
}), }),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -107,7 +104,7 @@ var _ = Describe("Handshake drop tests", func() {
serverSpeaksFirst := &applicationProtocol{ serverSpeaksFirst := &applicationProtocol{
name: "server speaks first", name: "server speaks first",
run: func(version protocol.VersionNumber) { run: func() {
serverConnChan := make(chan quic.Connection) serverConnChan := make(chan quic.Connection)
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -126,7 +123,6 @@ var _ = Describe("Handshake drop tests", func() {
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
MaxIdleTimeout: timeout, MaxIdleTimeout: timeout,
HandshakeIdleTimeout: timeout, HandshakeIdleTimeout: timeout,
Versions: []protocol.VersionNumber{version},
}), }),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -145,7 +141,7 @@ var _ = Describe("Handshake drop tests", func() {
nobodySpeaks := &applicationProtocol{ nobodySpeaks := &applicationProtocol{
name: "nobody speaks", name: "nobody speaks",
run: func(version protocol.VersionNumber) { run: func() {
serverConnChan := make(chan quic.Connection) serverConnChan := make(chan quic.Connection)
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -159,7 +155,6 @@ var _ = Describe("Handshake drop tests", func() {
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
MaxIdleTimeout: timeout, MaxIdleTimeout: timeout,
HandshakeIdleTimeout: timeout, HandshakeIdleTimeout: timeout,
Versions: []protocol.VersionNumber{version},
}), }),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -176,10 +171,6 @@ var _ = Describe("Handshake drop tests", func() {
Expect(proxy.Close()).To(Succeed()) Expect(proxy.Close()).To(Succeed())
}) })
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
for _, d := range directions { for _, d := range directions {
direction := d direction := d
@ -211,8 +202,8 @@ var _ = Describe("Handshake drop tests", func() {
p = atomic.AddInt32(&outgoing, 1) p = atomic.AddInt32(&outgoing, 1)
} }
return p == 1 && d.Is(direction) return p == 1 && d.Is(direction)
}, doRetry, longCertChain, version) }, doRetry, longCertChain)
app.run(version) app.run()
}) })
It(fmt.Sprintf("establishes a connection when the second packet is lost in %s direction", direction), func() { It(fmt.Sprintf("establishes a connection when the second packet is lost in %s direction", direction), func() {
@ -227,8 +218,8 @@ var _ = Describe("Handshake drop tests", func() {
p = atomic.AddInt32(&outgoing, 1) p = atomic.AddInt32(&outgoing, 1)
} }
return p == 2 && d.Is(direction) return p == 2 && d.Is(direction)
}, doRetry, longCertChain, version) }, doRetry, longCertChain)
app.run(version) app.run()
}) })
It(fmt.Sprintf("establishes a connection when 1/3 of the packets are lost in %s direction", direction), func() { It(fmt.Sprintf("establishes a connection when 1/3 of the packets are lost in %s direction", direction), func() {
@ -265,8 +256,8 @@ var _ = Describe("Handshake drop tests", func() {
} }
} }
return drop return drop
}, doRetry, longCertChain, version) }, doRetry, longCertChain)
app.run(version) app.run()
}) })
}) })
} }
@ -274,8 +265,6 @@ var _ = Describe("Handshake drop tests", func() {
} }
}) })
} }
}
})
It("establishes a connection when the ClientHello is larger than 1 MTU (e.g. post-quantum)", func() { It("establishes a connection when the ClientHello is larger than 1 MTU (e.g. post-quantum)", func() {
origAdditionalTransportParametersClient := wire.AdditionalTransportParametersClient origAdditionalTransportParametersClient := wire.AdditionalTransportParametersClient
@ -294,8 +283,8 @@ var _ = Describe("Handshake drop tests", func() {
return false return false
} }
return mrand.Intn(3) == 0 return mrand.Intn(3) == 0
}, false, false, version) }, false, false)
clientSpeaksFirst.run(version) clientSpeaksFirst.run()
}) })
} }
}) })

View file

@ -10,7 +10,6 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -53,35 +52,6 @@ var _ = Describe("Handshake RTT tests", func() {
)) ))
} }
It("fails when there's no matching version, after 1 RTT", func() {
if len(protocol.SupportedVersions) == 1 {
Skip("Test requires at least 2 supported versions.")
}
serverConfig.Versions = protocol.SupportedVersions[:1]
ln, err := quic.ListenAddr("localhost:0", serverTLSConfig, serverConfig)
Expect(err).ToNot(HaveOccurred())
defer ln.Close()
runProxy(ln.Addr())
startTime := time.Now()
_, err = quic.DialAddr(
proxy.LocalAddr().String(),
getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: protocol.SupportedVersions[1:2]}),
)
Expect(err).To(HaveOccurred())
expectDurationInRTTs(startTime, 1)
})
var clientConfig *quic.Config
BeforeEach(func() {
serverConfig.Versions = []protocol.VersionNumber{protocol.Version1}
clientConfig = getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{protocol.Version1}})
clientConfig := getTLSClientConfig()
clientConfig.InsecureSkipVerify = true
})
// 1 RTT for verifying the source address // 1 RTT for verifying the source address
// 1 RTT for the TLS handshake // 1 RTT for the TLS handshake
It("is forward-secure after 2 RTTs", func() { It("is forward-secure after 2 RTTs", func() {
@ -95,7 +65,7 @@ var _ = Describe("Handshake RTT tests", func() {
_, err = quic.DialAddr( _, err = quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
expectDurationInRTTs(startTime, 2) expectDurationInRTTs(startTime, 2)
@ -111,7 +81,7 @@ var _ = Describe("Handshake RTT tests", func() {
_, err = quic.DialAddr( _, err = quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
expectDurationInRTTs(startTime, 1) expectDurationInRTTs(startTime, 1)
@ -128,7 +98,7 @@ var _ = Describe("Handshake RTT tests", func() {
_, err = quic.DialAddr( _, err = quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
expectDurationInRTTs(startTime, 2) expectDurationInRTTs(startTime, 2)
@ -138,6 +108,7 @@ var _ = Describe("Handshake RTT tests", func() {
ln, err := quic.ListenAddr("localhost:0", serverTLSConfig, serverConfig) ln, err := quic.ListenAddr("localhost:0", serverTLSConfig, serverConfig)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
go func() { go func() {
defer GinkgoRecover()
conn, err := ln.Accept(context.Background()) conn, err := ln.Accept(context.Background())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.OpenUniStream() str, err := conn.OpenUniStream()
@ -153,7 +124,7 @@ var _ = Describe("Handshake RTT tests", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptUniStream(context.Background()) str, err := conn.AcceptUniStream(context.Background())
@ -168,6 +139,7 @@ var _ = Describe("Handshake RTT tests", func() {
ln, err := quic.ListenAddrEarly("localhost:0", serverTLSConfig, serverConfig) ln, err := quic.ListenAddrEarly("localhost:0", serverTLSConfig, serverConfig)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
go func() { go func() {
defer GinkgoRecover()
conn, err := ln.Accept(context.Background()) conn, err := ln.Accept(context.Background())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// Check the ALPN now. This is probably what an application would do. // Check the ALPN now. This is probably what an application would do.
@ -186,7 +158,7 @@ var _ = Describe("Handshake RTT tests", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptUniStream(context.Background()) str, err := conn.AcceptUniStream(context.Background())

View file

@ -128,23 +128,12 @@ var _ = Describe("Handshake tests", func() {
}) })
Context("Certificate validation", func() { Context("Certificate validation", func() {
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("using %s", version), func() {
var clientConfig *quic.Config
BeforeEach(func() {
serverConfig.Versions = []protocol.VersionNumber{version}
clientConfig = getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}})
})
It("accepts the certificate", func() { It("accepts the certificate", func() {
runServer(getTLSConfig()) runServer(getTLSConfig())
_, err := quic.DialAddr( _, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@ -154,7 +143,7 @@ var _ = Describe("Handshake tests", func() {
_, err := quic.DialAddr( _, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@ -168,7 +157,7 @@ var _ = Describe("Handshake tests", func() {
server.Addr(), server.Addr(),
"foo.bar", "foo.bar",
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
var transportErr *quic.TransportError var transportErr *quic.TransportError
@ -185,7 +174,7 @@ var _ = Describe("Handshake tests", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
clientConfig, getQuicConfig(nil),
) )
// Usually, the error will occur after the client already finished the handshake. // Usually, the error will occur after the client already finished the handshake.
// However, there's a race condition here. The server's CONNECTION_CLOSE might be // However, there's a race condition here. The server's CONNECTION_CLOSE might be
@ -213,7 +202,7 @@ var _ = Describe("Handshake tests", func() {
_, err := quic.DialAddr( _, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf, tlsConf,
clientConfig, getQuicConfig(nil),
) )
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
var transportErr *quic.TransportError var transportErr *quic.TransportError
@ -222,8 +211,6 @@ var _ = Describe("Handshake tests", func() {
Expect(transportErr.Error()).To(ContainSubstring("x509: certificate is valid for localhost, not foo.bar")) Expect(transportErr.Error()).To(ContainSubstring("x509: certificate is valid for localhost, not foo.bar"))
}) })
}) })
}
})
Context("rate limiting", func() { Context("rate limiting", func() {
var ( var (

View file

@ -3,7 +3,6 @@ package self_test
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
"fmt"
"io" "io"
"net" "net"
"net/http" "net/http"
@ -13,7 +12,6 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/http3" "github.com/quic-go/quic-go/http3"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/testdata" "github.com/quic-go/quic-go/internal/testdata"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
@ -71,8 +69,6 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
port string port string
) )
versions := protocol.SupportedVersions
BeforeEach(func() { BeforeEach(func() {
mux1 = http.NewServeMux() mux1 = http.NewServeMux()
mux1.HandleFunc("/hello1", func(w http.ResponseWriter, r *http.Request) { mux1.HandleFunc("/hello1", func(w http.ResponseWriter, r *http.Request) {
@ -89,17 +85,17 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
server1 = &http3.Server{ server1 = &http3.Server{
Handler: mux1, Handler: mux1,
TLSConfig: testdata.GetTLSConfig(), TLSConfig: testdata.GetTLSConfig(),
QuicConfig: getQuicConfig(&quic.Config{Versions: versions}), QuicConfig: getQuicConfig(nil),
} }
server2 = &http3.Server{ server2 = &http3.Server{
Handler: mux2, Handler: mux2,
TLSConfig: testdata.GetTLSConfig(), TLSConfig: testdata.GetTLSConfig(),
QuicConfig: getQuicConfig(&quic.Config{Versions: versions}), QuicConfig: getQuicConfig(nil),
} }
tlsConf := http3.ConfigureTLSConfig(testdata.GetTLSConfig()) tlsConf := http3.ConfigureTLSConfig(testdata.GetTLSConfig())
quicln, err := quic.ListenAddrEarly("0.0.0.0:0", tlsConf, getQuicConfig(&quic.Config{Versions: versions})) quicln, err := quic.ListenAddrEarly("0.0.0.0:0", tlsConf, getQuicConfig(nil))
ln = &listenerWrapper{EarlyListener: quicln} ln = &listenerWrapper{EarlyListener: quicln}
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
port = strconv.Itoa(ln.Addr().(*net.UDPAddr).Port) port = strconv.Itoa(ln.Addr().(*net.UDPAddr).Port)
@ -109,10 +105,6 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
Expect(ln.Close()).NotTo(HaveOccurred()) Expect(ln.Close()).NotTo(HaveOccurred())
}) })
for _, v := range versions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
BeforeEach(func() { BeforeEach(func() {
client = &http.Client{ client = &http.Client{
Transport: &http3.RoundTripper{ Transport: &http3.RoundTripper{
@ -120,10 +112,7 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
RootCAs: testdata.GetRootCA(), RootCAs: testdata.GetRootCA(),
}, },
DisableCompression: true, DisableCompression: true,
QuicConfig: getQuicConfig(&quic.Config{ QuicConfig: getQuicConfig(&quic.Config{MaxIdleTimeout: 10 * time.Second}),
Versions: []protocol.VersionNumber{version},
MaxIdleTimeout: 10 * time.Second,
}),
}, },
} }
}) })
@ -182,5 +171,3 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
Expect(ln.listenerClosed).To(BeTrue()) Expect(ln.listenerClosed).To(BeTrue())
}) })
}) })
}
})

View file

@ -46,8 +46,6 @@ var _ = Describe("HTTP tests", func() {
port string port string
) )
versions := protocol.SupportedVersions
BeforeEach(func() { BeforeEach(func() {
mux = http.NewServeMux() mux = http.NewServeMux()
mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
@ -83,7 +81,7 @@ var _ = Describe("HTTP tests", func() {
server = &http3.Server{ server = &http3.Server{
Handler: mux, Handler: mux,
TLSConfig: testdata.GetTLSConfig(), TLSConfig: testdata.GetTLSConfig(),
QuicConfig: getQuicConfig(&quic.Config{Versions: versions}), QuicConfig: getQuicConfig(nil),
} }
addr, err := net.ResolveUDPAddr("udp", "0.0.0.0:0") addr, err := net.ResolveUDPAddr("udp", "0.0.0.0:0")
@ -106,10 +104,6 @@ var _ = Describe("HTTP tests", func() {
Eventually(stoppedServing).Should(BeClosed()) Eventually(stoppedServing).Should(BeClosed())
}) })
for _, v := range versions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
BeforeEach(func() { BeforeEach(func() {
client = &http.Client{ client = &http.Client{
Transport: &http3.RoundTripper{ Transport: &http3.RoundTripper{
@ -117,10 +111,7 @@ var _ = Describe("HTTP tests", func() {
RootCAs: testdata.GetRootCA(), RootCAs: testdata.GetRootCA(),
}, },
DisableCompression: true, DisableCompression: true,
QuicConfig: getQuicConfig(&quic.Config{ QuicConfig: getQuicConfig(&quic.Config{MaxIdleTimeout: 10 * time.Second}),
Versions: []protocol.VersionNumber{version},
MaxIdleTimeout: 10 * time.Second,
}),
}, },
} }
}) })
@ -386,6 +377,30 @@ var _ = Describe("HTTP tests", func() {
Expect(repl).To(Equal(data)) Expect(repl).To(Equal(data))
}) })
It("serves other QUIC connections", func() {
if version == protocol.VersionDraft29 {
Skip("This test only works on RFC versions")
}
tlsConf := testdata.GetTLSConfig()
tlsConf.NextProtos = []string{"h3"}
ln, err := quic.ListenAddr("localhost:0", tlsConf, nil)
Expect(err).ToNot(HaveOccurred())
done := make(chan struct{})
go func() {
defer GinkgoRecover()
defer close(done)
conn, err := ln.Accept(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(server.ServeQUICConn(conn)).To(Succeed())
}()
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/hello", ln.Addr().(*net.UDPAddr).Port))
Expect(err).ToNot(HaveOccurred())
Expect(resp.StatusCode).To(Equal(http.StatusOK))
client.Transport.(io.Closer).Close()
Eventually(done).Should(BeClosed())
})
It("supports read deadlines", func() { It("supports read deadlines", func() {
if !go120 { if !go120 {
Skip("This test requires Go 1.20+") Skip("This test requires Go 1.20+")
@ -439,29 +454,4 @@ var _ = Describe("HTTP tests", func() {
Expect(time.Now().After(expectedEnd)).To(BeTrue()) Expect(time.Now().After(expectedEnd)).To(BeTrue())
Expect(string(body)).To(ContainSubstring("aa")) Expect(string(body)).To(ContainSubstring("aa"))
}) })
if version != protocol.VersionDraft29 {
It("serves other QUIC connections", func() {
tlsConf := testdata.GetTLSConfig()
tlsConf.NextProtos = []string{"h3"}
ln, err := quic.ListenAddr("localhost:0", tlsConf, nil)
Expect(err).ToNot(HaveOccurred())
done := make(chan struct{})
go func() {
defer GinkgoRecover()
defer close(done)
conn, err := ln.Accept(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(server.ServeQUICConn(conn)).To(Succeed())
}()
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/hello", ln.Addr().(*net.UDPAddr).Port))
Expect(err).ToNot(HaveOccurred())
Expect(resp.StatusCode).To(Equal(http.StatusOK))
client.Transport.(io.Closer).Close()
Eventually(done).Should(BeClosed())
})
}
})
}
}) })

View file

@ -22,10 +22,6 @@ import (
) )
var _ = Describe("MITM test", func() { var _ = Describe("MITM test", func() {
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
const connIDLen = 6 // explicitly set the connection ID length, so the proxy can parse it const connIDLen = 6 // explicitly set the connection ID length, so the proxy can parse it
var ( var (
@ -72,10 +68,7 @@ var _ = Describe("MITM test", func() {
} }
BeforeEach(func() { BeforeEach(func() {
serverConfig = getQuicConfig(&quic.Config{ serverConfig = getQuicConfig(&quic.Config{ConnectionIDLength: connIDLen})
Versions: []protocol.VersionNumber{version},
ConnectionIDLength: connIDLen,
})
addr, err := net.ResolveUDPAddr("udp", "localhost:0") addr, err := net.ResolveUDPAddr("udp", "localhost:0")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
clientUDPConn, err = net.ListenUDP("udp", addr) clientUDPConn, err = net.ListenUDP("udp", addr)
@ -116,7 +109,7 @@ var _ = Describe("MITM test", func() {
for i := 0; i < numPackets; i++ { for i := 0; i < numPackets; i++ {
payloadLen := mrand.Int31n(100) payloadLen := mrand.Int31n(100)
replyHdr.Length = protocol.ByteCount(mrand.Int31n(payloadLen + 1)) replyHdr.Length = protocol.ByteCount(mrand.Int31n(payloadLen + 1))
b, err := replyHdr.Append(nil, version) b, err := replyHdr.Append(nil, hdr.Version)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
r := make([]byte, payloadLen) r := make([]byte, payloadLen)
mrand.Read(r) mrand.Read(r)
@ -158,10 +151,7 @@ var _ = Describe("MITM test", func() {
raddr, raddr,
fmt.Sprintf("localhost:%d", proxyPort), fmt.Sprintf("localhost:%d", proxyPort),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{ConnectionIDLength: connIDLen}),
Versions: []protocol.VersionNumber{version},
ConnectionIDLength: connIDLen,
}),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptUniStream(context.Background()) str, err := conn.AcceptUniStream(context.Background())
@ -205,10 +195,7 @@ var _ = Describe("MITM test", func() {
raddr, raddr,
fmt.Sprintf("localhost:%d", proxyPort), fmt.Sprintf("localhost:%d", proxyPort),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{ConnectionIDLength: connIDLen}),
Versions: []protocol.VersionNumber{version},
ConnectionIDLength: connIDLen,
}),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptUniStream(context.Background()) str, err := conn.AcceptUniStream(context.Background())
@ -324,7 +311,6 @@ var _ = Describe("MITM test", func() {
fmt.Sprintf("localhost:%d", proxyPort), fmt.Sprintf("localhost:%d", proxyPort),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
ConnectionIDLength: connIDLen, ConnectionIDLength: connIDLen,
HandshakeIdleTimeout: 2 * time.Second, HandshakeIdleTimeout: 2 * time.Second,
}), }),
@ -468,5 +454,3 @@ var _ = Describe("MITM test", func() {
}) })
}) })
}) })
}
})

View file

@ -9,17 +9,12 @@ import (
"time" "time"
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = Describe("Multiplexing", func() { var _ = Describe("Multiplexing", func() {
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
runServer := func(ln quic.Listener) { runServer := func(ln quic.Listener) {
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
@ -46,7 +41,7 @@ var _ = Describe("Multiplexing", func() {
addr, addr,
fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port), fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer conn.CloseWithError(0, "") defer conn.CloseWithError(0, "")
@ -62,7 +57,7 @@ var _ = Describe("Multiplexing", func() {
ln, err := quic.ListenAddr( ln, err := quic.ListenAddr(
"localhost:0", "localhost:0",
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
return ln return ln
@ -145,7 +140,7 @@ var _ = Describe("Multiplexing", func() {
server, err := quic.Listen( server, err := quic.Listen(
conn, conn,
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runServer(server) runServer(server)
@ -181,7 +176,7 @@ var _ = Describe("Multiplexing", func() {
server1, err := quic.Listen( server1, err := quic.Listen(
conn1, conn1,
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runServer(server1) runServer(server1)
@ -190,7 +185,7 @@ var _ = Describe("Multiplexing", func() {
server2, err := quic.Listen( server2, err := quic.Listen(
conn2, conn2,
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runServer(server2) runServer(server2)
@ -217,5 +212,3 @@ var _ = Describe("Multiplexing", func() {
}) })
}) })
}) })
}
})

View file

@ -9,21 +9,17 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy" quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = Describe("non-zero RTT", func() { var _ = Describe("non-zero RTT", func() {
for _, v := range protocol.SupportedVersions {
version := v
runServer := func() quic.Listener { runServer := func() quic.Listener {
ln, err := quic.ListenAddr( ln, err := quic.ListenAddr(
"localhost:0", "localhost:0",
getTLSConfig(), getTLSConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
go func() { go func() {
@ -43,7 +39,7 @@ var _ = Describe("non-zero RTT", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", port), fmt.Sprintf("localhost:%d", port),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptStream(context.Background()) str, err := conn.AcceptStream(context.Background())
@ -54,7 +50,6 @@ var _ = Describe("non-zero RTT", func() {
conn.CloseWithError(0, "") conn.CloseWithError(0, "")
} }
Context(fmt.Sprintf("with QUIC version %s", version), func() {
for _, r := range [...]time.Duration{ for _, r := range [...]time.Duration{
10 * time.Millisecond, 10 * time.Millisecond,
50 * time.Millisecond, 50 * time.Millisecond,
@ -79,7 +74,7 @@ var _ = Describe("non-zero RTT", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.AcceptStream(context.Background()) str, err := conn.AcceptStream(context.Background())
@ -114,5 +109,3 @@ var _ = Describe("non-zero RTT", func() {
}) })
} }
}) })
}
})

View file

@ -6,6 +6,7 @@ import (
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"flag" "flag"
"fmt"
"log" "log"
mrand "math/rand" mrand "math/rand"
"os" "os"
@ -18,6 +19,7 @@ import (
"github.com/quic-go/quic-go" "github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/integrationtests/tools" "github.com/quic-go/quic-go/integrationtests/tools"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/utils" "github.com/quic-go/quic-go/internal/utils"
"github.com/quic-go/quic-go/internal/wire" "github.com/quic-go/quic-go/internal/wire"
"github.com/quic-go/quic-go/logging" "github.com/quic-go/quic-go/logging"
@ -83,10 +85,12 @@ var (
logFileName string // the log file set in the ginkgo flags logFileName string // the log file set in the ginkgo flags
logBufOnce sync.Once logBufOnce sync.Once
logBuf *syncedBuffer logBuf *syncedBuffer
versionParam string
qlogTracer logging.Tracer qlogTracer logging.Tracer
enableQlog bool enableQlog bool
version quic.VersionNumber
tlsConfig *tls.Config tlsConfig *tls.Config
tlsConfigLongChain *tls.Config tlsConfigLongChain *tls.Config
tlsClientConfig *tls.Config tlsClientConfig *tls.Config
@ -96,6 +100,7 @@ var (
// to set call ginkgo -- -logfile=log.txt // to set call ginkgo -- -logfile=log.txt
func init() { func init() {
flag.StringVar(&logFileName, "logfile", "", "log file") flag.StringVar(&logFileName, "logfile", "", "log file")
flag.StringVar(&versionParam, "version", "1", "QUIC version")
flag.BoolVar(&enableQlog, "qlog", false, "enable qlog") flag.BoolVar(&enableQlog, "qlog", false, "enable qlog")
ca, caPrivateKey, err := tools.GenerateCA() ca, caPrivateKey, err := tools.GenerateCA()
@ -133,6 +138,18 @@ var _ = BeforeSuite(func() {
if enableQlog { if enableQlog {
qlogTracer = tools.NewQlogger(GinkgoWriter) qlogTracer = tools.NewQlogger(GinkgoWriter)
} }
switch versionParam {
case "1":
version = quic.Version1
case "2":
version = quic.Version2
case "draft29":
version = quic.VersionDraft29
default:
Fail(fmt.Sprintf("unknown QUIC version: %s", versionParam))
}
fmt.Printf("Using QUIC version: %s\n", version)
protocol.SupportedVersions = []quic.VersionNumber{version}
}) })
func getTLSConfig() *tls.Config { func getTLSConfig() *tls.Config {

View file

@ -7,11 +7,9 @@ import (
"net" "net"
"sync" "sync"
"github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/quic-go/quic-go"
) )
var _ = Describe("Bidirectional streams", func() { var _ = Describe("Bidirectional streams", func() {
@ -20,20 +18,11 @@ var _ = Describe("Bidirectional streams", func() {
var ( var (
server quic.Listener server quic.Listener
serverAddr string serverAddr string
qconf *quic.Config
) )
for _, v := range []protocol.VersionNumber{protocol.Version1} {
version := v
Context(fmt.Sprintf("with QUIC %s", version), func() {
BeforeEach(func() { BeforeEach(func() {
var err error var err error
qconf = &quic.Config{ server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfig(nil))
Versions: []protocol.VersionNumber{version},
MaxIncomingStreams: 0,
}
server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfig(qconf))
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port) serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
}) })
@ -100,7 +89,7 @@ var _ = Describe("Bidirectional streams", func() {
client, err := quic.DialAddr( client, err := quic.DialAddr(
serverAddr, serverAddr,
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(qconf), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runSendingPeer(client) runSendingPeer(client)
@ -118,7 +107,7 @@ var _ = Describe("Bidirectional streams", func() {
client, err := quic.DialAddr( client, err := quic.DialAddr(
serverAddr, serverAddr,
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(qconf), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runReceivingPeer(client) runReceivingPeer(client)
@ -145,7 +134,7 @@ var _ = Describe("Bidirectional streams", func() {
client, err := quic.DialAddr( client, err := quic.DialAddr(
serverAddr, serverAddr,
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(qconf), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
done2 := make(chan struct{}) done2 := make(chan struct{})
@ -159,5 +148,3 @@ var _ = Describe("Bidirectional streams", func() {
<-done2 <-done2
}) })
}) })
}
})

View file

@ -20,13 +20,11 @@ var _ = Describe("Unidirectional Streams", func() {
var ( var (
server quic.Listener server quic.Listener
serverAddr string serverAddr string
qconf *quic.Config
) )
BeforeEach(func() { BeforeEach(func() {
var err error var err error
qconf = &quic.Config{Versions: []protocol.VersionNumber{protocol.Version1}} server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfig(nil))
server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfig(qconf))
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port) serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
}) })
@ -81,7 +79,7 @@ var _ = Describe("Unidirectional Streams", func() {
client, err := quic.DialAddr( client, err := quic.DialAddr(
serverAddr, serverAddr,
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(qconf), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runSendingPeer(client) runSendingPeer(client)
@ -99,7 +97,7 @@ var _ = Describe("Unidirectional Streams", func() {
client, err := quic.DialAddr( client, err := quic.DialAddr(
serverAddr, serverAddr,
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(qconf), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
runReceivingPeer(client) runReceivingPeer(client)
@ -125,7 +123,7 @@ var _ = Describe("Unidirectional Streams", func() {
client, err := quic.DialAddr( client, err := quic.DialAddr(
serverAddr, serverAddr,
getTLSClientConfig(), getTLSClientConfig(),
getQuicConfig(qconf), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
done2 := make(chan struct{}) done2 := make(chan struct{})

View file

@ -25,10 +25,6 @@ import (
var _ = Describe("0-RTT", func() { var _ = Describe("0-RTT", func() {
rtt := scaleDuration(5 * time.Millisecond) rtt := scaleDuration(5 * time.Millisecond)
for _, v := range protocol.SupportedVersions {
version := v
Context(fmt.Sprintf("with QUIC version %s", version), func() {
runCountingProxy := func(serverPort int) (*quicproxy.QuicProxy, *uint32) { runCountingProxy := func(serverPort int) (*quicproxy.QuicProxy, *uint32) {
var num0RTTPackets uint32 // to be used as an atomic var num0RTTPackets uint32 // to be used as an atomic
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{ proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
@ -58,7 +54,6 @@ var _ = Describe("0-RTT", func() {
tlsConf := getTLSConfig() tlsConf := getTLSConfig()
if serverConf == nil { if serverConf == nil {
serverConf = getQuicConfig(nil) serverConf = getQuicConfig(nil)
serverConf.Versions = []protocol.VersionNumber{version}
} }
serverConf.Allow0RTT = func(addr net.Addr) bool { return true } serverConf.Allow0RTT = func(addr net.Addr) bool { return true }
ln, err := quic.ListenAddrEarly( ln, err := quic.ListenAddrEarly(
@ -93,7 +88,7 @@ var _ = Describe("0-RTT", func() {
conn, err := quic.DialAddr( conn, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
clientConf, clientConf,
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Eventually(puts).Should(Receive()) Eventually(puts).Should(Receive())
@ -128,7 +123,7 @@ var _ = Describe("0-RTT", func() {
}() }()
if clientConf == nil { if clientConf == nil {
clientConf = getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}) clientConf = getQuicConfig(nil)
} }
conn, err := quic.DialAddrEarly( conn, err := quic.DialAddrEarly(
fmt.Sprintf("localhost:%d", proxyPort), fmt.Sprintf("localhost:%d", proxyPort),
@ -158,7 +153,7 @@ var _ = Describe("0-RTT", func() {
conn, err := quic.DialAddrEarly( conn, err := quic.DialAddrEarly(
fmt.Sprintf("localhost:%d", proxyPort), fmt.Sprintf("localhost:%d", proxyPort),
clientConf, clientConf,
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.OpenUniStream() str, err := conn.OpenUniStream()
@ -202,7 +197,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(addr net.Addr) bool { return true }, Allow0RTT: func(addr net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -217,10 +211,7 @@ var _ = Describe("0-RTT", func() {
ln, ln,
proxy.LocalPort(), proxy.LocalPort(),
clientTLSConf, clientTLSConf,
&quic.Config{ &quic.Config{ConnectionIDLength: connIDLen},
ConnectionIDLength: connIDLen,
Versions: []protocol.VersionNumber{version},
},
PRData, PRData,
) )
@ -260,7 +251,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -292,7 +282,7 @@ var _ = Describe("0-RTT", func() {
conn, err := quic.DialAddrEarly( conn, err := quic.DialAddrEarly(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
clientConf, clientConf,
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
firstStr, err := conn.OpenUniStream() firstStr, err := conn.OpenUniStream()
@ -342,7 +332,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -418,7 +407,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
RequireAddressValidation: func(net.Addr) bool { return true }, RequireAddressValidation: func(net.Addr) bool { return true },
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
@ -480,7 +468,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
MaxIncomingUniStreams: maxStreams + 1, MaxIncomingUniStreams: maxStreams + 1,
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
@ -494,7 +481,7 @@ var _ = Describe("0-RTT", func() {
conn, err := quic.DialAddrEarly( conn, err := quic.DialAddrEarly(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
clientConf, clientConf,
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.OpenUniStream() str, err := conn.OpenUniStream()
@ -525,7 +512,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
MaxIncomingStreams: maxStreams - 1, MaxIncomingStreams: maxStreams - 1,
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
@ -555,7 +541,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -583,7 +568,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(net.Addr) bool { return false }, // application rejects 0-RTT Allow0RTT: func(net.Addr) bool { return false }, // application rejects 0-RTT
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -605,15 +589,11 @@ var _ = Describe("0-RTT", func() {
DescribeTable("flow control limits", DescribeTable("flow control limits",
func(addFlowControlLimit func(*quic.Config, uint64)) { func(addFlowControlLimit func(*quic.Config, uint64)) {
tracer := newPacketTracer() tracer := newPacketTracer()
firstConf := getQuicConfig(&quic.Config{ firstConf := getQuicConfig(&quic.Config{Allow0RTT: func(net.Addr) bool { return true }})
Allow0RTT: func(net.Addr) bool { return true },
Versions: []protocol.VersionNumber{version},
})
addFlowControlLimit(firstConf, 3) addFlowControlLimit(firstConf, 3)
tlsConf, clientConf := dialAndReceiveSessionTicket(firstConf) tlsConf, clientConf := dialAndReceiveSessionTicket(firstConf)
secondConf := getQuicConfig(&quic.Config{ secondConf := getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}) })
@ -631,7 +611,7 @@ var _ = Describe("0-RTT", func() {
conn, err := quic.DialAddrEarly( conn, err := quic.DialAddrEarly(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
clientConf, clientConf,
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
str, err := conn.OpenUniStream() str, err := conn.OpenUniStream()
@ -690,7 +670,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
MaxIncomingUniStreams: 1, MaxIncomingUniStreams: 1,
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -703,7 +682,7 @@ var _ = Describe("0-RTT", func() {
conn, err := quic.DialAddrEarly( conn, err := quic.DialAddrEarly(
fmt.Sprintf("localhost:%d", proxy.LocalPort()), fmt.Sprintf("localhost:%d", proxy.LocalPort()),
clientConf, clientConf,
getQuicConfig(&quic.Config{Versions: []protocol.VersionNumber{version}}), getQuicConfig(nil),
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// The client remembers that it was allowed to open 2 uni-directional streams. // The client remembers that it was allowed to open 2 uni-directional streams.
@ -766,7 +745,6 @@ var _ = Describe("0-RTT", func() {
"localhost:0", "localhost:0",
tlsConf, tlsConf,
getQuicConfig(&quic.Config{ getQuicConfig(&quic.Config{
Versions: []protocol.VersionNumber{version},
Allow0RTT: func(net.Addr) bool { return true }, Allow0RTT: func(net.Addr) bool { return true },
Tracer: newTracer(func() logging.ConnectionTracer { return tracer }), Tracer: newTracer(func() logging.ConnectionTracer { return tracer }),
}), }),
@ -793,5 +771,3 @@ var _ = Describe("0-RTT", func() {
Expect(zeroRTTPackets[0]).To(Equal(protocol.PacketNumber(0))) Expect(zeroRTTPackets[0]).To(Equal(protocol.PacketNumber(0)))
}) })
}) })
}
})

View file

@ -0,0 +1,53 @@
package versionnegotiation
import (
"time"
"github.com/quic-go/quic-go"
quicproxy "github.com/quic-go/quic-go/integrationtests/tools/proxy"
"github.com/quic-go/quic-go/internal/protocol"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Handshake RTT tests", func() {
const rtt = 400 * time.Millisecond
expectDurationInRTTs := func(startTime time.Time, num int) {
testDuration := time.Since(startTime)
rtts := float32(testDuration) / float32(rtt)
Expect(rtts).To(SatisfyAll(
BeNumerically(">=", num),
BeNumerically("<", num+1),
))
}
It("fails when there's no matching version, after 1 RTT", func() {
if len(protocol.SupportedVersions) == 1 {
Skip("Test requires at least 2 supported versions.")
}
serverConfig := &quic.Config{}
serverConfig.Versions = protocol.SupportedVersions[:1]
ln, err := quic.ListenAddr("localhost:0", getTLSConfig(), serverConfig)
Expect(err).ToNot(HaveOccurred())
defer ln.Close()
// start the proxy
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
RemoteAddr: ln.Addr().String(),
DelayPacket: func(_ quicproxy.Direction, _ []byte) time.Duration { return rtt / 2 },
})
Expect(err).ToNot(HaveOccurred())
startTime := time.Now()
_, err = quic.DialAddr(
proxy.LocalAddr().String(),
getTLSClientConfig(),
maybeAddQlogTracer(&quic.Config{Versions: protocol.SupportedVersions[1:2]}),
)
Expect(err).To(HaveOccurred())
expectDurationInRTTs(startTime, 1)
})
})