rename the EarlySession to EarlyConnection

This commit is contained in:
Marten Seemann 2022-03-26 15:12:28 +01:00
parent fda9f72161
commit 6aaa9a817c
17 changed files with 232 additions and 228 deletions

View file

@ -68,7 +68,7 @@ func DialAddrEarly(
addr string, addr string,
tlsConf *tls.Config, tlsConf *tls.Config,
config *Config, config *Config,
) (EarlySession, error) { ) (EarlyConnection, error) {
return DialAddrEarlyContext(context.Background(), addr, tlsConf, config) return DialAddrEarlyContext(context.Background(), addr, tlsConf, config)
} }
@ -79,7 +79,7 @@ func DialAddrEarlyContext(
addr string, addr string,
tlsConf *tls.Config, tlsConf *tls.Config,
config *Config, config *Config,
) (EarlySession, error) { ) (EarlyConnection, error) {
sess, err := dialAddrContext(ctx, addr, tlsConf, config, true) sess, err := dialAddrContext(ctx, addr, tlsConf, config, true)
if err != nil { if err != nil {
return nil, err return nil, err
@ -146,7 +146,7 @@ func DialEarly(
host string, host string,
tlsConf *tls.Config, tlsConf *tls.Config,
config *Config, config *Config,
) (EarlySession, error) { ) (EarlyConnection, error) {
return DialEarlyContext(context.Background(), pconn, remoteAddr, host, tlsConf, config) return DialEarlyContext(context.Background(), pconn, remoteAddr, host, tlsConf, config)
} }
@ -159,7 +159,7 @@ func DialEarlyContext(
host string, host string,
tlsConf *tls.Config, tlsConf *tls.Config,
config *Config, config *Config,
) (EarlySession, error) { ) (EarlyConnection, error) {
return dialContext(ctx, pconn, remoteAddr, host, tlsConf, config, true, false) return dialContext(ctx, pconn, remoteAddr, host, tlsConf, config, true, false)
} }

View file

@ -34,7 +34,7 @@ var defaultQuicConfig = &quic.Config{
Versions: []protocol.VersionNumber{protocol.VersionTLS}, Versions: []protocol.VersionNumber{protocol.VersionTLS},
} }
type dialFunc func(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) type dialFunc func(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
var dialAddr = quic.DialAddrEarlyContext var dialAddr = quic.DialAddrEarlyContext
@ -59,7 +59,7 @@ type client struct {
decoder *qpack.Decoder decoder *qpack.Decoder
hostname string hostname string
session quic.EarlySession session quic.EarlyConnection
logger utils.Logger logger utils.Logger
} }

View file

@ -65,7 +65,7 @@ var _ = Describe("Client", func() {
client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil) client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil)
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.EarlySession, error) { dialAddr = func(_ context.Context, _ string, tlsConf *tls.Config, quicConf *quic.Config) (quic.EarlyConnection, error) {
Expect(quicConf).To(Equal(defaultQuicConfig)) Expect(quicConf).To(Equal(defaultQuicConfig))
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}))
@ -80,7 +80,7 @@ var _ = Describe("Client", func() {
client, err := newClient("quic.clemente.io", nil, &roundTripperOpts{}, nil, nil) client, err := newClient("quic.clemente.io", nil, &roundTripperOpts{}, nil, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
var dialAddrCalled bool var dialAddrCalled bool
dialAddr = func(_ context.Context, hostname string, _ *tls.Config, _ *quic.Config) (quic.EarlySession, error) { dialAddr = func(_ context.Context, hostname string, _ *tls.Config, _ *quic.Config) (quic.EarlyConnection, error) {
Expect(hostname).To(Equal("quic.clemente.io:443")) Expect(hostname).To(Equal("quic.clemente.io:443"))
dialAddrCalled = true dialAddrCalled = true
return nil, errors.New("test done") return nil, errors.New("test done")
@ -100,7 +100,7 @@ var _ = Describe("Client", func() {
client, err := newClient("localhost:1337", tlsConf, &roundTripperOpts{}, quicConf, nil) client, err := newClient("localhost:1337", tlsConf, &roundTripperOpts{}, quicConf, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
var dialAddrCalled bool var dialAddrCalled bool
dialAddr = func(_ context.Context, host string, tlsConfP *tls.Config, quicConfP *quic.Config) (quic.EarlySession, error) { dialAddr = func(_ context.Context, host string, tlsConfP *tls.Config, quicConfP *quic.Config) (quic.EarlyConnection, error) {
Expect(host).To(Equal("localhost:1337")) Expect(host).To(Equal("localhost:1337"))
Expect(tlsConfP.ServerName).To(Equal(tlsConf.ServerName)) Expect(tlsConfP.ServerName).To(Equal(tlsConf.ServerName))
Expect(tlsConfP.NextProtos).To(Equal([]string{nextProtoH3})) Expect(tlsConfP.NextProtos).To(Equal([]string{nextProtoH3}))
@ -121,7 +121,7 @@ var _ = Describe("Client", func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Hour) ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
defer cancel() defer cancel()
var dialerCalled bool var dialerCalled bool
dialer := func(ctxP context.Context, network, address string, tlsConfP *tls.Config, quicConfP *quic.Config) (quic.EarlySession, error) { dialer := func(ctxP context.Context, network, address string, tlsConfP *tls.Config, quicConfP *quic.Config) (quic.EarlyConnection, error) {
Expect(ctxP).To(Equal(ctx)) Expect(ctxP).To(Equal(ctx))
Expect(network).To(Equal("udp")) Expect(network).To(Equal("udp"))
Expect(address).To(Equal("localhost:1337")) Expect(address).To(Equal("localhost:1337"))
@ -141,7 +141,7 @@ var _ = Describe("Client", func() {
testErr := errors.New("handshake error") testErr := errors.New("handshake error")
client, err := newClient("localhost:1337", nil, &roundTripperOpts{EnableDatagram: true}, nil, nil) client, err := newClient("localhost:1337", nil, &roundTripperOpts{EnableDatagram: true}, nil, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
dialAddr = func(_ context.Context, _ string, _ *tls.Config, quicConf *quic.Config) (quic.EarlySession, error) { dialAddr = func(_ context.Context, _ string, _ *tls.Config, quicConf *quic.Config) (quic.EarlyConnection, error) {
Expect(quicConf.EnableDatagrams).To(BeTrue()) Expect(quicConf.EnableDatagrams).To(BeTrue())
return nil, testErr return nil, testErr
} }
@ -153,14 +153,14 @@ var _ = Describe("Client", func() {
testErr := errors.New("handshake error") testErr := errors.New("handshake error")
client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil) client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlySession, error) { dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlyConnection, error) {
return nil, testErr return nil, testErr
} }
_, err = client.RoundTrip(req) _, err = client.RoundTrip(req)
Expect(err).To(MatchError(testErr)) Expect(err).To(MatchError(testErr))
}) })
It("closes correctly if session was not created", func() { It("closes correctly if connection was not created", func() {
client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil) client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(client.Close()).To(Succeed()) Expect(client.Close()).To(Succeed())
@ -178,7 +178,7 @@ var _ = Describe("Client", func() {
testErr := errors.New("handshake error") testErr := errors.New("handshake error")
req, err := http.NewRequest("masque", "masque://quic.clemente.io:1337/foobar.html", nil) req, err := http.NewRequest("masque", "masque://quic.clemente.io:1337/foobar.html", nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlySession, error) { dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlyConnection, error) {
return nil, testErr return nil, testErr
} }
_, err = client.RoundTrip(req) _, err = client.RoundTrip(req)
@ -189,7 +189,7 @@ var _ = Describe("Client", func() {
Context("control stream handling", func() { Context("control stream handling", func() {
var ( var (
request *http.Request request *http.Request
sess *mockquic.MockEarlySession conn *mockquic.MockEarlyConnection
settingsFrameWritten chan struct{} settingsFrameWritten chan struct{}
) )
testDone := make(chan struct{}) testDone := make(chan struct{})
@ -201,11 +201,13 @@ var _ = Describe("Client", func() {
defer GinkgoRecover() defer GinkgoRecover()
close(settingsFrameWritten) close(settingsFrameWritten)
}) })
sess = mockquic.NewMockEarlySession(mockCtrl) conn = mockquic.NewMockEarlyConnection(mockCtrl)
sess.EXPECT().OpenUniStream().Return(controlStr, nil) conn.EXPECT().OpenUniStream().Return(controlStr, nil)
sess.EXPECT().HandshakeComplete().Return(handshakeCtx) conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
sess.EXPECT().OpenStreamSync(gomock.Any()).Return(nil, errors.New("done")) conn.EXPECT().OpenStreamSync(gomock.Any()).Return(nil, errors.New("done"))
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlySession, error) { return sess, nil } dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlyConnection, error) {
return conn, nil
}
var err error var err error
request, err = http.NewRequest("GET", "https://quic.clemente.io:1337/file1.dat", nil) request, err = http.NewRequest("GET", "https://quic.clemente.io:1337/file1.dat", nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -222,16 +224,16 @@ var _ = Describe("Client", func() {
(&settingsFrame{}).Write(buf) (&settingsFrame{}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
_, err := client.RoundTrip(request) _, err := client.RoundTrip(request)
Expect(err).To(MatchError("done")) Expect(err).To(MatchError("done"))
time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to sess.CloseWithError time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to conn.CloseWithError
}) })
for _, t := range []uint64{streamTypeQPACKEncoderStream, streamTypeQPACKDecoderStream} { for _, t := range []uint64{streamTypeQPACKEncoderStream, streamTypeQPACKDecoderStream} {
@ -247,10 +249,10 @@ var _ = Describe("Client", func() {
str := mockquic.NewMockStream(mockCtrl) str := mockquic.NewMockStream(mockCtrl)
str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return str, nil return str, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
@ -270,10 +272,10 @@ var _ = Describe("Client", func() {
close(done) close(done)
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return str, nil return str, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
@ -288,15 +290,15 @@ var _ = Describe("Client", func() {
(&dataFrame{}).Write(buf) (&dataFrame{}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorMissingSettings)) Expect(code).To(BeEquivalentTo(errorMissingSettings))
close(done) close(done)
@ -314,15 +316,15 @@ var _ = Describe("Client", func() {
buf.Write(b.Bytes()[:b.Len()-1]) buf.Write(b.Bytes()[:b.Len()-1])
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorFrameError)) Expect(code).To(BeEquivalentTo(errorFrameError))
close(done) close(done)
@ -337,15 +339,15 @@ var _ = Describe("Client", func() {
quicvarint.Write(buf, streamTypePushStream) quicvarint.Write(buf, streamTypePushStream)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorIDError)) Expect(code).To(BeEquivalentTo(errorIDError))
close(done) close(done)
@ -362,16 +364,16 @@ var _ = Describe("Client", func() {
(&settingsFrame{Datagram: true}).Write(buf) (&settingsFrame{Datagram: true}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{SupportsDatagrams: false}) conn.EXPECT().ConnectionState().Return(quic.ConnectionState{SupportsDatagrams: false})
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, reason string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, reason string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorSettingsError)) Expect(code).To(BeEquivalentTo(errorSettingsError))
Expect(reason).To(Equal("missing QUIC Datagram support")) Expect(reason).To(Equal("missing QUIC Datagram support"))
@ -387,7 +389,7 @@ var _ = Describe("Client", func() {
var ( var (
request *http.Request request *http.Request
str *mockquic.MockStream str *mockquic.MockStream
sess *mockquic.MockEarlySession conn *mockquic.MockEarlyConnection
settingsFrameWritten chan struct{} settingsFrameWritten chan struct{}
) )
testDone := make(chan struct{}) testDone := make(chan struct{})
@ -446,13 +448,15 @@ var _ = Describe("Client", func() {
close(settingsFrameWritten) close(settingsFrameWritten)
}) // SETTINGS frame }) // SETTINGS frame
str = mockquic.NewMockStream(mockCtrl) str = mockquic.NewMockStream(mockCtrl)
sess = mockquic.NewMockEarlySession(mockCtrl) conn = mockquic.NewMockEarlyConnection(mockCtrl)
sess.EXPECT().OpenUniStream().Return(controlStr, nil) conn.EXPECT().OpenUniStream().Return(controlStr, nil)
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlySession, error) { return sess, nil } dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlyConnection, error) {
return conn, nil
}
var err error var err error
request, err = http.NewRequest("GET", "https://quic.clemente.io:1337/file1.dat", nil) request, err = http.NewRequest("GET", "https://quic.clemente.io:1337/file1.dat", nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -465,9 +469,9 @@ var _ = Describe("Client", func() {
It("errors if it can't open a stream", func() { It("errors if it can't open a stream", func() {
testErr := errors.New("stream open error") testErr := errors.New("stream open error")
sess.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr) conn.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr)
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).MaxTimes(1) conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).MaxTimes(1)
sess.EXPECT().HandshakeComplete().Return(handshakeCtx) conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
_, err := client.RoundTrip(request) _, err := client.RoundTrip(request)
Expect(err).To(MatchError(testErr)) Expect(err).To(MatchError(testErr))
}) })
@ -476,7 +480,7 @@ var _ = Describe("Client", func() {
testErr := errors.New("stream open error") testErr := errors.New("stream open error")
request.Method = MethodGet0RTT request.Method = MethodGet0RTT
// don't EXPECT any calls to HandshakeComplete() // don't EXPECT any calls to HandshakeComplete()
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil) conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write).AnyTimes() str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write).AnyTimes()
str.EXPECT().Close() str.EXPECT().Close()
@ -492,9 +496,9 @@ var _ = Describe("Client", func() {
It("returns a response", func() { It("returns a response", func() {
rspBuf := bytes.NewBuffer(getResponse(418)) rspBuf := bytes.NewBuffer(getResponse(418))
gomock.InOrder( gomock.InOrder(
sess.EXPECT().HandshakeComplete().Return(handshakeCtx), conn.EXPECT().HandshakeComplete().Return(handshakeCtx),
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil), conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil),
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{}), conn.EXPECT().ConnectionState().Return(quic.ConnectionState{}),
) )
str.EXPECT().Write(gomock.Any()).AnyTimes().DoAndReturn(func(p []byte) (int, error) { return len(p), nil }) str.EXPECT().Write(gomock.Any()).AnyTimes().DoAndReturn(func(p []byte) (int, error) { return len(p), nil })
str.EXPECT().Close() str.EXPECT().Close()
@ -512,8 +516,8 @@ var _ = Describe("Client", func() {
BeforeEach(func() { BeforeEach(func() {
strBuf = &bytes.Buffer{} strBuf = &bytes.Buffer{}
gomock.InOrder( gomock.InOrder(
sess.EXPECT().HandshakeComplete().Return(handshakeCtx), conn.EXPECT().HandshakeComplete().Return(handshakeCtx),
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil), conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil),
) )
body := &mockBody{} body := &mockBody{}
body.SetData([]byte("request body")) body.SetData([]byte("request body"))
@ -570,7 +574,7 @@ var _ = Describe("Client", func() {
(&dataFrame{Length: 0x6}).Write(buf) (&dataFrame{Length: 0x6}).Write(buf)
buf.Write([]byte("foobar")) buf.Write([]byte("foobar"))
str.EXPECT().Close().Do(func() { close(done) }) str.EXPECT().Close().Do(func() { close(done) })
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{}) conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
str.EXPECT().CancelWrite(gomock.Any()).MaxTimes(1) // when reading the response errors str.EXPECT().CancelWrite(gomock.Any()).MaxTimes(1) // when reading the response errors
// the response body is sent asynchronously, while already reading the response // the response body is sent asynchronously, while already reading the response
str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
@ -583,7 +587,7 @@ var _ = Describe("Client", func() {
It("closes the connection when the first frame is not a HEADERS frame", func() { It("closes the connection when the first frame is not a HEADERS frame", func() {
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
(&dataFrame{Length: 0x42}).Write(buf) (&dataFrame{Length: 0x42}).Write(buf)
sess.EXPECT().CloseWithError(quic.ApplicationErrorCode(errorFrameUnexpected), gomock.Any()) conn.EXPECT().CloseWithError(quic.ApplicationErrorCode(errorFrameUnexpected), gomock.Any())
closed := make(chan struct{}) closed := make(chan struct{})
str.EXPECT().Close().Do(func() { close(closed) }) str.EXPECT().Close().Do(func() { close(closed) })
str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
@ -609,7 +613,7 @@ var _ = Describe("Client", func() {
It("cancels a request while waiting for the handshake to complete", func() { It("cancels a request while waiting for the handshake to complete", func() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
req := request.WithContext(ctx) req := request.WithContext(ctx)
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
errChan := make(chan error) errChan := make(chan error)
go func() { go func() {
@ -624,8 +628,8 @@ var _ = Describe("Client", func() {
It("cancels a request while the request is still in flight", func() { It("cancels a request while the request is still in flight", func() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
req := request.WithContext(ctx) req := request.WithContext(ctx)
sess.EXPECT().HandshakeComplete().Return(handshakeCtx) conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
sess.EXPECT().OpenStreamSync(ctx).Return(str, nil) conn.EXPECT().OpenStreamSync(ctx).Return(str, nil)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
str.EXPECT().Close().MaxTimes(1) str.EXPECT().Close().MaxTimes(1)
@ -653,9 +657,9 @@ var _ = Describe("Client", func() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
req := request.WithContext(ctx) req := request.WithContext(ctx)
sess.EXPECT().HandshakeComplete().Return(handshakeCtx) conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
sess.EXPECT().OpenStreamSync(ctx).Return(str, nil) conn.EXPECT().OpenStreamSync(ctx).Return(str, nil)
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{}) conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
str.EXPECT().Close().MaxTimes(1) str.EXPECT().Close().MaxTimes(1)
@ -673,11 +677,11 @@ var _ = Describe("Client", func() {
Context("gzip compression", func() { Context("gzip compression", func() {
BeforeEach(func() { BeforeEach(func() {
sess.EXPECT().HandshakeComplete().Return(handshakeCtx) conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
}) })
It("adds the gzip header to requests", func() { It("adds the gzip header to requests", func() {
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil) conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write) str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write)
gomock.InOrder( gomock.InOrder(
@ -694,7 +698,7 @@ var _ = Describe("Client", func() {
It("doesn't add gzip if the header disable it", func() { It("doesn't add gzip if the header disable it", func() {
client, err := newClient("quic.clemente.io:1337", nil, &roundTripperOpts{DisableCompression: true}, nil, nil) client, err := newClient("quic.clemente.io:1337", nil, &roundTripperOpts{DisableCompression: true}, nil, nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil) conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write) str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write)
gomock.InOrder( gomock.InOrder(
@ -709,8 +713,8 @@ var _ = Describe("Client", func() {
}) })
It("decompresses the response", func() { It("decompresses the response", func() {
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil) conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{}) conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
rstr := mockquic.NewMockStream(mockCtrl) rstr := mockquic.NewMockStream(mockCtrl)
rstr.EXPECT().Write(gomock.Any()).Do(buf.Write).AnyTimes() rstr.EXPECT().Write(gomock.Any()).Do(buf.Write).AnyTimes()
@ -735,8 +739,8 @@ var _ = Describe("Client", func() {
}) })
It("only decompresses the response if the response contains the right content-encoding header", func() { It("only decompresses the response if the response contains the right content-encoding header", func() {
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil) conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{}) conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
rstr := mockquic.NewMockStream(mockCtrl) rstr := mockquic.NewMockStream(mockCtrl)
rstr.EXPECT().Write(gomock.Any()).Do(buf.Write).AnyTimes() rstr.EXPECT().Write(gomock.Any()).Do(buf.Write).AnyTimes()

View file

@ -50,7 +50,7 @@ type RoundTripper struct {
// Dial specifies an optional dial function for creating QUIC // Dial specifies an optional dial function for creating QUIC
// connections for requests. // connections for requests.
// If Dial is nil, quic.DialAddrEarlyContext will be used. // If Dial is nil, quic.DialAddrEarlyContext will be used.
Dial func(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) Dial func(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
// MaxResponseHeaderBytes specifies a limit on how many response bytes are // MaxResponseHeaderBytes specifies a limit on how many response bytes are
// allowed in the server's response header. // allowed in the server's response header.

View file

@ -61,7 +61,7 @@ var _ = Describe("RoundTripper", func() {
var ( var (
rt *RoundTripper rt *RoundTripper
req1 *http.Request req1 *http.Request
session *mockquic.MockEarlySession conn *mockquic.MockEarlyConnection
handshakeCtx context.Context // an already canceled context handshakeCtx context.Context // an already canceled context
) )
@ -80,12 +80,12 @@ var _ = Describe("RoundTripper", func() {
origDialAddr := dialAddr origDialAddr := dialAddr
BeforeEach(func() { BeforeEach(func() {
session = mockquic.NewMockEarlySession(mockCtrl) conn = mockquic.NewMockEarlyConnection(mockCtrl)
origDialAddr = dialAddr origDialAddr = dialAddr
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlySession, error) { dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlyConnection, error) {
// return an error when trying to open a stream // return an error when trying to open a stream
// we don't want to test all the dial logic here, just that dialing happens at all // we don't want to test all the dial logic here, just that dialing happens at all
return session, nil return conn, nil
} }
}) })
@ -98,14 +98,14 @@ var _ = Describe("RoundTripper", func() {
testErr := errors.New("test err") testErr := errors.New("test err")
req, err := http.NewRequest("GET", "https://quic.clemente.io/foobar.html", nil) req, err := http.NewRequest("GET", "https://quic.clemente.io/foobar.html", nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
session.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr) conn.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr)
session.EXPECT().HandshakeComplete().Return(handshakeCtx) conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
session.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr) conn.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr)
session.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-closed <-closed
return nil, errors.New("test done") return nil, errors.New("test done")
}).MaxTimes(1) }).MaxTimes(1)
session.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ApplicationErrorCode, string) { close(closed) }) conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ApplicationErrorCode, string) { close(closed) })
_, err = rt.RoundTrip(req) _, err = rt.RoundTrip(req)
Expect(err).To(MatchError(testErr)) Expect(err).To(MatchError(testErr))
Expect(rt.clients).To(HaveLen(1)) Expect(rt.clients).To(HaveLen(1))
@ -115,7 +115,7 @@ var _ = Describe("RoundTripper", func() {
It("uses the quic.Config, if provided", func() { It("uses the quic.Config, if provided", func() {
config := &quic.Config{HandshakeIdleTimeout: time.Millisecond} config := &quic.Config{HandshakeIdleTimeout: time.Millisecond}
var receivedConfig *quic.Config var receivedConfig *quic.Config
dialAddr = func(_ context.Context, _ string, _ *tls.Config, config *quic.Config) (quic.EarlySession, error) { dialAddr = func(_ context.Context, _ string, _ *tls.Config, config *quic.Config) (quic.EarlyConnection, error) {
receivedConfig = config receivedConfig = config
return nil, errors.New("handshake error") return nil, errors.New("handshake error")
} }
@ -127,7 +127,7 @@ var _ = Describe("RoundTripper", func() {
It("uses the custom dialer, if provided", func() { It("uses the custom dialer, if provided", func() {
var dialed bool var dialed bool
dialer := func(_ context.Context, _, _ string, tlsCfgP *tls.Config, cfg *quic.Config) (quic.EarlySession, error) { dialer := func(_ context.Context, _, _ string, tlsCfgP *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
dialed = true dialed = true
return nil, errors.New("handshake error") return nil, errors.New("handshake error")
} }
@ -140,14 +140,14 @@ var _ = Describe("RoundTripper", func() {
It("reuses existing clients", func() { It("reuses existing clients", func() {
closed := make(chan struct{}) closed := make(chan struct{})
testErr := errors.New("test err") testErr := errors.New("test err")
session.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr) conn.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr)
session.EXPECT().HandshakeComplete().Return(handshakeCtx).Times(2) conn.EXPECT().HandshakeComplete().Return(handshakeCtx).Times(2)
session.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr).Times(2) conn.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr).Times(2)
session.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-closed <-closed
return nil, errors.New("test done") return nil, errors.New("test done")
}).MaxTimes(1) }).MaxTimes(1)
session.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ApplicationErrorCode, string) { close(closed) }) conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ApplicationErrorCode, string) { close(closed) })
req, err := http.NewRequest("GET", "https://quic.clemente.io/file1.html", nil) req, err := http.NewRequest("GET", "https://quic.clemente.io/file1.html", nil)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
_, err = rt.RoundTrip(req) _, err = rt.RoundTrip(req)

View file

@ -334,7 +334,7 @@ func (s *Server) removeListener(l *quic.EarlyListener) {
s.mutex.Unlock() s.mutex.Unlock()
} }
func (s *Server) handleConn(sess quic.EarlySession) { func (s *Server) handleConn(sess quic.EarlyConnection) {
decoder := qpack.NewDecoder(nil) decoder := qpack.NewDecoder(nil)
// send a SETTINGS frame // send a SETTINGS frame
@ -381,7 +381,7 @@ func (s *Server) handleConn(sess quic.EarlySession) {
} }
} }
func (s *Server) handleUnidirectionalStreams(sess quic.EarlySession) { func (s *Server) handleUnidirectionalStreams(sess quic.EarlyConnection) {
for { for {
str, err := sess.AcceptUniStream(context.Background()) str, err := sess.AcceptUniStream(context.Background())
if err != nil { if err != nil {

View file

@ -107,7 +107,7 @@ var _ = Describe("Server", func() {
var ( var (
qpackDecoder *qpack.Decoder qpackDecoder *qpack.Decoder
str *mockquic.MockStream str *mockquic.MockStream
sess *mockquic.MockEarlySession conn *mockquic.MockEarlyConnection
exampleGetRequest *http.Request exampleGetRequest *http.Request
examplePostRequest *http.Request examplePostRequest *http.Request
) )
@ -164,10 +164,10 @@ var _ = Describe("Server", func() {
qpackDecoder = qpack.NewDecoder(nil) qpackDecoder = qpack.NewDecoder(nil)
str = mockquic.NewMockStream(mockCtrl) str = mockquic.NewMockStream(mockCtrl)
sess = mockquic.NewMockEarlySession(mockCtrl) conn = mockquic.NewMockEarlyConnection(mockCtrl)
addr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337} addr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}
sess.EXPECT().RemoteAddr().Return(addr).AnyTimes() conn.EXPECT().RemoteAddr().Return(addr).AnyTimes()
sess.EXPECT().LocalAddr().AnyTimes() conn.EXPECT().LocalAddr().AnyTimes()
}) })
It("calls the HTTP handler function", func() { It("calls the HTTP handler function", func() {
@ -183,7 +183,7 @@ var _ = Describe("Server", func() {
}).AnyTimes() }).AnyTimes()
str.EXPECT().CancelRead(gomock.Any()) str.EXPECT().CancelRead(gomock.Any())
Expect(s.handleRequest(sess, str, qpackDecoder, nil)).To(Equal(requestError{})) Expect(s.handleRequest(conn, str, qpackDecoder, nil)).To(Equal(requestError{}))
var req *http.Request var req *http.Request
Eventually(requestChan).Should(Receive(&req)) Eventually(requestChan).Should(Receive(&req))
Expect(req.Host).To(Equal("www.example.com")) Expect(req.Host).To(Equal("www.example.com"))
@ -200,7 +200,7 @@ var _ = Describe("Server", func() {
str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes() str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes()
str.EXPECT().CancelRead(gomock.Any()) str.EXPECT().CancelRead(gomock.Any())
serr := s.handleRequest(sess, str, qpackDecoder, nil) serr := s.handleRequest(conn, str, qpackDecoder, nil)
Expect(serr.err).ToNot(HaveOccurred()) Expect(serr.err).ToNot(HaveOccurred())
hfs := decodeHeader(responseBuf) hfs := decodeHeader(responseBuf)
Expect(hfs).To(HaveKeyWithValue(":status", []string{"200"})) Expect(hfs).To(HaveKeyWithValue(":status", []string{"200"}))
@ -217,7 +217,7 @@ var _ = Describe("Server", func() {
str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes() str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes()
str.EXPECT().CancelRead(gomock.Any()) str.EXPECT().CancelRead(gomock.Any())
serr := s.handleRequest(sess, str, qpackDecoder, nil) serr := s.handleRequest(conn, str, qpackDecoder, nil)
Expect(serr.err).ToNot(HaveOccurred()) Expect(serr.err).ToNot(HaveOccurred())
hfs := decodeHeader(responseBuf) hfs := decodeHeader(responseBuf)
Expect(hfs).To(HaveKeyWithValue(":status", []string{"500"})) Expect(hfs).To(HaveKeyWithValue(":status", []string{"500"}))
@ -234,22 +234,22 @@ var _ = Describe("Server", func() {
str.EXPECT().Write([]byte("foobar")) str.EXPECT().Write([]byte("foobar"))
// don't EXPECT CancelRead() // don't EXPECT CancelRead()
serr := s.handleRequest(sess, str, qpackDecoder, nil) serr := s.handleRequest(conn, str, qpackDecoder, nil)
Expect(serr.err).ToNot(HaveOccurred()) Expect(serr.err).ToNot(HaveOccurred())
}) })
Context("control stream handling", func() { Context("control stream handling", func() {
var sess *mockquic.MockEarlySession var conn *mockquic.MockEarlyConnection
testDone := make(chan struct{}) testDone := make(chan struct{})
BeforeEach(func() { BeforeEach(func() {
sess = mockquic.NewMockEarlySession(mockCtrl) conn = mockquic.NewMockEarlyConnection(mockCtrl)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Write(gomock.Any()) controlStr.EXPECT().Write(gomock.Any())
sess.EXPECT().OpenUniStream().Return(controlStr, nil) conn.EXPECT().OpenUniStream().Return(controlStr, nil)
sess.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done")) conn.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done"))
sess.EXPECT().RemoteAddr().Return(&net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}).AnyTimes() conn.EXPECT().RemoteAddr().Return(&net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}).AnyTimes()
sess.EXPECT().LocalAddr().AnyTimes() conn.EXPECT().LocalAddr().AnyTimes()
}) })
AfterEach(func() { testDone <- struct{}{} }) AfterEach(func() { testDone <- struct{}{} })
@ -260,15 +260,15 @@ var _ = Describe("Server", func() {
(&settingsFrame{}).Write(buf) (&settingsFrame{}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
s.handleConn(sess) s.handleConn(conn)
time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to sess.CloseWithError time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to conn.CloseWithError
}) })
for _, t := range []uint64{streamTypeQPACKEncoderStream, streamTypeQPACKDecoderStream} { for _, t := range []uint64{streamTypeQPACKEncoderStream, streamTypeQPACKDecoderStream} {
@ -284,14 +284,14 @@ var _ = Describe("Server", func() {
str := mockquic.NewMockStream(mockCtrl) str := mockquic.NewMockStream(mockCtrl)
str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() str.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return str, nil return str, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
s.handleConn(sess) s.handleConn(conn)
time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to str.CancelRead time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to str.CancelRead
}) })
} }
@ -306,14 +306,14 @@ var _ = Describe("Server", func() {
close(done) close(done)
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return str, nil return str, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -323,20 +323,20 @@ var _ = Describe("Server", func() {
(&dataFrame{}).Write(buf) (&dataFrame{}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorMissingSettings)) Expect(code).To(BeEquivalentTo(errorMissingSettings))
close(done) close(done)
}) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -348,20 +348,20 @@ var _ = Describe("Server", func() {
buf.Write(b.Bytes()[:b.Len()-1]) buf.Write(b.Bytes()[:b.Len()-1])
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorFrameError)) Expect(code).To(BeEquivalentTo(errorFrameError))
close(done) close(done)
}) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -371,20 +371,20 @@ var _ = Describe("Server", func() {
(&dataFrame{}).Write(buf) (&dataFrame{}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorStreamCreationError)) Expect(code).To(BeEquivalentTo(errorStreamCreationError))
close(done) close(done)
}) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -395,45 +395,45 @@ var _ = Describe("Server", func() {
(&settingsFrame{Datagram: true}).Write(buf) (&settingsFrame{Datagram: true}).Write(buf)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes() controlStr.EXPECT().Read(gomock.Any()).DoAndReturn(buf.Read).AnyTimes()
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
return controlStr, nil return controlStr, nil
}) })
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{SupportsDatagrams: false}) conn.EXPECT().ConnectionState().Return(quic.ConnectionState{SupportsDatagrams: false})
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, reason string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, reason string) {
defer GinkgoRecover() defer GinkgoRecover()
Expect(code).To(BeEquivalentTo(errorSettingsError)) Expect(code).To(BeEquivalentTo(errorSettingsError))
Expect(reason).To(Equal("missing QUIC Datagram support")) Expect(reason).To(Equal("missing QUIC Datagram support"))
close(done) close(done)
}) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
}) })
Context("stream- and connection-level errors", func() { Context("stream- and connection-level errors", func() {
var sess *mockquic.MockEarlySession var conn *mockquic.MockEarlyConnection
testDone := make(chan struct{}) testDone := make(chan struct{})
BeforeEach(func() { BeforeEach(func() {
testDone = make(chan struct{}) testDone = make(chan struct{})
addr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337} addr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}
sess = mockquic.NewMockEarlySession(mockCtrl) conn = mockquic.NewMockEarlyConnection(mockCtrl)
controlStr := mockquic.NewMockStream(mockCtrl) controlStr := mockquic.NewMockStream(mockCtrl)
controlStr.EXPECT().Write(gomock.Any()) controlStr.EXPECT().Write(gomock.Any())
sess.EXPECT().OpenUniStream().Return(controlStr, nil) conn.EXPECT().OpenUniStream().Return(controlStr, nil)
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) { conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
<-testDone <-testDone
return nil, errors.New("test done") return nil, errors.New("test done")
}) })
sess.EXPECT().AcceptStream(gomock.Any()).Return(str, nil) conn.EXPECT().AcceptStream(gomock.Any()).Return(str, nil)
sess.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done")) conn.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done"))
sess.EXPECT().RemoteAddr().Return(addr).AnyTimes() conn.EXPECT().RemoteAddr().Return(addr).AnyTimes()
sess.EXPECT().LocalAddr().AnyTimes() conn.EXPECT().LocalAddr().AnyTimes()
}) })
AfterEach(func() { testDone <- struct{}{} }) AfterEach(func() { testDone <- struct{}{} })
@ -456,7 +456,7 @@ var _ = Describe("Server", func() {
str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError)) str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError))
str.EXPECT().Close().Do(func() { close(done) }) str.EXPECT().Close().Do(func() { close(done) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
hfs := decodeHeader(responseBuf) hfs := decodeHeader(responseBuf)
Expect(hfs).To(HaveKeyWithValue(":status", []string{"200"})) Expect(hfs).To(HaveKeyWithValue(":status", []string{"200"}))
@ -478,7 +478,7 @@ var _ = Describe("Server", func() {
str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes() str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes()
str.EXPECT().CancelWrite(quic.StreamErrorCode(errorFrameError)).Do(func(quic.StreamErrorCode) { close(done) }) str.EXPECT().CancelWrite(quic.StreamErrorCode(errorFrameError)).Do(func(quic.StreamErrorCode) { close(done) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -493,7 +493,7 @@ var _ = Describe("Server", func() {
str.EXPECT().Read(gomock.Any()).Return(0, testErr) str.EXPECT().Read(gomock.Any()).Return(0, testErr)
str.EXPECT().CancelWrite(quic.StreamErrorCode(errorRequestIncomplete)).Do(func(quic.StreamErrorCode) { close(done) }) str.EXPECT().CancelWrite(quic.StreamErrorCode(errorRequestIncomplete)).Do(func(quic.StreamErrorCode) { close(done) })
s.handleConn(sess) s.handleConn(conn)
Consistently(handlerCalled).ShouldNot(BeClosed()) Consistently(handlerCalled).ShouldNot(BeClosed())
}) })
@ -511,11 +511,11 @@ var _ = Describe("Server", func() {
}).AnyTimes() }).AnyTimes()
done := make(chan struct{}) done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) { conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ApplicationErrorCode, _ string) {
Expect(code).To(Equal(quic.ApplicationErrorCode(errorFrameUnexpected))) Expect(code).To(Equal(quic.ApplicationErrorCode(errorFrameUnexpected)))
close(done) close(done)
}) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -538,7 +538,7 @@ var _ = Describe("Server", func() {
done := make(chan struct{}) done := make(chan struct{})
str.EXPECT().CancelWrite(quic.StreamErrorCode(errorFrameError)).Do(func(quic.StreamErrorCode) { close(done) }) str.EXPECT().CancelWrite(quic.StreamErrorCode(errorFrameError)).Do(func(quic.StreamErrorCode) { close(done) })
s.handleConn(sess) s.handleConn(conn)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
}) })
@ -560,7 +560,7 @@ var _ = Describe("Server", func() {
}).AnyTimes() }).AnyTimes()
str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError)) str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError))
serr := s.handleRequest(sess, str, qpackDecoder, nil) serr := s.handleRequest(conn, str, qpackDecoder, nil)
Expect(serr.err).ToNot(HaveOccurred()) Expect(serr.err).ToNot(HaveOccurred())
Eventually(handlerCalled).Should(BeClosed()) Eventually(handlerCalled).Should(BeClosed())
}) })
@ -583,7 +583,7 @@ var _ = Describe("Server", func() {
}).AnyTimes() }).AnyTimes()
str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError)) str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError))
serr := s.handleRequest(sess, str, qpackDecoder, nil) serr := s.handleRequest(conn, str, qpackDecoder, nil)
Expect(serr.err).ToNot(HaveOccurred()) Expect(serr.err).ToNot(HaveOccurred())
Eventually(handlerCalled).Should(BeClosed()) Eventually(handlerCalled).Should(BeClosed())
}) })

View file

@ -45,7 +45,7 @@ type fakeClosingListener struct {
cancel context.CancelFunc cancel context.CancelFunc
} }
func (ln *fakeClosingListener) Accept(ctx context.Context) (quic.EarlySession, error) { func (ln *fakeClosingListener) Accept(ctx context.Context) (quic.EarlyConnection, error) {
Expect(ctx).To(Equal(context.Background())) Expect(ctx).To(Equal(context.Background()))
return ln.listenerWrapper.Accept(ln.ctx) return ln.listenerWrapper.Accept(ln.ctx)
} }

View file

@ -695,7 +695,7 @@ var _ = Describe("0-RTT", func() {
_, err = conn.AcceptStream(ctx) _, err = conn.AcceptStream(ctx)
Expect(err).To(Equal(quic.Err0RTTRejected)) Expect(err).To(Equal(quic.Err0RTTRejected))
newConn := conn.NextSession() newConn := conn.NextConnection()
str, err := newConn.OpenUniStream() str, err := newConn.OpenUniStream()
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
_, err = newConn.OpenUniStream() _, err = newConn.OpenUniStream()

View file

@ -199,11 +199,11 @@ type Connection interface {
ReceiveMessage() ([]byte, error) ReceiveMessage() ([]byte, error)
} }
// An EarlySession is a connection that is handshaking. // An EarlyConnection is a connection that is handshaking.
// Data sent during the handshake is encrypted using the forward secure keys. // Data sent during the handshake is encrypted using the forward secure keys.
// When using client certificates, the client's identity is only verified // When using client certificates, the client's identity is only verified
// after completion of the handshake. // after completion of the handshake.
type EarlySession interface { type EarlyConnection interface {
Connection Connection
// HandshakeComplete blocks until the handshake completes (or fails). // HandshakeComplete blocks until the handshake completes (or fails).
@ -211,7 +211,7 @@ type EarlySession interface {
// Note that the client's identity hasn't been verified yet. // Note that the client's identity hasn't been verified yet.
HandshakeComplete() context.Context HandshakeComplete() context.Context
NextSession() Connection NextConnection() Connection
} }
// Config contains all configuration data needed for a QUIC server or client. // Config contains all configuration data needed for a QUIC server or client.
@ -326,5 +326,5 @@ type EarlyListener interface {
// Addr returns the local network addr that the server is listening on. // Addr returns the local network addr that the server is listening on.
Addr() net.Addr Addr() net.Addr
// Accept returns new early connections. It should be called in a loop. // Accept returns new early connections. It should be called in a loop.
Accept(context.Context) (EarlySession, error) Accept(context.Context) (EarlyConnection, error)
} }

View file

@ -1,7 +1,7 @@
package mocks package mocks
//go:generate sh -c "mockgen -package mockquic -destination quic/stream.go github.com/lucas-clemente/quic-go Stream" //go:generate sh -c "mockgen -package mockquic -destination quic/stream.go github.com/lucas-clemente/quic-go Stream"
//go:generate sh -c "mockgen -package mockquic -destination quic/early_session_tmp.go github.com/lucas-clemente/quic-go EarlySession && sed 's/qtls.ConnectionState/quic.ConnectionState/g' quic/early_session_tmp.go > quic/early_session.go && rm quic/early_session_tmp.go && goimports -w quic/early_session.go" //go:generate sh -c "mockgen -package mockquic -destination quic/early_conn_tmp.go github.com/lucas-clemente/quic-go EarlyConnection && sed 's/qtls.ConnectionState/quic.ConnectionState/g' quic/early_conn_tmp.go > quic/early_conn.go && rm quic/early_conn_tmp.go && goimports -w quic/early_conn.go"
//go:generate sh -c "mockgen -package mockquic -destination quic/early_listener.go github.com/lucas-clemente/quic-go EarlyListener" //go:generate sh -c "mockgen -package mockquic -destination quic/early_listener.go github.com/lucas-clemente/quic-go EarlyListener"
//go:generate sh -c "mockgen -package mocklogging -destination logging/tracer.go github.com/lucas-clemente/quic-go/logging Tracer" //go:generate sh -c "mockgen -package mocklogging -destination logging/tracer.go github.com/lucas-clemente/quic-go/logging Tracer"
//go:generate sh -c "mockgen -package mocklogging -destination logging/connection_tracer.go github.com/lucas-clemente/quic-go/logging ConnectionTracer" //go:generate sh -c "mockgen -package mocklogging -destination logging/connection_tracer.go github.com/lucas-clemente/quic-go/logging ConnectionTracer"

View file

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT. // Code generated by MockGen. DO NOT EDIT.
// Source: github.com/lucas-clemente/quic-go (interfaces: EarlySession) // Source: github.com/lucas-clemente/quic-go (interfaces: EarlyConnection)
// Package mockquic is a generated GoMock package. // Package mockquic is a generated GoMock package.
package mockquic package mockquic
@ -14,31 +14,31 @@ import (
qerr "github.com/lucas-clemente/quic-go/internal/qerr" qerr "github.com/lucas-clemente/quic-go/internal/qerr"
) )
// MockEarlySession is a mock of EarlySession interface. // MockEarlyConnection is a mock of EarlyConnection interface.
type MockEarlySession struct { type MockEarlyConnection struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockEarlySessionMockRecorder recorder *MockEarlyConnectionMockRecorder
} }
// MockEarlySessionMockRecorder is the mock recorder for MockEarlySession. // MockEarlyConnectionMockRecorder is the mock recorder for MockEarlyConnection.
type MockEarlySessionMockRecorder struct { type MockEarlyConnectionMockRecorder struct {
mock *MockEarlySession mock *MockEarlyConnection
} }
// NewMockEarlySession creates a new mock instance. // NewMockEarlyConnection creates a new mock instance.
func NewMockEarlySession(ctrl *gomock.Controller) *MockEarlySession { func NewMockEarlyConnection(ctrl *gomock.Controller) *MockEarlyConnection {
mock := &MockEarlySession{ctrl: ctrl} mock := &MockEarlyConnection{ctrl: ctrl}
mock.recorder = &MockEarlySessionMockRecorder{mock} mock.recorder = &MockEarlyConnectionMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use. // EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockEarlySession) EXPECT() *MockEarlySessionMockRecorder { func (m *MockEarlyConnection) EXPECT() *MockEarlyConnectionMockRecorder {
return m.recorder return m.recorder
} }
// AcceptStream mocks base method. // AcceptStream mocks base method.
func (m *MockEarlySession) AcceptStream(arg0 context.Context) (quic.Stream, error) { func (m *MockEarlyConnection) AcceptStream(arg0 context.Context) (quic.Stream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AcceptStream", arg0) ret := m.ctrl.Call(m, "AcceptStream", arg0)
ret0, _ := ret[0].(quic.Stream) ret0, _ := ret[0].(quic.Stream)
@ -47,13 +47,13 @@ func (m *MockEarlySession) AcceptStream(arg0 context.Context) (quic.Stream, erro
} }
// AcceptStream indicates an expected call of AcceptStream. // AcceptStream indicates an expected call of AcceptStream.
func (mr *MockEarlySessionMockRecorder) AcceptStream(arg0 interface{}) *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) AcceptStream(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptStream", reflect.TypeOf((*MockEarlySession)(nil).AcceptStream), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptStream", reflect.TypeOf((*MockEarlyConnection)(nil).AcceptStream), arg0)
} }
// AcceptUniStream mocks base method. // AcceptUniStream mocks base method.
func (m *MockEarlySession) AcceptUniStream(arg0 context.Context) (quic.ReceiveStream, error) { func (m *MockEarlyConnection) AcceptUniStream(arg0 context.Context) (quic.ReceiveStream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AcceptUniStream", arg0) ret := m.ctrl.Call(m, "AcceptUniStream", arg0)
ret0, _ := ret[0].(quic.ReceiveStream) ret0, _ := ret[0].(quic.ReceiveStream)
@ -62,13 +62,13 @@ func (m *MockEarlySession) AcceptUniStream(arg0 context.Context) (quic.ReceiveSt
} }
// AcceptUniStream indicates an expected call of AcceptUniStream. // AcceptUniStream indicates an expected call of AcceptUniStream.
func (mr *MockEarlySessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockEarlySession)(nil).AcceptUniStream), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockEarlyConnection)(nil).AcceptUniStream), arg0)
} }
// CloseWithError mocks base method. // CloseWithError mocks base method.
func (m *MockEarlySession) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 string) error { func (m *MockEarlyConnection) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 string) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1) ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -76,13 +76,13 @@ func (m *MockEarlySession) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 s
} }
// CloseWithError indicates an expected call of CloseWithError. // CloseWithError indicates an expected call of CloseWithError.
func (mr *MockEarlySessionMockRecorder) CloseWithError(arg0, arg1 interface{}) *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) CloseWithError(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseWithError", reflect.TypeOf((*MockEarlySession)(nil).CloseWithError), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseWithError", reflect.TypeOf((*MockEarlyConnection)(nil).CloseWithError), arg0, arg1)
} }
// ConnectionState mocks base method. // ConnectionState mocks base method.
func (m *MockEarlySession) ConnectionState() quic.ConnectionState { func (m *MockEarlyConnection) ConnectionState() quic.ConnectionState {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConnectionState") ret := m.ctrl.Call(m, "ConnectionState")
ret0, _ := ret[0].(quic.ConnectionState) ret0, _ := ret[0].(quic.ConnectionState)
@ -90,13 +90,13 @@ func (m *MockEarlySession) ConnectionState() quic.ConnectionState {
} }
// ConnectionState indicates an expected call of ConnectionState. // ConnectionState indicates an expected call of ConnectionState.
func (mr *MockEarlySessionMockRecorder) ConnectionState() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) ConnectionState() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectionState", reflect.TypeOf((*MockEarlySession)(nil).ConnectionState)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectionState", reflect.TypeOf((*MockEarlyConnection)(nil).ConnectionState))
} }
// Context mocks base method. // Context mocks base method.
func (m *MockEarlySession) Context() context.Context { func (m *MockEarlyConnection) Context() context.Context {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Context") ret := m.ctrl.Call(m, "Context")
ret0, _ := ret[0].(context.Context) ret0, _ := ret[0].(context.Context)
@ -104,13 +104,13 @@ func (m *MockEarlySession) Context() context.Context {
} }
// Context indicates an expected call of Context. // Context indicates an expected call of Context.
func (mr *MockEarlySessionMockRecorder) Context() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) Context() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockEarlySession)(nil).Context)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockEarlyConnection)(nil).Context))
} }
// HandshakeComplete mocks base method. // HandshakeComplete mocks base method.
func (m *MockEarlySession) HandshakeComplete() context.Context { func (m *MockEarlyConnection) HandshakeComplete() context.Context {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HandshakeComplete") ret := m.ctrl.Call(m, "HandshakeComplete")
ret0, _ := ret[0].(context.Context) ret0, _ := ret[0].(context.Context)
@ -118,13 +118,13 @@ func (m *MockEarlySession) HandshakeComplete() context.Context {
} }
// HandshakeComplete indicates an expected call of HandshakeComplete. // HandshakeComplete indicates an expected call of HandshakeComplete.
func (mr *MockEarlySessionMockRecorder) HandshakeComplete() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) HandshakeComplete() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandshakeComplete", reflect.TypeOf((*MockEarlySession)(nil).HandshakeComplete)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandshakeComplete", reflect.TypeOf((*MockEarlyConnection)(nil).HandshakeComplete))
} }
// LocalAddr mocks base method. // LocalAddr mocks base method.
func (m *MockEarlySession) LocalAddr() net.Addr { func (m *MockEarlyConnection) LocalAddr() net.Addr {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LocalAddr") ret := m.ctrl.Call(m, "LocalAddr")
ret0, _ := ret[0].(net.Addr) ret0, _ := ret[0].(net.Addr)
@ -132,27 +132,27 @@ func (m *MockEarlySession) LocalAddr() net.Addr {
} }
// LocalAddr indicates an expected call of LocalAddr. // LocalAddr indicates an expected call of LocalAddr.
func (mr *MockEarlySessionMockRecorder) LocalAddr() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) LocalAddr() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockEarlySession)(nil).LocalAddr)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockEarlyConnection)(nil).LocalAddr))
} }
// NextSession mocks base method. // NextConnection mocks base method.
func (m *MockEarlySession) NextSession() quic.Connection { func (m *MockEarlyConnection) NextConnection() quic.Connection {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NextSession") ret := m.ctrl.Call(m, "NextConnection")
ret0, _ := ret[0].(quic.Connection) ret0, _ := ret[0].(quic.Connection)
return ret0 return ret0
} }
// NextSession indicates an expected call of NextSession. // NextConnection indicates an expected call of NextConnection.
func (mr *MockEarlySessionMockRecorder) NextSession() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) NextConnection() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextSession", reflect.TypeOf((*MockEarlySession)(nil).NextSession)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextConnection", reflect.TypeOf((*MockEarlyConnection)(nil).NextConnection))
} }
// OpenStream mocks base method. // OpenStream mocks base method.
func (m *MockEarlySession) OpenStream() (quic.Stream, error) { func (m *MockEarlyConnection) OpenStream() (quic.Stream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenStream") ret := m.ctrl.Call(m, "OpenStream")
ret0, _ := ret[0].(quic.Stream) ret0, _ := ret[0].(quic.Stream)
@ -161,13 +161,13 @@ func (m *MockEarlySession) OpenStream() (quic.Stream, error) {
} }
// OpenStream indicates an expected call of OpenStream. // OpenStream indicates an expected call of OpenStream.
func (mr *MockEarlySessionMockRecorder) OpenStream() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) OpenStream() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStream", reflect.TypeOf((*MockEarlySession)(nil).OpenStream)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStream", reflect.TypeOf((*MockEarlyConnection)(nil).OpenStream))
} }
// OpenStreamSync mocks base method. // OpenStreamSync mocks base method.
func (m *MockEarlySession) OpenStreamSync(arg0 context.Context) (quic.Stream, error) { func (m *MockEarlyConnection) OpenStreamSync(arg0 context.Context) (quic.Stream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenStreamSync", arg0) ret := m.ctrl.Call(m, "OpenStreamSync", arg0)
ret0, _ := ret[0].(quic.Stream) ret0, _ := ret[0].(quic.Stream)
@ -176,13 +176,13 @@ func (m *MockEarlySession) OpenStreamSync(arg0 context.Context) (quic.Stream, er
} }
// OpenStreamSync indicates an expected call of OpenStreamSync. // OpenStreamSync indicates an expected call of OpenStreamSync.
func (mr *MockEarlySessionMockRecorder) OpenStreamSync(arg0 interface{}) *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) OpenStreamSync(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStreamSync", reflect.TypeOf((*MockEarlySession)(nil).OpenStreamSync), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStreamSync", reflect.TypeOf((*MockEarlyConnection)(nil).OpenStreamSync), arg0)
} }
// OpenUniStream mocks base method. // OpenUniStream mocks base method.
func (m *MockEarlySession) OpenUniStream() (quic.SendStream, error) { func (m *MockEarlyConnection) OpenUniStream() (quic.SendStream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenUniStream") ret := m.ctrl.Call(m, "OpenUniStream")
ret0, _ := ret[0].(quic.SendStream) ret0, _ := ret[0].(quic.SendStream)
@ -191,13 +191,13 @@ func (m *MockEarlySession) OpenUniStream() (quic.SendStream, error) {
} }
// OpenUniStream indicates an expected call of OpenUniStream. // OpenUniStream indicates an expected call of OpenUniStream.
func (mr *MockEarlySessionMockRecorder) OpenUniStream() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) OpenUniStream() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStream", reflect.TypeOf((*MockEarlySession)(nil).OpenUniStream)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStream", reflect.TypeOf((*MockEarlyConnection)(nil).OpenUniStream))
} }
// OpenUniStreamSync mocks base method. // OpenUniStreamSync mocks base method.
func (m *MockEarlySession) OpenUniStreamSync(arg0 context.Context) (quic.SendStream, error) { func (m *MockEarlyConnection) OpenUniStreamSync(arg0 context.Context) (quic.SendStream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenUniStreamSync", arg0) ret := m.ctrl.Call(m, "OpenUniStreamSync", arg0)
ret0, _ := ret[0].(quic.SendStream) ret0, _ := ret[0].(quic.SendStream)
@ -206,13 +206,13 @@ func (m *MockEarlySession) OpenUniStreamSync(arg0 context.Context) (quic.SendStr
} }
// OpenUniStreamSync indicates an expected call of OpenUniStreamSync. // OpenUniStreamSync indicates an expected call of OpenUniStreamSync.
func (mr *MockEarlySessionMockRecorder) OpenUniStreamSync(arg0 interface{}) *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) OpenUniStreamSync(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStreamSync", reflect.TypeOf((*MockEarlySession)(nil).OpenUniStreamSync), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStreamSync", reflect.TypeOf((*MockEarlyConnection)(nil).OpenUniStreamSync), arg0)
} }
// ReceiveMessage mocks base method. // ReceiveMessage mocks base method.
func (m *MockEarlySession) ReceiveMessage() ([]byte, error) { func (m *MockEarlyConnection) ReceiveMessage() ([]byte, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ReceiveMessage") ret := m.ctrl.Call(m, "ReceiveMessage")
ret0, _ := ret[0].([]byte) ret0, _ := ret[0].([]byte)
@ -221,13 +221,13 @@ func (m *MockEarlySession) ReceiveMessage() ([]byte, error) {
} }
// ReceiveMessage indicates an expected call of ReceiveMessage. // ReceiveMessage indicates an expected call of ReceiveMessage.
func (mr *MockEarlySessionMockRecorder) ReceiveMessage() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) ReceiveMessage() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveMessage", reflect.TypeOf((*MockEarlySession)(nil).ReceiveMessage)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveMessage", reflect.TypeOf((*MockEarlyConnection)(nil).ReceiveMessage))
} }
// RemoteAddr mocks base method. // RemoteAddr mocks base method.
func (m *MockEarlySession) RemoteAddr() net.Addr { func (m *MockEarlyConnection) RemoteAddr() net.Addr {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RemoteAddr") ret := m.ctrl.Call(m, "RemoteAddr")
ret0, _ := ret[0].(net.Addr) ret0, _ := ret[0].(net.Addr)
@ -235,13 +235,13 @@ func (m *MockEarlySession) RemoteAddr() net.Addr {
} }
// RemoteAddr indicates an expected call of RemoteAddr. // RemoteAddr indicates an expected call of RemoteAddr.
func (mr *MockEarlySessionMockRecorder) RemoteAddr() *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) RemoteAddr() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockEarlySession)(nil).RemoteAddr)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockEarlyConnection)(nil).RemoteAddr))
} }
// SendMessage mocks base method. // SendMessage mocks base method.
func (m *MockEarlySession) SendMessage(arg0 []byte) error { func (m *MockEarlyConnection) SendMessage(arg0 []byte) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendMessage", arg0) ret := m.ctrl.Call(m, "SendMessage", arg0)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -249,7 +249,7 @@ func (m *MockEarlySession) SendMessage(arg0 []byte) error {
} }
// SendMessage indicates an expected call of SendMessage. // SendMessage indicates an expected call of SendMessage.
func (mr *MockEarlySessionMockRecorder) SendMessage(arg0 interface{}) *gomock.Call { func (mr *MockEarlyConnectionMockRecorder) SendMessage(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMessage", reflect.TypeOf((*MockEarlySession)(nil).SendMessage), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMessage", reflect.TypeOf((*MockEarlyConnection)(nil).SendMessage), arg0)
} }

View file

@ -37,10 +37,10 @@ func (m *MockEarlyListener) EXPECT() *MockEarlyListenerMockRecorder {
} }
// Accept mocks base method. // Accept mocks base method.
func (m *MockEarlyListener) Accept(arg0 context.Context) (quic.EarlySession, error) { func (m *MockEarlyListener) Accept(arg0 context.Context) (quic.EarlyConnection, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Accept", arg0) ret := m.ctrl.Call(m, "Accept", arg0)
ret0, _ := ret[0].(quic.EarlySession) ret0, _ := ret[0].(quic.EarlyConnection)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }

View file

@ -84,7 +84,7 @@ type client struct {
quicConf *quic.Config quicConf *quic.Config
once sync.Once once sync.Once
conn quic.EarlySession conn quic.EarlyConnection
dialErr error dialErr error
} }

View file

@ -150,18 +150,18 @@ func (mr *MockQuicSessionMockRecorder) LocalAddr() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockQuicSession)(nil).LocalAddr)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockQuicSession)(nil).LocalAddr))
} }
// NextSession mocks base method. // NextConnection mocks base method.
func (m *MockQuicSession) NextSession() Connection { func (m *MockQuicSession) NextConnection() Connection {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NextSession") ret := m.ctrl.Call(m, "NextConnection")
ret0, _ := ret[0].(Connection) ret0, _ := ret[0].(Connection)
return ret0 return ret0
} }
// NextSession indicates an expected call of NextSession. // NextConnection indicates an expected call of NextConnection.
func (mr *MockQuicSessionMockRecorder) NextSession() *gomock.Call { func (mr *MockQuicSessionMockRecorder) NextConnection() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextSession", reflect.TypeOf((*MockQuicSession)(nil).NextSession)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextConnection", reflect.TypeOf((*MockQuicSession)(nil).NextConnection))
} }
// OpenStream mocks base method. // OpenStream mocks base method.

