mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
rename the EarlySession to EarlyConnection
This commit is contained in:
parent
fda9f72161
commit
6aaa9a817c
17 changed files with 232 additions and 228 deletions
|
@ -68,7 +68,7 @@ func DialAddrEarly(
|
|||
addr string,
|
||||
tlsConf *tls.Config,
|
||||
config *Config,
|
||||
) (EarlySession, error) {
|
||||
) (EarlyConnection, error) {
|
||||
return DialAddrEarlyContext(context.Background(), addr, tlsConf, config)
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ func DialAddrEarlyContext(
|
|||
addr string,
|
||||
tlsConf *tls.Config,
|
||||
config *Config,
|
||||
) (EarlySession, error) {
|
||||
) (EarlyConnection, error) {
|
||||
sess, err := dialAddrContext(ctx, addr, tlsConf, config, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -146,7 +146,7 @@ func DialEarly(
|
|||
host string,
|
||||
tlsConf *tls.Config,
|
||||
config *Config,
|
||||
) (EarlySession, error) {
|
||||
) (EarlyConnection, error) {
|
||||
return DialEarlyContext(context.Background(), pconn, remoteAddr, host, tlsConf, config)
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ func DialEarlyContext(
|
|||
host string,
|
||||
tlsConf *tls.Config,
|
||||
config *Config,
|
||||
) (EarlySession, error) {
|
||||
) (EarlyConnection, error) {
|
||||
return dialContext(ctx, pconn, remoteAddr, host, tlsConf, config, true, false)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ var defaultQuicConfig = &quic.Config{
|
|||
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
|
||||
|
||||
|
@ -59,7 +59,7 @@ type client struct {
|
|||
decoder *qpack.Decoder
|
||||
|
||||
hostname string
|
||||
session quic.EarlySession
|
||||
session quic.EarlyConnection
|
||||
|
||||
logger utils.Logger
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ var _ = Describe("Client", func() {
|
|||
client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
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(tlsConf.NextProtos).To(Equal([]string{nextProtoH3}))
|
||||
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)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
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"))
|
||||
dialAddrCalled = true
|
||||
return nil, errors.New("test done")
|
||||
|
@ -100,7 +100,7 @@ var _ = Describe("Client", func() {
|
|||
client, err := newClient("localhost:1337", tlsConf, &roundTripperOpts{}, quicConf, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
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(tlsConfP.ServerName).To(Equal(tlsConf.ServerName))
|
||||
Expect(tlsConfP.NextProtos).To(Equal([]string{nextProtoH3}))
|
||||
|
@ -121,7 +121,7 @@ var _ = Describe("Client", func() {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
|
||||
defer cancel()
|
||||
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(network).To(Equal("udp"))
|
||||
Expect(address).To(Equal("localhost:1337"))
|
||||
|
@ -141,7 +141,7 @@ var _ = Describe("Client", func() {
|
|||
testErr := errors.New("handshake error")
|
||||
client, err := newClient("localhost:1337", nil, &roundTripperOpts{EnableDatagram: true}, nil, nil)
|
||||
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())
|
||||
return nil, testErr
|
||||
}
|
||||
|
@ -153,14 +153,14 @@ var _ = Describe("Client", func() {
|
|||
testErr := errors.New("handshake error")
|
||||
client, err := newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil)
|
||||
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
|
||||
}
|
||||
_, err = client.RoundTrip(req)
|
||||
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)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(client.Close()).To(Succeed())
|
||||
|
@ -178,7 +178,7 @@ var _ = Describe("Client", func() {
|
|||
testErr := errors.New("handshake error")
|
||||
req, err := http.NewRequest("masque", "masque://quic.clemente.io:1337/foobar.html", nil)
|
||||
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
|
||||
}
|
||||
_, err = client.RoundTrip(req)
|
||||
|
@ -189,7 +189,7 @@ var _ = Describe("Client", func() {
|
|||
Context("control stream handling", func() {
|
||||
var (
|
||||
request *http.Request
|
||||
sess *mockquic.MockEarlySession
|
||||
conn *mockquic.MockEarlyConnection
|
||||
settingsFrameWritten chan struct{}
|
||||
)
|
||||
testDone := make(chan struct{})
|
||||
|
@ -201,11 +201,13 @@ var _ = Describe("Client", func() {
|
|||
defer GinkgoRecover()
|
||||
close(settingsFrameWritten)
|
||||
})
|
||||
sess = mockquic.NewMockEarlySession(mockCtrl)
|
||||
sess.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
sess.EXPECT().OpenStreamSync(gomock.Any()).Return(nil, errors.New("done"))
|
||||
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlySession, error) { return sess, nil }
|
||||
conn = mockquic.NewMockEarlyConnection(mockCtrl)
|
||||
conn.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
conn.EXPECT().OpenStreamSync(gomock.Any()).Return(nil, errors.New("done"))
|
||||
dialAddr = func(context.Context, string, *tls.Config, *quic.Config) (quic.EarlyConnection, error) {
|
||||
return conn, nil
|
||||
}
|
||||
var err error
|
||||
request, err = http.NewRequest("GET", "https://quic.clemente.io:1337/file1.dat", nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -222,16 +224,16 @@ var _ = Describe("Client", func() {
|
|||
(&settingsFrame{}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
_, err := client.RoundTrip(request)
|
||||
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} {
|
||||
|
@ -247,10 +249,10 @@ var _ = Describe("Client", func() {
|
|||
str := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
|
@ -270,10 +272,10 @@ var _ = Describe("Client", func() {
|
|||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
|
@ -288,15 +290,15 @@ var _ = Describe("Client", func() {
|
|||
(&dataFrame{}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorMissingSettings))
|
||||
close(done)
|
||||
|
@ -314,15 +316,15 @@ var _ = Describe("Client", func() {
|
|||
buf.Write(b.Bytes()[:b.Len()-1])
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorFrameError))
|
||||
close(done)
|
||||
|
@ -337,15 +339,15 @@ var _ = Describe("Client", func() {
|
|||
quicvarint.Write(buf, streamTypePushStream)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorIDError))
|
||||
close(done)
|
||||
|
@ -362,16 +364,16 @@ var _ = Describe("Client", func() {
|
|||
(&settingsFrame{Datagram: true}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
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{})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorSettingsError))
|
||||
Expect(reason).To(Equal("missing QUIC Datagram support"))
|
||||
|
@ -387,7 +389,7 @@ var _ = Describe("Client", func() {
|
|||
var (
|
||||
request *http.Request
|
||||
str *mockquic.MockStream
|
||||
sess *mockquic.MockEarlySession
|
||||
conn *mockquic.MockEarlyConnection
|
||||
settingsFrameWritten chan struct{}
|
||||
)
|
||||
testDone := make(chan struct{})
|
||||
|
@ -446,13 +448,15 @@ var _ = Describe("Client", func() {
|
|||
close(settingsFrameWritten)
|
||||
}) // SETTINGS frame
|
||||
str = mockquic.NewMockStream(mockCtrl)
|
||||
sess = mockquic.NewMockEarlySession(mockCtrl)
|
||||
sess.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
conn = mockquic.NewMockEarlyConnection(mockCtrl)
|
||||
conn.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
<-testDone
|
||||
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
|
||||
request, err = http.NewRequest("GET", "https://quic.clemente.io:1337/file1.dat", nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -465,9 +469,9 @@ var _ = Describe("Client", func() {
|
|||
|
||||
It("errors if it can't open a stream", func() {
|
||||
testErr := errors.New("stream open error")
|
||||
sess.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr)
|
||||
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).MaxTimes(1)
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr)
|
||||
conn.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).MaxTimes(1)
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
_, err := client.RoundTrip(request)
|
||||
Expect(err).To(MatchError(testErr))
|
||||
})
|
||||
|
@ -476,7 +480,7 @@ var _ = Describe("Client", func() {
|
|||
testErr := errors.New("stream open error")
|
||||
request.Method = MethodGet0RTT
|
||||
// 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{}
|
||||
str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write).AnyTimes()
|
||||
str.EXPECT().Close()
|
||||
|
@ -492,9 +496,9 @@ var _ = Describe("Client", func() {
|
|||
It("returns a response", func() {
|
||||
rspBuf := bytes.NewBuffer(getResponse(418))
|
||||
gomock.InOrder(
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx),
|
||||
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil),
|
||||
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{}),
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx),
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil),
|
||||
conn.EXPECT().ConnectionState().Return(quic.ConnectionState{}),
|
||||
)
|
||||
str.EXPECT().Write(gomock.Any()).AnyTimes().DoAndReturn(func(p []byte) (int, error) { return len(p), nil })
|
||||
str.EXPECT().Close()
|
||||
|
@ -512,8 +516,8 @@ var _ = Describe("Client", func() {
|
|||
BeforeEach(func() {
|
||||
strBuf = &bytes.Buffer{}
|
||||
gomock.InOrder(
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx),
|
||||
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil),
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx),
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil),
|
||||
)
|
||||
body := &mockBody{}
|
||||
body.SetData([]byte("request body"))
|
||||
|
@ -570,7 +574,7 @@ var _ = Describe("Client", func() {
|
|||
(&dataFrame{Length: 0x6}).Write(buf)
|
||||
buf.Write([]byte("foobar"))
|
||||
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
|
||||
// the response body is sent asynchronously, while already reading the response
|
||||
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() {
|
||||
buf := &bytes.Buffer{}
|
||||
(&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{})
|
||||
str.EXPECT().Close().Do(func() { close(closed) })
|
||||
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() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
req := request.WithContext(ctx)
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
|
||||
errChan := make(chan error)
|
||||
go func() {
|
||||
|
@ -624,8 +628,8 @@ var _ = Describe("Client", func() {
|
|||
It("cancels a request while the request is still in flight", func() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
req := request.WithContext(ctx)
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
sess.EXPECT().OpenStreamSync(ctx).Return(str, nil)
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
conn.EXPECT().OpenStreamSync(ctx).Return(str, nil)
|
||||
buf := &bytes.Buffer{}
|
||||
str.EXPECT().Close().MaxTimes(1)
|
||||
|
||||
|
@ -653,9 +657,9 @@ var _ = Describe("Client", func() {
|
|||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
req := request.WithContext(ctx)
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
sess.EXPECT().OpenStreamSync(ctx).Return(str, nil)
|
||||
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{})
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
conn.EXPECT().OpenStreamSync(ctx).Return(str, nil)
|
||||
conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
|
||||
buf := &bytes.Buffer{}
|
||||
str.EXPECT().Close().MaxTimes(1)
|
||||
|
||||
|
@ -673,11 +677,11 @@ var _ = Describe("Client", func() {
|
|||
|
||||
Context("gzip compression", func() {
|
||||
BeforeEach(func() {
|
||||
sess.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
})
|
||||
|
||||
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{}
|
||||
str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write)
|
||||
gomock.InOrder(
|
||||
|
@ -694,7 +698,7 @@ var _ = Describe("Client", 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)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
|
||||
buf := &bytes.Buffer{}
|
||||
str.EXPECT().Write(gomock.Any()).DoAndReturn(buf.Write)
|
||||
gomock.InOrder(
|
||||
|
@ -709,8 +713,8 @@ var _ = Describe("Client", func() {
|
|||
})
|
||||
|
||||
It("decompresses the response", func() {
|
||||
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
|
||||
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{})
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
|
||||
conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
|
||||
buf := &bytes.Buffer{}
|
||||
rstr := mockquic.NewMockStream(mockCtrl)
|
||||
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() {
|
||||
sess.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
|
||||
sess.EXPECT().ConnectionState().Return(quic.ConnectionState{})
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(str, nil)
|
||||
conn.EXPECT().ConnectionState().Return(quic.ConnectionState{})
|
||||
buf := &bytes.Buffer{}
|
||||
rstr := mockquic.NewMockStream(mockCtrl)
|
||||
rstr.EXPECT().Write(gomock.Any()).Do(buf.Write).AnyTimes()
|
||||
|
|
|
@ -50,7 +50,7 @@ type RoundTripper struct {
|
|||
// Dial specifies an optional dial function for creating QUIC
|
||||
// connections for requests.
|
||||
// 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
|
||||
// allowed in the server's response header.
|
||||
|
|
|
@ -61,7 +61,7 @@ var _ = Describe("RoundTripper", func() {
|
|||
var (
|
||||
rt *RoundTripper
|
||||
req1 *http.Request
|
||||
session *mockquic.MockEarlySession
|
||||
conn *mockquic.MockEarlyConnection
|
||||
handshakeCtx context.Context // an already canceled context
|
||||
)
|
||||
|
||||
|
@ -80,12 +80,12 @@ var _ = Describe("RoundTripper", func() {
|
|||
origDialAddr := dialAddr
|
||||
|
||||
BeforeEach(func() {
|
||||
session = mockquic.NewMockEarlySession(mockCtrl)
|
||||
conn = mockquic.NewMockEarlyConnection(mockCtrl)
|
||||
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
|
||||
// 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")
|
||||
req, err := http.NewRequest("GET", "https://quic.clemente.io/foobar.html", nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
session.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr)
|
||||
session.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
session.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr)
|
||||
session.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
conn.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr)
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx)
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr)
|
||||
conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
<-closed
|
||||
return nil, errors.New("test done")
|
||||
}).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)
|
||||
Expect(err).To(MatchError(testErr))
|
||||
Expect(rt.clients).To(HaveLen(1))
|
||||
|
@ -115,7 +115,7 @@ var _ = Describe("RoundTripper", func() {
|
|||
It("uses the quic.Config, if provided", func() {
|
||||
config := &quic.Config{HandshakeIdleTimeout: time.Millisecond}
|
||||
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
|
||||
return nil, errors.New("handshake error")
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ var _ = Describe("RoundTripper", func() {
|
|||
|
||||
It("uses the custom dialer, if provided", func() {
|
||||
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
|
||||
return nil, errors.New("handshake error")
|
||||
}
|
||||
|
@ -140,14 +140,14 @@ var _ = Describe("RoundTripper", func() {
|
|||
It("reuses existing clients", func() {
|
||||
closed := make(chan struct{})
|
||||
testErr := errors.New("test err")
|
||||
session.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr)
|
||||
session.EXPECT().HandshakeComplete().Return(handshakeCtx).Times(2)
|
||||
session.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr).Times(2)
|
||||
session.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
conn.EXPECT().OpenUniStream().AnyTimes().Return(nil, testErr)
|
||||
conn.EXPECT().HandshakeComplete().Return(handshakeCtx).Times(2)
|
||||
conn.EXPECT().OpenStreamSync(context.Background()).Return(nil, testErr).Times(2)
|
||||
conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
<-closed
|
||||
return nil, errors.New("test done")
|
||||
}).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)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
_, err = rt.RoundTrip(req)
|
||||
|
|
|
@ -334,7 +334,7 @@ func (s *Server) removeListener(l *quic.EarlyListener) {
|
|||
s.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (s *Server) handleConn(sess quic.EarlySession) {
|
||||
func (s *Server) handleConn(sess quic.EarlyConnection) {
|
||||
decoder := qpack.NewDecoder(nil)
|
||||
|
||||
// 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 {
|
||||
str, err := sess.AcceptUniStream(context.Background())
|
||||
if err != nil {
|
||||
|
|
|
@ -107,7 +107,7 @@ var _ = Describe("Server", func() {
|
|||
var (
|
||||
qpackDecoder *qpack.Decoder
|
||||
str *mockquic.MockStream
|
||||
sess *mockquic.MockEarlySession
|
||||
conn *mockquic.MockEarlyConnection
|
||||
exampleGetRequest *http.Request
|
||||
examplePostRequest *http.Request
|
||||
)
|
||||
|
@ -164,10 +164,10 @@ var _ = Describe("Server", func() {
|
|||
qpackDecoder = qpack.NewDecoder(nil)
|
||||
str = mockquic.NewMockStream(mockCtrl)
|
||||
|
||||
sess = mockquic.NewMockEarlySession(mockCtrl)
|
||||
conn = mockquic.NewMockEarlyConnection(mockCtrl)
|
||||
addr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}
|
||||
sess.EXPECT().RemoteAddr().Return(addr).AnyTimes()
|
||||
sess.EXPECT().LocalAddr().AnyTimes()
|
||||
conn.EXPECT().RemoteAddr().Return(addr).AnyTimes()
|
||||
conn.EXPECT().LocalAddr().AnyTimes()
|
||||
})
|
||||
|
||||
It("calls the HTTP handler function", func() {
|
||||
|
@ -183,7 +183,7 @@ var _ = Describe("Server", func() {
|
|||
}).AnyTimes()
|
||||
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
|
||||
Eventually(requestChan).Should(Receive(&req))
|
||||
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().CancelRead(gomock.Any())
|
||||
|
||||
serr := s.handleRequest(sess, str, qpackDecoder, nil)
|
||||
serr := s.handleRequest(conn, str, qpackDecoder, nil)
|
||||
Expect(serr.err).ToNot(HaveOccurred())
|
||||
hfs := decodeHeader(responseBuf)
|
||||
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().CancelRead(gomock.Any())
|
||||
|
||||
serr := s.handleRequest(sess, str, qpackDecoder, nil)
|
||||
serr := s.handleRequest(conn, str, qpackDecoder, nil)
|
||||
Expect(serr.err).ToNot(HaveOccurred())
|
||||
hfs := decodeHeader(responseBuf)
|
||||
Expect(hfs).To(HaveKeyWithValue(":status", []string{"500"}))
|
||||
|
@ -234,22 +234,22 @@ var _ = Describe("Server", func() {
|
|||
str.EXPECT().Write([]byte("foobar"))
|
||||
// don't EXPECT CancelRead()
|
||||
|
||||
serr := s.handleRequest(sess, str, qpackDecoder, nil)
|
||||
serr := s.handleRequest(conn, str, qpackDecoder, nil)
|
||||
Expect(serr.err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
Context("control stream handling", func() {
|
||||
var sess *mockquic.MockEarlySession
|
||||
var conn *mockquic.MockEarlyConnection
|
||||
testDone := make(chan struct{})
|
||||
|
||||
BeforeEach(func() {
|
||||
sess = mockquic.NewMockEarlySession(mockCtrl)
|
||||
conn = mockquic.NewMockEarlyConnection(mockCtrl)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
controlStr.EXPECT().Write(gomock.Any())
|
||||
sess.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
sess.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()
|
||||
sess.EXPECT().LocalAddr().AnyTimes()
|
||||
conn.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
conn.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done"))
|
||||
conn.EXPECT().RemoteAddr().Return(&net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}).AnyTimes()
|
||||
conn.EXPECT().LocalAddr().AnyTimes()
|
||||
})
|
||||
|
||||
AfterEach(func() { testDone <- struct{}{} })
|
||||
|
@ -260,15 +260,15 @@ var _ = Describe("Server", func() {
|
|||
(&settingsFrame{}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
s.handleConn(sess)
|
||||
time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to sess.CloseWithError
|
||||
s.handleConn(conn)
|
||||
time.Sleep(scaleDuration(20 * time.Millisecond)) // don't EXPECT any calls to conn.CloseWithError
|
||||
})
|
||||
|
||||
for _, t := range []uint64{streamTypeQPACKEncoderStream, streamTypeQPACKDecoderStream} {
|
||||
|
@ -284,14 +284,14 @@ var _ = Describe("Server", func() {
|
|||
str := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
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
|
||||
})
|
||||
}
|
||||
|
@ -306,14 +306,14 @@ var _ = Describe("Server", func() {
|
|||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -323,20 +323,20 @@ var _ = Describe("Server", func() {
|
|||
(&dataFrame{}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorMissingSettings))
|
||||
close(done)
|
||||
})
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -348,20 +348,20 @@ var _ = Describe("Server", func() {
|
|||
buf.Write(b.Bytes()[:b.Len()-1])
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorFrameError))
|
||||
close(done)
|
||||
})
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -371,20 +371,20 @@ var _ = Describe("Server", func() {
|
|||
(&dataFrame{}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorStreamCreationError))
|
||||
close(done)
|
||||
})
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -395,45 +395,45 @@ var _ = Describe("Server", func() {
|
|||
(&settingsFrame{Datagram: true}).Write(buf)
|
||||
controlStr := mockquic.NewMockStream(mockCtrl)
|
||||
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
|
||||
})
|
||||
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
|
||||
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{})
|
||||
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()
|
||||
Expect(code).To(BeEquivalentTo(errorSettingsError))
|
||||
Expect(reason).To(Equal("missing QUIC Datagram support"))
|
||||
close(done)
|
||||
})
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
})
|
||||
|
||||
Context("stream- and connection-level errors", func() {
|
||||
var sess *mockquic.MockEarlySession
|
||||
var conn *mockquic.MockEarlyConnection
|
||||
testDone := make(chan struct{})
|
||||
|
||||
BeforeEach(func() {
|
||||
testDone = make(chan struct{})
|
||||
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.EXPECT().Write(gomock.Any())
|
||||
sess.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
sess.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
conn.EXPECT().OpenUniStream().Return(controlStr, nil)
|
||||
conn.EXPECT().AcceptUniStream(gomock.Any()).DoAndReturn(func(context.Context) (quic.ReceiveStream, error) {
|
||||
<-testDone
|
||||
return nil, errors.New("test done")
|
||||
})
|
||||
sess.EXPECT().AcceptStream(gomock.Any()).Return(str, nil)
|
||||
sess.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done"))
|
||||
sess.EXPECT().RemoteAddr().Return(addr).AnyTimes()
|
||||
sess.EXPECT().LocalAddr().AnyTimes()
|
||||
conn.EXPECT().AcceptStream(gomock.Any()).Return(str, nil)
|
||||
conn.EXPECT().AcceptStream(gomock.Any()).Return(nil, errors.New("done"))
|
||||
conn.EXPECT().RemoteAddr().Return(addr).AnyTimes()
|
||||
conn.EXPECT().LocalAddr().AnyTimes()
|
||||
})
|
||||
|
||||
AfterEach(func() { testDone <- struct{}{} })
|
||||
|
@ -456,7 +456,7 @@ var _ = Describe("Server", func() {
|
|||
str.EXPECT().CancelRead(quic.StreamErrorCode(errorNoError))
|
||||
str.EXPECT().Close().Do(func() { close(done) })
|
||||
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
hfs := decodeHeader(responseBuf)
|
||||
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().CancelWrite(quic.StreamErrorCode(errorFrameError)).Do(func(quic.StreamErrorCode) { close(done) })
|
||||
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -493,7 +493,7 @@ var _ = Describe("Server", func() {
|
|||
str.EXPECT().Read(gomock.Any()).Return(0, testErr)
|
||||
str.EXPECT().CancelWrite(quic.StreamErrorCode(errorRequestIncomplete)).Do(func(quic.StreamErrorCode) { close(done) })
|
||||
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Consistently(handlerCalled).ShouldNot(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -511,11 +511,11 @@ var _ = Describe("Server", func() {
|
|||
}).AnyTimes()
|
||||
|
||||
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)))
|
||||
close(done)
|
||||
})
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
|
@ -538,7 +538,7 @@ var _ = Describe("Server", func() {
|
|||
done := make(chan struct{})
|
||||
str.EXPECT().CancelWrite(quic.StreamErrorCode(errorFrameError)).Do(func(quic.StreamErrorCode) { close(done) })
|
||||
|
||||
s.handleConn(sess)
|
||||
s.handleConn(conn)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
})
|
||||
|
@ -560,7 +560,7 @@ var _ = Describe("Server", func() {
|
|||
}).AnyTimes()
|
||||
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())
|
||||
Eventually(handlerCalled).Should(BeClosed())
|
||||
})
|
||||
|
@ -583,7 +583,7 @@ var _ = Describe("Server", func() {
|
|||
}).AnyTimes()
|
||||
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())
|
||||
Eventually(handlerCalled).Should(BeClosed())
|
||||
})
|
||||
|
|
|
@ -45,7 +45,7 @@ type fakeClosingListener struct {
|
|||
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()))
|
||||
return ln.listenerWrapper.Accept(ln.ctx)
|
||||
}
|
||||
|
|
|
@ -695,7 +695,7 @@ var _ = Describe("0-RTT", func() {
|
|||
_, err = conn.AcceptStream(ctx)
|
||||
Expect(err).To(Equal(quic.Err0RTTRejected))
|
||||
|
||||
newConn := conn.NextSession()
|
||||
newConn := conn.NextConnection()
|
||||
str, err := newConn.OpenUniStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
_, err = newConn.OpenUniStream()
|
||||
|
|
|
@ -199,11 +199,11 @@ type Connection interface {
|
|||
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.
|
||||
// When using client certificates, the client's identity is only verified
|
||||
// after completion of the handshake.
|
||||
type EarlySession interface {
|
||||
type EarlyConnection interface {
|
||||
Connection
|
||||
|
||||
// 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.
|
||||
HandshakeComplete() context.Context
|
||||
|
||||
NextSession() Connection
|
||||
NextConnection() Connection
|
||||
}
|
||||
|
||||
// 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() net.Addr
|
||||
// Accept returns new early connections. It should be called in a loop.
|
||||
Accept(context.Context) (EarlySession, error)
|
||||
Accept(context.Context) (EarlyConnection, error)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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/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 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"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// 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
|
||||
|
@ -14,31 +14,31 @@ import (
|
|||
qerr "github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
)
|
||||
|
||||
// MockEarlySession is a mock of EarlySession interface.
|
||||
type MockEarlySession struct {
|
||||
// MockEarlyConnection is a mock of EarlyConnection interface.
|
||||
type MockEarlyConnection struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockEarlySessionMockRecorder
|
||||
recorder *MockEarlyConnectionMockRecorder
|
||||
}
|
||||
|
||||
// MockEarlySessionMockRecorder is the mock recorder for MockEarlySession.
|
||||
type MockEarlySessionMockRecorder struct {
|
||||
mock *MockEarlySession
|
||||
// MockEarlyConnectionMockRecorder is the mock recorder for MockEarlyConnection.
|
||||
type MockEarlyConnectionMockRecorder struct {
|
||||
mock *MockEarlyConnection
|
||||
}
|
||||
|
||||
// NewMockEarlySession creates a new mock instance.
|
||||
func NewMockEarlySession(ctrl *gomock.Controller) *MockEarlySession {
|
||||
mock := &MockEarlySession{ctrl: ctrl}
|
||||
mock.recorder = &MockEarlySessionMockRecorder{mock}
|
||||
// NewMockEarlyConnection creates a new mock instance.
|
||||
func NewMockEarlyConnection(ctrl *gomock.Controller) *MockEarlyConnection {
|
||||
mock := &MockEarlyConnection{ctrl: ctrl}
|
||||
mock.recorder = &MockEarlyConnectionMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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()
|
||||
ret := m.ctrl.Call(m, "AcceptStream", arg0)
|
||||
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.
|
||||
func (mr *MockEarlySessionMockRecorder) AcceptStream(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) AcceptStream(arg0 interface{}) *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) AcceptUniStream(arg0 context.Context) (quic.ReceiveStream, error) {
|
||||
func (m *MockEarlyConnection) AcceptUniStream(arg0 context.Context) (quic.ReceiveStream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AcceptUniStream", arg0)
|
||||
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.
|
||||
func (mr *MockEarlySessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 string) error {
|
||||
func (m *MockEarlyConnection) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
@ -76,13 +76,13 @@ func (m *MockEarlySession) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 s
|
|||
}
|
||||
|
||||
// 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()
|
||||
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.
|
||||
func (m *MockEarlySession) ConnectionState() quic.ConnectionState {
|
||||
func (m *MockEarlyConnection) ConnectionState() quic.ConnectionState {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ConnectionState")
|
||||
ret0, _ := ret[0].(quic.ConnectionState)
|
||||
|
@ -90,13 +90,13 @@ func (m *MockEarlySession) ConnectionState() quic.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()
|
||||
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.
|
||||
func (m *MockEarlySession) Context() context.Context {
|
||||
func (m *MockEarlyConnection) Context() context.Context {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Context")
|
||||
ret0, _ := ret[0].(context.Context)
|
||||
|
@ -104,13 +104,13 @@ func (m *MockEarlySession) Context() context.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()
|
||||
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.
|
||||
func (m *MockEarlySession) HandshakeComplete() context.Context {
|
||||
func (m *MockEarlyConnection) HandshakeComplete() context.Context {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HandshakeComplete")
|
||||
ret0, _ := ret[0].(context.Context)
|
||||
|
@ -118,13 +118,13 @@ func (m *MockEarlySession) HandshakeComplete() context.Context {
|
|||
}
|
||||
|
||||
// HandshakeComplete indicates an expected call of HandshakeComplete.
|
||||
func (mr *MockEarlySessionMockRecorder) HandshakeComplete() *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) HandshakeComplete() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) LocalAddr() net.Addr {
|
||||
func (m *MockEarlyConnection) LocalAddr() net.Addr {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "LocalAddr")
|
||||
ret0, _ := ret[0].(net.Addr)
|
||||
|
@ -132,27 +132,27 @@ func (m *MockEarlySession) LocalAddr() net.Addr {
|
|||
}
|
||||
|
||||
// LocalAddr indicates an expected call of LocalAddr.
|
||||
func (mr *MockEarlySessionMockRecorder) LocalAddr() *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) LocalAddr() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) NextSession() quic.Connection {
|
||||
// NextConnection mocks base method.
|
||||
func (m *MockEarlyConnection) NextConnection() quic.Connection {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NextSession")
|
||||
ret := m.ctrl.Call(m, "NextConnection")
|
||||
ret0, _ := ret[0].(quic.Connection)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// NextSession indicates an expected call of NextSession.
|
||||
func (mr *MockEarlySessionMockRecorder) NextSession() *gomock.Call {
|
||||
// NextConnection indicates an expected call of NextConnection.
|
||||
func (mr *MockEarlyConnectionMockRecorder) NextConnection() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) OpenStream() (quic.Stream, error) {
|
||||
func (m *MockEarlyConnection) OpenStream() (quic.Stream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenStream")
|
||||
ret0, _ := ret[0].(quic.Stream)
|
||||
|
@ -161,13 +161,13 @@ func (m *MockEarlySession) OpenStream() (quic.Stream, error) {
|
|||
}
|
||||
|
||||
// OpenStream indicates an expected call of OpenStream.
|
||||
func (mr *MockEarlySessionMockRecorder) OpenStream() *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) OpenStream() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) OpenStreamSync(arg0 context.Context) (quic.Stream, error) {
|
||||
func (m *MockEarlyConnection) OpenStreamSync(arg0 context.Context) (quic.Stream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenStreamSync", arg0)
|
||||
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.
|
||||
func (mr *MockEarlySessionMockRecorder) OpenStreamSync(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) OpenStreamSync(arg0 interface{}) *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) OpenUniStream() (quic.SendStream, error) {
|
||||
func (m *MockEarlyConnection) OpenUniStream() (quic.SendStream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenUniStream")
|
||||
ret0, _ := ret[0].(quic.SendStream)
|
||||
|
@ -191,13 +191,13 @@ func (m *MockEarlySession) OpenUniStream() (quic.SendStream, error) {
|
|||
}
|
||||
|
||||
// OpenUniStream indicates an expected call of OpenUniStream.
|
||||
func (mr *MockEarlySessionMockRecorder) OpenUniStream() *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) OpenUniStream() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) OpenUniStreamSync(arg0 context.Context) (quic.SendStream, error) {
|
||||
func (m *MockEarlyConnection) OpenUniStreamSync(arg0 context.Context) (quic.SendStream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenUniStreamSync", arg0)
|
||||
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.
|
||||
func (mr *MockEarlySessionMockRecorder) OpenUniStreamSync(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) OpenUniStreamSync(arg0 interface{}) *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) ReceiveMessage() ([]byte, error) {
|
||||
func (m *MockEarlyConnection) ReceiveMessage() ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReceiveMessage")
|
||||
ret0, _ := ret[0].([]byte)
|
||||
|
@ -221,13 +221,13 @@ func (m *MockEarlySession) ReceiveMessage() ([]byte, error) {
|
|||
}
|
||||
|
||||
// ReceiveMessage indicates an expected call of ReceiveMessage.
|
||||
func (mr *MockEarlySessionMockRecorder) ReceiveMessage() *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) ReceiveMessage() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) RemoteAddr() net.Addr {
|
||||
func (m *MockEarlyConnection) RemoteAddr() net.Addr {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RemoteAddr")
|
||||
ret0, _ := ret[0].(net.Addr)
|
||||
|
@ -235,13 +235,13 @@ func (m *MockEarlySession) RemoteAddr() net.Addr {
|
|||
}
|
||||
|
||||
// RemoteAddr indicates an expected call of RemoteAddr.
|
||||
func (mr *MockEarlySessionMockRecorder) RemoteAddr() *gomock.Call {
|
||||
func (mr *MockEarlyConnectionMockRecorder) RemoteAddr() *gomock.Call {
|
||||
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.
|
||||
func (m *MockEarlySession) SendMessage(arg0 []byte) error {
|
||||
func (m *MockEarlyConnection) SendMessage(arg0 []byte) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendMessage", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
@ -249,7 +249,7 @@ func (m *MockEarlySession) SendMessage(arg0 []byte) error {
|
|||
}
|
||||
|
||||
// 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()
|
||||
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)
|
||||
}
|
|
@ -37,10 +37,10 @@ func (m *MockEarlyListener) EXPECT() *MockEarlyListenerMockRecorder {
|
|||
}
|
||||
|
||||
// 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()
|
||||
ret := m.ctrl.Call(m, "Accept", arg0)
|
||||
ret0, _ := ret[0].(quic.EarlySession)
|
||||
ret0, _ := ret[0].(quic.EarlyConnection)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ type client struct {
|
|||
quicConf *quic.Config
|
||||
|
||||
once sync.Once
|
||||
conn quic.EarlySession
|
||||
conn quic.EarlyConnection
|
||||
dialErr error
|
||||
}
|
||||
|
||||
|
|
|
@ -150,18 +150,18 @@ func (mr *MockQuicSessionMockRecorder) LocalAddr() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockQuicSession)(nil).LocalAddr))
|
||||
}
|
||||
|
||||
// NextSession mocks base method.
|
||||
func (m *MockQuicSession) NextSession() Connection {
|
||||
// NextConnection mocks base method.
|
||||
func (m *MockQuicSession) NextConnection() Connection {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NextSession")
|
||||
ret := m.ctrl.Call(m, "NextConnection")
|
||||
ret0, _ := ret[0].(Connection)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// NextSession indicates an expected call of NextSession.
|
||||
func (mr *MockQuicSessionMockRecorder) NextSession() *gomock.Call {
|
||||
// NextConnection indicates an expected call of NextConnection.
|
||||
func (mr *MockQuicSessionMockRecorder) NextConnection() *gomock.Call {
|
||||
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.
|
||||
|
|
|
@ -42,7 +42,7 @@ type packetHandlerManager interface {
|
|||
}
|
||||
|
||||
type quicSession interface {
|
||||
EarlySession
|
||||
EarlyConnection
|
||||
earlySessionReady() <-chan struct{}
|
||||
handlePacket(*receivedPacket)
|
||||
GetVersion() protocol.VersionNumber
|
||||
|
@ -112,7 +112,7 @@ type earlyServer struct{ *baseServer }
|
|||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
10
session.go
10
session.go
|
@ -222,10 +222,10 @@ type session struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ Connection = &session{}
|
||||
_ EarlySession = &session{}
|
||||
_ streamSender = &session{}
|
||||
deadlineSendImmediately = time.Time{}.Add(42 * time.Millisecond) // any value > time.Time{} and before time.Now() is fine
|
||||
_ Connection = &session{}
|
||||
_ EarlyConnection = &session{}
|
||||
_ streamSender = &session{}
|
||||
deadlineSendImmediately = time.Time{}.Add(42 * time.Millisecond) // any value > time.Time{} and before time.Now() is fine
|
||||
)
|
||||
|
||||
var newSession = func(
|
||||
|
@ -1996,7 +1996,7 @@ func (s *session) GetVersion() protocol.VersionNumber {
|
|||
return s.version
|
||||
}
|
||||
|
||||
func (s *session) NextSession() Connection {
|
||||
func (s *session) NextConnection() Connection {
|
||||
<-s.HandshakeComplete().Done()
|
||||
s.streamsMap.UseResetMaps()
|
||||
return s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue