From a5b967a30963bb29f6ba755986f0a82d2f4476d6 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 26 Mar 2020 17:08:18 +0700 Subject: [PATCH] add a command line option to export qlogs from the integration tests --- integrationtests/self/cancelation_test.go | 18 +++++----- integrationtests/self/conn_id_test.go | 16 ++++----- integrationtests/self/drop_test.go | 6 ++-- integrationtests/self/early_data_test.go | 4 +-- integrationtests/self/handshake_drop_test.go | 16 ++++----- integrationtests/self/handshake_rtt_test.go | 8 ++--- integrationtests/self/handshake_test.go | 15 ++++---- integrationtests/self/http_test.go | 6 ++-- integrationtests/self/mitm_test.go | 16 ++++----- integrationtests/self/multiplex_test.go | 10 +++--- integrationtests/self/rtt_test.go | 8 ++--- integrationtests/self/self_suite_test.go | 35 +++++++++++++++++++ integrationtests/self/stateless_reset_test.go | 6 ++-- integrationtests/self/stream_test.go | 8 ++--- integrationtests/self/timeout_test.go | 30 ++++++++++------ integrationtests/self/uni_stream_test.go | 8 ++--- integrationtests/self/zero_rtt_test.go | 32 ++++++++--------- 17 files changed, 137 insertions(+), 105 deletions(-) diff --git a/integrationtests/self/cancelation_test.go b/integrationtests/self/cancelation_test.go index bdf5922b..bb7b04b8 100644 --- a/integrationtests/self/cancelation_test.go +++ b/integrationtests/self/cancelation_test.go @@ -26,7 +26,7 @@ var _ = Describe("Stream Cancelations", func() { runServer := func() <-chan int32 { numCanceledStreamsChan := make(chan int32) var err error - server, err = quic.ListenAddr("localhost:0", getTLSConfig(), nil) + server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfigForServer(nil)) Expect(err).ToNot(HaveOccurred()) var canceledCounter int32 @@ -65,7 +65,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIncomingUniStreams: numStreams / 2}, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: numStreams / 2}), ) Expect(err).ToNot(HaveOccurred()) @@ -109,7 +109,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIncomingUniStreams: numStreams / 2}, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: numStreams / 2}), ) Expect(err).ToNot(HaveOccurred()) @@ -157,7 +157,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIncomingUniStreams: numStreams / 2}, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: numStreams / 2}), ) Expect(err).ToNot(HaveOccurred()) @@ -293,7 +293,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIncomingUniStreams: numStreams / 2}, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: numStreams / 2}), ) Expect(err).ToNot(HaveOccurred()) @@ -371,7 +371,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIncomingUniStreams: numStreams / 2}, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: numStreams / 2}), ) Expect(err).ToNot(HaveOccurred()) @@ -446,7 +446,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIncomingUniStreams: numStreams / 3}, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: numStreams / 3}), ) Expect(err).ToNot(HaveOccurred()) @@ -529,9 +529,7 @@ var _ = Describe("Stream Cancelations", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{ - MaxIncomingUniStreams: 5, - }, + getQuicConfigForClient(&quic.Config{MaxIncomingUniStreams: 5}), ) Expect(err).ToNot(HaveOccurred()) diff --git a/integrationtests/self/conn_id_test.go b/integrationtests/self/conn_id_test.go index 1cca23c3..5e522066 100644 --- a/integrationtests/self/conn_id_test.go +++ b/integrationtests/self/conn_id_test.go @@ -60,13 +60,13 @@ var _ = Describe("Connection ID lengths tests", func() { } It("downloads a file using a 0-byte connection ID for the client", func() { - serverConf := &quic.Config{ + serverConf := getQuicConfigForServer(&quic.Config{ ConnectionIDLength: randomConnIDLen(), Versions: []protocol.VersionNumber{protocol.VersionTLS}, - } - clientConf := &quic.Config{ + }) + clientConf := getQuicConfigForClient(&quic.Config{ Versions: []protocol.VersionNumber{protocol.VersionTLS}, - } + }) ln := runServer(serverConf) defer ln.Close() @@ -74,14 +74,14 @@ var _ = Describe("Connection ID lengths tests", func() { }) It("downloads a file when both client and server use a random connection ID length", func() { - serverConf := &quic.Config{ + serverConf := getQuicConfigForServer(&quic.Config{ ConnectionIDLength: randomConnIDLen(), Versions: []protocol.VersionNumber{protocol.VersionTLS}, - } - clientConf := &quic.Config{ + }) + clientConf := getQuicConfigForClient(&quic.Config{ ConnectionIDLength: randomConnIDLen(), Versions: []protocol.VersionNumber{protocol.VersionTLS}, - } + }) ln := runServer(serverConf) defer ln.Close() diff --git a/integrationtests/self/drop_test.go b/integrationtests/self/drop_test.go index 1c68bda2..ae8b3018 100644 --- a/integrationtests/self/drop_test.go +++ b/integrationtests/self/drop_test.go @@ -31,9 +31,7 @@ var _ = Describe("Drop Tests", func() { ln, err = quic.ListenAddr( "localhost:0", getTLSConfig(), - &quic.Config{ - Versions: []protocol.VersionNumber{version}, - }, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) serverPort := ln.Addr().(*net.UDPAddr).Port @@ -106,7 +104,7 @@ var _ = Describe("Drop Tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) defer sess.CloseWithError(0, "") diff --git a/integrationtests/self/early_data_test.go b/integrationtests/self/early_data_test.go index ab12ea37..a4a5d793 100644 --- a/integrationtests/self/early_data_test.go +++ b/integrationtests/self/early_data_test.go @@ -25,7 +25,7 @@ var _ = Describe("early data", func() { ln, err := quic.ListenAddrEarly( "localhost:0", getTLSConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) done := make(chan struct{}) @@ -56,7 +56,7 @@ var _ = Describe("early data", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptUniStream(context.Background()) diff --git a/integrationtests/self/handshake_drop_test.go b/integrationtests/self/handshake_drop_test.go index cdb12bf5..92e9951e 100644 --- a/integrationtests/self/handshake_drop_test.go +++ b/integrationtests/self/handshake_drop_test.go @@ -33,11 +33,11 @@ var _ = Describe("Handshake drop tests", func() { const timeout = 10 * time.Minute startListenerAndProxy := func(dropCallback quicproxy.DropCallback, doRetry bool, version protocol.VersionNumber) { - conf := &quic.Config{ + conf := getQuicConfigForServer(&quic.Config{ MaxIdleTimeout: timeout, HandshakeTimeout: timeout, Versions: []protocol.VersionNumber{version}, - } + }) if !doRetry { conf.AcceptToken = func(net.Addr, *quic.Token) bool { return true } } @@ -79,11 +79,11 @@ var _ = Describe("Handshake drop tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ MaxIdleTimeout: timeout, HandshakeTimeout: timeout, Versions: []protocol.VersionNumber{version}, - }, + }), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.OpenStream() @@ -115,11 +115,11 @@ var _ = Describe("Handshake drop tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ MaxIdleTimeout: timeout, HandshakeTimeout: timeout, Versions: []protocol.VersionNumber{version}, - }, + }), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptStream(context.Background()) @@ -149,11 +149,11 @@ var _ = Describe("Handshake drop tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ MaxIdleTimeout: timeout, HandshakeTimeout: timeout, Versions: []protocol.VersionNumber{version}, - }, + }), ) Expect(err).ToNot(HaveOccurred()) var serverSession quic.Session diff --git a/integrationtests/self/handshake_rtt_test.go b/integrationtests/self/handshake_rtt_test.go index 90a4c3ac..17c64be1 100644 --- a/integrationtests/self/handshake_rtt_test.go +++ b/integrationtests/self/handshake_rtt_test.go @@ -29,7 +29,7 @@ var _ = Describe("Handshake RTT tests", func() { BeforeEach(func() { acceptStopped = make(chan struct{}) - serverConfig = &quic.Config{} + serverConfig = getQuicConfigForServer(nil) serverTLSConfig = getTLSConfig() }) @@ -79,9 +79,7 @@ var _ = Describe("Handshake RTT tests", func() { } serverConfig.Versions = protocol.SupportedVersions[:1] runServerAndProxy() - clientConfig := &quic.Config{ - Versions: protocol.SupportedVersions[1:2], - } + clientConfig := getQuicConfigForClient(&quic.Config{Versions: protocol.SupportedVersions[1:2]}) _, err := quic.DialAddr( proxy.LocalAddr().String(), getTLSClientConfig(), @@ -96,7 +94,7 @@ var _ = Describe("Handshake RTT tests", func() { BeforeEach(func() { serverConfig.Versions = []protocol.VersionNumber{protocol.VersionTLS} - clientConfig = &quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}} + clientConfig = getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}}) clientConfig := getTLSClientConfig() clientConfig.InsecureSkipVerify = true }) diff --git a/integrationtests/self/handshake_test.go b/integrationtests/self/handshake_test.go index 204192f3..ff5c9455 100644 --- a/integrationtests/self/handshake_test.go +++ b/integrationtests/self/handshake_test.go @@ -57,7 +57,7 @@ var _ = Describe("Handshake tests", func() { BeforeEach(func() { server = nil acceptStopped = make(chan struct{}) - serverConfig = &quic.Config{} + serverConfig = getQuicConfigForServer(nil) tlsServerConf = getTLSConfig() }) @@ -121,13 +121,12 @@ var _ = Describe("Handshake tests", func() { serverConfig.Versions = supportedVersions server := runServer() defer server.Close() - conf := &quic.Config{ - Versions: []protocol.VersionNumber{7, 8, 9, protocol.SupportedVersions[0], 10}, - } sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - conf, + getQuicConfigForClient(&quic.Config{ + Versions: []protocol.VersionNumber{7, 8, 9, protocol.SupportedVersions[0], 10}, + }), ) Expect(err).ToNot(HaveOccurred()) Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[0])) @@ -187,9 +186,7 @@ var _ = Describe("Handshake tests", func() { BeforeEach(func() { serverConfig.Versions = []protocol.VersionNumber{version} - clientConfig = &quic.Config{ - Versions: []protocol.VersionNumber{version}, - } + clientConfig = getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}) }) JustBeforeEach(func() { @@ -421,7 +418,7 @@ var _ = Describe("Handshake tests", func() { gets := make(chan string, 100) puts := make(chan string, 100) tokenStore := newTokenStore(gets, puts) - quicConf := &quic.Config{TokenStore: tokenStore} + quicConf := getQuicConfigForClient(&quic.Config{TokenStore: tokenStore}) sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), diff --git a/integrationtests/self/http_test.go b/integrationtests/self/http_test.go index 6b2337c1..b4f135f0 100644 --- a/integrationtests/self/http_test.go +++ b/integrationtests/self/http_test.go @@ -76,7 +76,7 @@ var _ = Describe("HTTP tests", func() { Handler: mux, TLSConfig: testdata.GetTLSConfig(), }, - QuicConfig: &quic.Config{Versions: versions}, + QuicConfig: getQuicConfigForServer(&quic.Config{Versions: versions}), } addr, err := net.ResolveUDPAddr("udp", "0.0.0.0:0") @@ -110,10 +110,10 @@ var _ = Describe("HTTP tests", func() { RootCAs: testdata.GetRootCA(), }, DisableCompression: true, - QuicConfig: &quic.Config{ + QuicConfig: getQuicConfigForClient(&quic.Config{ Versions: []protocol.VersionNumber{version}, MaxIdleTimeout: 10 * time.Second, - }, + }), }, } }) diff --git a/integrationtests/self/mitm_test.go b/integrationtests/self/mitm_test.go index ea6b9d98..2025c2a3 100644 --- a/integrationtests/self/mitm_test.go +++ b/integrationtests/self/mitm_test.go @@ -63,10 +63,10 @@ var _ = Describe("MITM test", func() { } BeforeEach(func() { - serverConfig = &quic.Config{ + serverConfig = getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, ConnectionIDLength: connIDLen, - } + }) addr, err := net.ResolveUDPAddr("udp", "localhost:0") Expect(err).ToNot(HaveOccurred()) clientConn, err = net.ListenUDP("udp", addr) @@ -128,10 +128,10 @@ var _ = Describe("MITM test", func() { raddr, fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ Versions: []protocol.VersionNumber{version}, ConnectionIDLength: connIDLen, - }, + }), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptUniStream(context.Background()) @@ -174,10 +174,10 @@ var _ = Describe("MITM test", func() { raddr, fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ Versions: []protocol.VersionNumber{version}, ConnectionIDLength: connIDLen, - }, + }), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptUniStream(context.Background()) @@ -335,11 +335,11 @@ var _ = Describe("MITM test", func() { raddr, fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ Versions: []protocol.VersionNumber{version}, ConnectionIDLength: connIDLen, HandshakeTimeout: 2 * time.Second, - }, + }), ) return err } diff --git a/integrationtests/self/multiplex_test.go b/integrationtests/self/multiplex_test.go index bd4bfcd6..3b0f2981 100644 --- a/integrationtests/self/multiplex_test.go +++ b/integrationtests/self/multiplex_test.go @@ -46,7 +46,7 @@ var _ = Describe("Multiplexing", func() { addr, fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) defer sess.CloseWithError(0, "") @@ -62,7 +62,7 @@ var _ = Describe("Multiplexing", func() { ln, err := quic.ListenAddr( "localhost:0", getTLSConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) return ln @@ -145,7 +145,7 @@ var _ = Describe("Multiplexing", func() { server, err := quic.Listen( conn, getTLSConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) runServer(server) @@ -181,7 +181,7 @@ var _ = Describe("Multiplexing", func() { server1, err := quic.Listen( conn1, getTLSConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) runServer(server1) @@ -190,7 +190,7 @@ var _ = Describe("Multiplexing", func() { server2, err := quic.Listen( conn2, getTLSConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) runServer(server2) diff --git a/integrationtests/self/rtt_test.go b/integrationtests/self/rtt_test.go index 367713f7..a99df0b3 100644 --- a/integrationtests/self/rtt_test.go +++ b/integrationtests/self/rtt_test.go @@ -23,9 +23,7 @@ var _ = Describe("non-zero RTT", func() { ln, err := quic.ListenAddr( "localhost:0", getTLSConfig(), - &quic.Config{ - Versions: []protocol.VersionNumber{version}, - }, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) go func() { @@ -45,7 +43,7 @@ var _ = Describe("non-zero RTT", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", port), getTLSClientConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptStream(context.Background()) @@ -81,7 +79,7 @@ var _ = Describe("non-zero RTT", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptStream(context.Background()) diff --git a/integrationtests/self/self_suite_test.go b/integrationtests/self/self_suite_test.go index 68b37d0e..4f03170f 100644 --- a/integrationtests/self/self_suite_test.go +++ b/integrationtests/self/self_suite_test.go @@ -1,15 +1,20 @@ package self_test import ( + "bufio" "bytes" "crypto/tls" "flag" + "fmt" + "io" "log" "math/rand" "os" "sync" "testing" + "github.com/lucas-clemente/quic-go" + "github.com/lucas-clemente/quic-go/internal/testdata" "github.com/lucas-clemente/quic-go/internal/utils" @@ -87,12 +92,42 @@ var ( logFileName string // the log file set in the ginkgo flags logBufOnce sync.Once logBuf *syncedBuffer + enableQlog bool ) // read the logfile command line flag // to set call ginkgo -- -logfile=log.txt func init() { flag.StringVar(&logFileName, "logfile", "", "log file") + flag.BoolVar(&enableQlog, "qlog", false, "enable qlog") +} + +func getQuicConfigForClient(conf *quic.Config) *quic.Config { + return getQuicConfigForRole("client", conf) +} + +func getQuicConfigForServer(conf *quic.Config) *quic.Config { + return getQuicConfigForRole("server", conf) +} + +func getQuicConfigForRole(role string, conf *quic.Config) *quic.Config { + if conf == nil { + conf = &quic.Config{} + } else { + conf = conf.Clone() + } + if !enableQlog { + return conf + } + conf.GetLogWriter = func(connectionID []byte) io.WriteCloser { + filename := fmt.Sprintf("log_%x_%s.qlog", connectionID, role) + fmt.Fprintf(GinkgoWriter, "Creating %s.\n", filename) + f, err := os.Create(filename) + Expect(err).ToNot(HaveOccurred()) + bw := bufio.NewWriter(f) + return utils.NewBufferedWriteCloser(bw, f) + } + return conf } var _ = BeforeEach(func() { diff --git a/integrationtests/self/stateless_reset_test.go b/integrationtests/self/stateless_reset_test.go index 34cf5236..147d5fb4 100644 --- a/integrationtests/self/stateless_reset_test.go +++ b/integrationtests/self/stateless_reset_test.go @@ -24,7 +24,7 @@ var _ = Describe("Stateless Resets", func() { It(fmt.Sprintf("sends and recognizes stateless resets, for %d byte connection IDs", connIDLen), func() { statelessResetKey := make([]byte, 32) rand.Read(statelessResetKey) - serverConfig := &quic.Config{StatelessResetKey: statelessResetKey} + serverConfig := getQuicConfigForServer(&quic.Config{StatelessResetKey: statelessResetKey}) ln, err := quic.ListenAddr("localhost:0", getTLSConfig(), serverConfig) Expect(err).ToNot(HaveOccurred()) @@ -58,10 +58,10 @@ var _ = Describe("Stateless Resets", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ ConnectionIDLength: connIDLen, MaxIdleTimeout: 2 * time.Second, - }, + }), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.AcceptStream(context.Background()) diff --git a/integrationtests/self/stream_test.go b/integrationtests/self/stream_test.go index e8cba7ff..e5bfded6 100644 --- a/integrationtests/self/stream_test.go +++ b/integrationtests/self/stream_test.go @@ -33,7 +33,7 @@ var _ = Describe("Bidirectional streams", func() { Versions: []protocol.VersionNumber{version}, MaxIncomingStreams: 0, } - server, err = quic.ListenAddr("localhost:0", getTLSConfig(), qconf) + server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfigForServer(qconf)) Expect(err).ToNot(HaveOccurred()) serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port) }) @@ -100,7 +100,7 @@ var _ = Describe("Bidirectional streams", func() { client, err := quic.DialAddr( serverAddr, getTLSClientConfig(), - qconf, + getQuicConfigForClient(qconf), ) Expect(err).ToNot(HaveOccurred()) runSendingPeer(client) @@ -118,7 +118,7 @@ var _ = Describe("Bidirectional streams", func() { client, err := quic.DialAddr( serverAddr, getTLSClientConfig(), - qconf, + getQuicConfigForClient(qconf), ) Expect(err).ToNot(HaveOccurred()) runReceivingPeer(client) @@ -145,7 +145,7 @@ var _ = Describe("Bidirectional streams", func() { client, err := quic.DialAddr( serverAddr, getTLSClientConfig(), - qconf, + getQuicConfigForClient(qconf), ) Expect(err).ToNot(HaveOccurred()) done2 := make(chan struct{}) diff --git a/integrationtests/self/timeout_test.go b/integrationtests/self/timeout_test.go index 53a51c80..4b9a185b 100644 --- a/integrationtests/self/timeout_test.go +++ b/integrationtests/self/timeout_test.go @@ -29,7 +29,7 @@ var _ = Describe("Timeout tests", func() { _, err := quic.DialAddr( "localhost:12345", getTLSClientConfig(), - &quic.Config{HandshakeTimeout: 10 * time.Millisecond}, + getQuicConfigForClient(&quic.Config{HandshakeTimeout: 10 * time.Millisecond}), ) errChan <- err }() @@ -47,7 +47,7 @@ var _ = Describe("Timeout tests", func() { ctx, "localhost:12345", getTLSClientConfig(), - nil, + getQuicConfigForClient(nil), ) errChan <- err }() @@ -63,7 +63,7 @@ var _ = Describe("Timeout tests", func() { server, err := quic.ListenAddr( "localhost:0", getTLSConfig(), - nil, + getQuicConfigForServer(nil), ) Expect(err).ToNot(HaveOccurred()) defer server.Close() @@ -92,7 +92,7 @@ var _ = Describe("Timeout tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{MaxIdleTimeout: idleTimeout}, + getQuicConfigForClient(&quic.Config{MaxIdleTimeout: idleTimeout}), ) Expect(err).ToNot(HaveOccurred()) strIn, err := sess.AcceptStream(context.Background()) @@ -139,7 +139,11 @@ var _ = Describe("Timeout tests", func() { }) It("times out after inactivity", func() { - server, err := quic.ListenAddr("localhost:0", getTLSConfig(), nil) + server, err := quic.ListenAddr( + "localhost:0", + getTLSConfig(), + getQuicConfigForServer(nil), + ) Expect(err).ToNot(HaveOccurred()) defer server.Close() @@ -155,7 +159,7 @@ var _ = Describe("Timeout tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIdleTimeout: idleTimeout}, + getQuicConfigForClient(&quic.Config{MaxIdleTimeout: idleTimeout}), ) Expect(err).ToNot(HaveOccurred()) startTime := time.Now() @@ -180,7 +184,11 @@ var _ = Describe("Timeout tests", func() { }) It("times out after sending a packet", func() { - server, err := quic.ListenAddr("localhost:0", getTLSConfig(), nil) + server, err := quic.ListenAddr( + "localhost:0", + getTLSConfig(), + getQuicConfigForServer(nil), + ) Expect(err).ToNot(HaveOccurred()) defer server.Close() @@ -196,7 +204,7 @@ var _ = Describe("Timeout tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port), getTLSClientConfig(), - &quic.Config{MaxIdleTimeout: idleTimeout}, + getQuicConfigForClient(&quic.Config{MaxIdleTimeout: idleTimeout}), ) Expect(err).ToNot(HaveOccurred()) @@ -236,7 +244,7 @@ var _ = Describe("Timeout tests", func() { server, err := quic.ListenAddr( "localhost:0", getTLSConfig(), - nil, + getQuicConfigForServer(nil), ) Expect(err).ToNot(HaveOccurred()) defer server.Close() @@ -264,10 +272,10 @@ var _ = Describe("Timeout tests", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxy.LocalPort()), getTLSClientConfig(), - &quic.Config{ + getQuicConfigForClient(&quic.Config{ MaxIdleTimeout: idleTimeout, KeepAlive: true, - }, + }), ) Expect(err).ToNot(HaveOccurred()) diff --git a/integrationtests/self/uni_stream_test.go b/integrationtests/self/uni_stream_test.go index 7dfe23c3..ded5357e 100644 --- a/integrationtests/self/uni_stream_test.go +++ b/integrationtests/self/uni_stream_test.go @@ -26,7 +26,7 @@ var _ = Describe("Unidirectional Streams", func() { BeforeEach(func() { var err error qconf = &quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}} - server, err = quic.ListenAddr("localhost:0", getTLSConfig(), qconf) + server, err = quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfigForServer(qconf)) Expect(err).ToNot(HaveOccurred()) serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port) }) @@ -81,7 +81,7 @@ var _ = Describe("Unidirectional Streams", func() { client, err := quic.DialAddr( serverAddr, getTLSClientConfig(), - qconf, + getQuicConfigForClient(qconf), ) Expect(err).ToNot(HaveOccurred()) runSendingPeer(client) @@ -99,7 +99,7 @@ var _ = Describe("Unidirectional Streams", func() { client, err := quic.DialAddr( serverAddr, getTLSClientConfig(), - qconf, + getQuicConfigForClient(qconf), ) Expect(err).ToNot(HaveOccurred()) runReceivingPeer(client) @@ -125,7 +125,7 @@ var _ = Describe("Unidirectional Streams", func() { client, err := quic.DialAddr( serverAddr, getTLSClientConfig(), - qconf, + getQuicConfigForClient(qconf), ) Expect(err).ToNot(HaveOccurred()) done2 := make(chan struct{}) diff --git a/integrationtests/self/zero_rtt_test.go b/integrationtests/self/zero_rtt_test.go index fa73fe25..b7ee9893 100644 --- a/integrationtests/self/zero_rtt_test.go +++ b/integrationtests/self/zero_rtt_test.go @@ -59,7 +59,7 @@ var _ = Describe("0-RTT", func() { sess, err := quic.DialAddr( fmt.Sprintf("localhost:%d", proxyPort), clientConf, - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) Eventually(puts).Should(Receive()) @@ -93,7 +93,7 @@ var _ = Describe("0-RTT", func() { sess, err := quic.DialAddrEarly( fmt.Sprintf("localhost:%d", proxyPort), clientConf, - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) str, err := sess.OpenUniStream() @@ -109,10 +109,10 @@ var _ = Describe("0-RTT", func() { ln, err := quic.ListenAddrEarly( "localhost:0", getTLSConfig(), - &quic.Config{ + getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true }, - }, + }), ) Expect(err).ToNot(HaveOccurred()) defer ln.Close() @@ -171,7 +171,7 @@ var _ = Describe("0-RTT", func() { sess, err := quic.DialAddrEarly( fmt.Sprintf("localhost:%d", proxy.LocalPort()), clientConf, - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForClient(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) sent0RTT := make(chan struct{}) @@ -210,10 +210,10 @@ var _ = Describe("0-RTT", func() { ln, err := quic.ListenAddrEarly( "localhost:0", getTLSConfig(), - &quic.Config{ + getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true }, - }, + }), ) Expect(err).ToNot(HaveOccurred()) defer ln.Close() @@ -264,7 +264,7 @@ var _ = Describe("0-RTT", func() { ln, err := quic.ListenAddrEarly( "localhost:0", getTLSConfig(), - &quic.Config{Versions: []protocol.VersionNumber{version}}, + getQuicConfigForServer(&quic.Config{Versions: []protocol.VersionNumber{version}}), ) Expect(err).ToNot(HaveOccurred()) defer ln.Close() @@ -330,11 +330,11 @@ var _ = Describe("0-RTT", func() { ln, err := quic.ListenAddrEarly( "localhost:0", tlsConf, - &quic.Config{ + getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true }, MaxIncomingStreams: maxStreams, - }, + }), ) Expect(err).ToNot(HaveOccurred()) @@ -345,11 +345,11 @@ var _ = Describe("0-RTT", func() { ln, err = quic.ListenAddrEarly( "localhost:0", tlsConf, - &quic.Config{ + getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true }, MaxIncomingStreams: maxStreams + 1, - }, + }), ) Expect(err).ToNot(HaveOccurred()) proxy, num0RTTPackets := runCountingProxy(ln.Addr().(*net.UDPAddr).Port) @@ -367,10 +367,10 @@ var _ = Describe("0-RTT", func() { ln, err := quic.ListenAddrEarly( "localhost:0", tlsConf, - &quic.Config{ + getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true }, - }, + }), ) Expect(err).ToNot(HaveOccurred()) @@ -383,10 +383,10 @@ var _ = Describe("0-RTT", func() { ln, err = quic.ListenAddrEarly( "localhost:0", tlsConf, - &quic.Config{ + getQuicConfigForServer(&quic.Config{ Versions: []protocol.VersionNumber{version}, AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true }, - }, + }), ) Expect(err).ToNot(HaveOccurred()) proxy, num0RTTPackets := runCountingProxy(ln.Addr().(*net.UDPAddr).Port)