View file

@ -42,7 +42,7 @@ type packetHandlerManager interface {
} }
type quicSession interface { type quicSession interface {
EarlySession EarlyConnection
earlySessionReady() <-chan struct{} earlySessionReady() <-chan struct{}
handlePacket(*receivedPacket) handlePacket(*receivedPacket)
GetVersion() protocol.VersionNumber GetVersion() protocol.VersionNumber
@ -112,7 +112,7 @@ type earlyServer struct{ *baseServer }
var _ EarlyListener = &earlyServer{} var _ EarlyListener = &earlyServer{}
func (s *earlyServer) Accept(ctx context.Context) (EarlySession, error) { func (s *earlyServer) Accept(ctx context.Context) (EarlyConnection, error) {
return s.baseServer.accept(ctx) return s.baseServer.accept(ctx)
} }

View file

@ -222,10 +222,10 @@ type session struct {
} }
var ( var (
_ Connection = &session{} _ Connection = &session{}
_ EarlySession = &session{} _ EarlyConnection = &session{}
_ streamSender = &session{} _ streamSender = &session{}
deadlineSendImmediately = time.Time{}.Add(42 * time.Millisecond) // any value > time.Time{} and before time.Now() is fine deadlineSendImmediately = time.Time{}.Add(42 * time.Millisecond) // any value > time.Time{} and before time.Now() is fine
) )
var newSession = func( var newSession = func(
@ -1996,7 +1996,7 @@ func (s *session) GetVersion() protocol.VersionNumber {
return s.version return s.version
} }
func (s *session) NextSession() Connection { func (s *session) NextConnection() Connection {
<-s.HandshakeComplete().Done() <-s.HandshakeComplete().Done()
s.streamsMap.UseResetMaps() s.streamsMap.UseResetMaps()
return s return s