mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
rename the quicSession to quicConnection
This commit is contained in:
parent
6aaa9a817c
commit
e7c2e7e147
7 changed files with 219 additions and 220 deletions
|
@ -35,7 +35,7 @@ type client struct {
|
|||
|
||||
handshakeChan chan struct{}
|
||||
|
||||
session quicSession
|
||||
session quicConn
|
||||
|
||||
tracer logging.ConnectionTracer
|
||||
tracingID uint64
|
||||
|
@ -105,7 +105,7 @@ func dialAddrContext(
|
|||
tlsConf *tls.Config,
|
||||
config *Config,
|
||||
use0RTT bool,
|
||||
) (quicSession, error) {
|
||||
) (quicConn, error) {
|
||||
udpAddr, err := net.ResolveUDPAddr("udp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -185,7 +185,7 @@ func dialContext(
|
|||
config *Config,
|
||||
use0RTT bool,
|
||||
createdPacketConn bool,
|
||||
) (quicSession, error) {
|
||||
) (quicConn, error) {
|
||||
if tlsConf == nil {
|
||||
return nil, errors.New("quic: tls.Config not set")
|
||||
}
|
||||
|
|
119
client_test.go
119
client_test.go
|
@ -45,7 +45,7 @@ var _ = Describe("Client", func() {
|
|||
tracingID uint64,
|
||||
logger utils.Logger,
|
||||
v protocol.VersionNumber,
|
||||
) quicSession
|
||||
) quicConn
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
|
@ -57,7 +57,6 @@ var _ = Describe("Client", func() {
|
|||
tr.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveClient, gomock.Any()).Return(tracer).MaxTimes(1)
|
||||
config = &Config{Tracer: tr, Versions: []protocol.VersionNumber{protocol.VersionTLS}}
|
||||
Eventually(areSessionsRunning).Should(BeFalse())
|
||||
// sess = NewMockQuicSession(mockCtrl)
|
||||
addr = &net.UDPAddr{IP: net.IPv4(192, 168, 100, 200), Port: 1337}
|
||||
packetConn = NewMockPacketConn(mockCtrl)
|
||||
packetConn.EXPECT().LocalAddr().Return(&net.UDPAddr{}).AnyTimes()
|
||||
|
@ -120,7 +119,7 @@ var _ = Describe("Client", func() {
|
|||
|
||||
remoteAddrChan := make(chan string, 1)
|
||||
newClientSession = func(
|
||||
conn sendConn,
|
||||
sconn sendConn,
|
||||
_ sessionRunner,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
|
@ -133,12 +132,12 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
remoteAddrChan <- conn.RemoteAddr().String()
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return sess
|
||||
) quicConn {
|
||||
remoteAddrChan <- sconn.RemoteAddr().String()
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
_, err := DialAddr("localhost:17890", tlsConf, &Config{HandshakeIdleTimeout: time.Millisecond})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -166,12 +165,12 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
hostnameChan <- tlsConf.ServerName
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return sess
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
tlsConf.ServerName = "foobar"
|
||||
_, err := DialAddr("localhost:17890", tlsConf, nil)
|
||||
|
@ -199,12 +198,12 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
hostnameChan <- tlsConf.ServerName
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
sess.EXPECT().run()
|
||||
return sess
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
conn.EXPECT().run()
|
||||
return conn
|
||||
}
|
||||
tracer.EXPECT().StartedConnection(packetConn.LocalAddr(), addr, gomock.Any(), gomock.Any())
|
||||
_, err := Dial(
|
||||
|
@ -238,14 +237,14 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
Expect(enable0RTT).To(BeFalse())
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run().Do(func() { close(run) })
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run().Do(func() { close(run) })
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
sess.EXPECT().HandshakeComplete().Return(ctx)
|
||||
return sess
|
||||
conn.EXPECT().HandshakeComplete().Return(ctx)
|
||||
return conn
|
||||
}
|
||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
s, err := Dial(
|
||||
|
@ -281,13 +280,13 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
Expect(enable0RTT).To(BeTrue())
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run().Do(func() { <-done })
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
sess.EXPECT().earlySessionReady().Return(readyChan)
|
||||
return sess
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run().Do(func() { <-done })
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
conn.EXPECT().earlySessionReady().Return(readyChan)
|
||||
return conn
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
@ -329,11 +328,11 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run().Return(testErr)
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return sess
|
||||
) quicConn {
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run().Return(testErr)
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
_, err := Dial(
|
||||
|
@ -353,11 +352,11 @@ var _ = Describe("Client", func() {
|
|||
|
||||
sessionRunning := make(chan struct{})
|
||||
defer close(sessionRunning)
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run().Do(func() {
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run().Do(func() {
|
||||
<-sessionRunning
|
||||
})
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
newClientSession = func(
|
||||
_ sendConn,
|
||||
_ sessionRunner,
|
||||
|
@ -372,8 +371,8 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
return sess
|
||||
) quicConn {
|
||||
return conn
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
dialed := make(chan struct{})
|
||||
|
@ -392,7 +391,7 @@ var _ = Describe("Client", func() {
|
|||
close(dialed)
|
||||
}()
|
||||
Consistently(dialed).ShouldNot(BeClosed())
|
||||
sess.EXPECT().shutdown()
|
||||
conn.EXPECT().shutdown()
|
||||
cancel()
|
||||
Eventually(dialed).Should(BeClosed())
|
||||
})
|
||||
|
@ -406,10 +405,10 @@ var _ = Describe("Client", func() {
|
|||
mockMultiplexer.EXPECT().AddConn(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(manager, nil)
|
||||
manager.EXPECT().Add(gomock.Any(), gomock.Any())
|
||||
|
||||
var conn sendConn
|
||||
var sconn sendConn
|
||||
run := make(chan struct{})
|
||||
sessionCreated := make(chan struct{})
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
newClientSession = func(
|
||||
connP sendConn,
|
||||
_ sessionRunner,
|
||||
|
@ -424,15 +423,15 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
conn = connP
|
||||
) quicConn {
|
||||
sconn = connP
|
||||
close(sessionCreated)
|
||||
return sess
|
||||
return conn
|
||||
}
|
||||
sess.EXPECT().run().Do(func() {
|
||||
conn.EXPECT().run().Do(func() {
|
||||
<-run
|
||||
})
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
|
@ -445,7 +444,7 @@ var _ = Describe("Client", func() {
|
|||
Eventually(sessionCreated).Should(BeClosed())
|
||||
|
||||
// check that the connection is not closed
|
||||
Expect(conn.Write([]byte("foobar"))).To(Succeed())
|
||||
Expect(sconn.Write([]byte("foobar"))).To(Succeed())
|
||||
|
||||
manager.EXPECT().Destroy()
|
||||
close(run)
|
||||
|
@ -544,16 +543,16 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
versionP protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
cconn = connP
|
||||
version = versionP
|
||||
conf = configP
|
||||
close(c)
|
||||
// TODO: check connection IDs?
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return sess
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
_, err := Dial(packetConn, addr, "localhost:1337", tlsConf, config)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -584,23 +583,23 @@ var _ = Describe("Client", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
versionP protocol.VersionNumber,
|
||||
) quicSession {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
) quicConn {
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
if counter == 0 {
|
||||
Expect(pn).To(BeZero())
|
||||
Expect(hasNegotiatedVersion).To(BeFalse())
|
||||
sess.EXPECT().run().Return(&errCloseForRecreating{
|
||||
conn.EXPECT().run().Return(&errCloseForRecreating{
|
||||
nextPacketNumber: 109,
|
||||
nextVersion: 789,
|
||||
})
|
||||
} else {
|
||||
Expect(pn).To(Equal(protocol.PacketNumber(109)))
|
||||
Expect(hasNegotiatedVersion).To(BeTrue())
|
||||
sess.EXPECT().run()
|
||||
conn.EXPECT().run()
|
||||
}
|
||||
counter++
|
||||
return sess
|
||||
return conn
|
||||
}
|
||||
|
||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
|
|
|
@ -13,31 +13,31 @@ import (
|
|||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
)
|
||||
|
||||
// MockQuicSession is a mock of QuicSession interface.
|
||||
type MockQuicSession struct {
|
||||
// MockQuicConn is a mock of QuicConn interface.
|
||||
type MockQuicConn struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockQuicSessionMockRecorder
|
||||
recorder *MockQuicConnMockRecorder
|
||||
}
|
||||
|
||||
// MockQuicSessionMockRecorder is the mock recorder for MockQuicSession.
|
||||
type MockQuicSessionMockRecorder struct {
|
||||
mock *MockQuicSession
|
||||
// MockQuicConnMockRecorder is the mock recorder for MockQuicConn.
|
||||
type MockQuicConnMockRecorder struct {
|
||||
mock *MockQuicConn
|
||||
}
|
||||
|
||||
// NewMockQuicSession creates a new mock instance.
|
||||
func NewMockQuicSession(ctrl *gomock.Controller) *MockQuicSession {
|
||||
mock := &MockQuicSession{ctrl: ctrl}
|
||||
mock.recorder = &MockQuicSessionMockRecorder{mock}
|
||||
// NewMockQuicConn creates a new mock instance.
|
||||
func NewMockQuicConn(ctrl *gomock.Controller) *MockQuicConn {
|
||||
mock := &MockQuicConn{ctrl: ctrl}
|
||||
mock.recorder = &MockQuicConnMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockQuicSession) EXPECT() *MockQuicSessionMockRecorder {
|
||||
func (m *MockQuicConn) EXPECT() *MockQuicConnMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AcceptStream mocks base method.
|
||||
func (m *MockQuicSession) AcceptStream(arg0 context.Context) (Stream, error) {
|
||||
func (m *MockQuicConn) AcceptStream(arg0 context.Context) (Stream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AcceptStream", arg0)
|
||||
ret0, _ := ret[0].(Stream)
|
||||
|
@ -46,13 +46,13 @@ func (m *MockQuicSession) AcceptStream(arg0 context.Context) (Stream, error) {
|
|||
}
|
||||
|
||||
// AcceptStream indicates an expected call of AcceptStream.
|
||||
func (mr *MockQuicSessionMockRecorder) AcceptStream(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) AcceptStream(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptStream", reflect.TypeOf((*MockQuicSession)(nil).AcceptStream), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptStream", reflect.TypeOf((*MockQuicConn)(nil).AcceptStream), arg0)
|
||||
}
|
||||
|
||||
// AcceptUniStream mocks base method.
|
||||
func (m *MockQuicSession) AcceptUniStream(arg0 context.Context) (ReceiveStream, error) {
|
||||
func (m *MockQuicConn) AcceptUniStream(arg0 context.Context) (ReceiveStream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AcceptUniStream", arg0)
|
||||
ret0, _ := ret[0].(ReceiveStream)
|
||||
|
@ -61,13 +61,13 @@ func (m *MockQuicSession) AcceptUniStream(arg0 context.Context) (ReceiveStream,
|
|||
}
|
||||
|
||||
// AcceptUniStream indicates an expected call of AcceptUniStream.
|
||||
func (mr *MockQuicSessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockQuicSession)(nil).AcceptUniStream), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockQuicConn)(nil).AcceptUniStream), arg0)
|
||||
}
|
||||
|
||||
// CloseWithError mocks base method.
|
||||
func (m *MockQuicSession) CloseWithError(arg0 ApplicationErrorCode, arg1 string) error {
|
||||
func (m *MockQuicConn) CloseWithError(arg0 ApplicationErrorCode, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
@ -75,13 +75,13 @@ func (m *MockQuicSession) CloseWithError(arg0 ApplicationErrorCode, arg1 string)
|
|||
}
|
||||
|
||||
// CloseWithError indicates an expected call of CloseWithError.
|
||||
func (mr *MockQuicSessionMockRecorder) CloseWithError(arg0, arg1 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) CloseWithError(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseWithError", reflect.TypeOf((*MockQuicSession)(nil).CloseWithError), arg0, arg1)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseWithError", reflect.TypeOf((*MockQuicConn)(nil).CloseWithError), arg0, arg1)
|
||||
}
|
||||
|
||||
// ConnectionState mocks base method.
|
||||
func (m *MockQuicSession) ConnectionState() ConnectionState {
|
||||
func (m *MockQuicConn) ConnectionState() ConnectionState {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ConnectionState")
|
||||
ret0, _ := ret[0].(ConnectionState)
|
||||
|
@ -89,13 +89,13 @@ func (m *MockQuicSession) ConnectionState() ConnectionState {
|
|||
}
|
||||
|
||||
// ConnectionState indicates an expected call of ConnectionState.
|
||||
func (mr *MockQuicSessionMockRecorder) ConnectionState() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) ConnectionState() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectionState", reflect.TypeOf((*MockQuicSession)(nil).ConnectionState))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectionState", reflect.TypeOf((*MockQuicConn)(nil).ConnectionState))
|
||||
}
|
||||
|
||||
// Context mocks base method.
|
||||
func (m *MockQuicSession) Context() context.Context {
|
||||
func (m *MockQuicConn) Context() context.Context {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Context")
|
||||
ret0, _ := ret[0].(context.Context)
|
||||
|
@ -103,13 +103,13 @@ func (m *MockQuicSession) Context() context.Context {
|
|||
}
|
||||
|
||||
// Context indicates an expected call of Context.
|
||||
func (mr *MockQuicSessionMockRecorder) Context() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) Context() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockQuicSession)(nil).Context))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockQuicConn)(nil).Context))
|
||||
}
|
||||
|
||||
// GetVersion mocks base method.
|
||||
func (m *MockQuicSession) GetVersion() protocol.VersionNumber {
|
||||
func (m *MockQuicConn) GetVersion() protocol.VersionNumber {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetVersion")
|
||||
ret0, _ := ret[0].(protocol.VersionNumber)
|
||||
|
@ -117,13 +117,13 @@ func (m *MockQuicSession) GetVersion() protocol.VersionNumber {
|
|||
}
|
||||
|
||||
// GetVersion indicates an expected call of GetVersion.
|
||||
func (mr *MockQuicSessionMockRecorder) GetVersion() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) GetVersion() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockQuicSession)(nil).GetVersion))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockQuicConn)(nil).GetVersion))
|
||||
}
|
||||
|
||||
// HandshakeComplete mocks base method.
|
||||
func (m *MockQuicSession) HandshakeComplete() context.Context {
|
||||
func (m *MockQuicConn) HandshakeComplete() context.Context {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HandshakeComplete")
|
||||
ret0, _ := ret[0].(context.Context)
|
||||
|
@ -131,13 +131,13 @@ func (m *MockQuicSession) HandshakeComplete() context.Context {
|
|||
}
|
||||
|
||||
// HandshakeComplete indicates an expected call of HandshakeComplete.
|
||||
func (mr *MockQuicSessionMockRecorder) HandshakeComplete() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) HandshakeComplete() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandshakeComplete", reflect.TypeOf((*MockQuicSession)(nil).HandshakeComplete))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandshakeComplete", reflect.TypeOf((*MockQuicConn)(nil).HandshakeComplete))
|
||||
}
|
||||
|
||||
// LocalAddr mocks base method.
|
||||
func (m *MockQuicSession) LocalAddr() net.Addr {
|
||||
func (m *MockQuicConn) LocalAddr() net.Addr {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "LocalAddr")
|
||||
ret0, _ := ret[0].(net.Addr)
|
||||
|
@ -145,13 +145,13 @@ func (m *MockQuicSession) LocalAddr() net.Addr {
|
|||
}
|
||||
|
||||
// LocalAddr indicates an expected call of LocalAddr.
|
||||
func (mr *MockQuicSessionMockRecorder) LocalAddr() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) LocalAddr() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockQuicSession)(nil).LocalAddr))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockQuicConn)(nil).LocalAddr))
|
||||
}
|
||||
|
||||
// NextConnection mocks base method.
|
||||
func (m *MockQuicSession) NextConnection() Connection {
|
||||
func (m *MockQuicConn) NextConnection() Connection {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NextConnection")
|
||||
ret0, _ := ret[0].(Connection)
|
||||
|
@ -159,13 +159,13 @@ func (m *MockQuicSession) NextConnection() Connection {
|
|||
}
|
||||
|
||||
// NextConnection indicates an expected call of NextConnection.
|
||||
func (mr *MockQuicSessionMockRecorder) NextConnection() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) NextConnection() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextConnection", reflect.TypeOf((*MockQuicSession)(nil).NextConnection))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextConnection", reflect.TypeOf((*MockQuicConn)(nil).NextConnection))
|
||||
}
|
||||
|
||||
// OpenStream mocks base method.
|
||||
func (m *MockQuicSession) OpenStream() (Stream, error) {
|
||||
func (m *MockQuicConn) OpenStream() (Stream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenStream")
|
||||
ret0, _ := ret[0].(Stream)
|
||||
|
@ -174,13 +174,13 @@ func (m *MockQuicSession) OpenStream() (Stream, error) {
|
|||
}
|
||||
|
||||
// OpenStream indicates an expected call of OpenStream.
|
||||
func (mr *MockQuicSessionMockRecorder) OpenStream() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) OpenStream() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStream", reflect.TypeOf((*MockQuicSession)(nil).OpenStream))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStream", reflect.TypeOf((*MockQuicConn)(nil).OpenStream))
|
||||
}
|
||||
|
||||
// OpenStreamSync mocks base method.
|
||||
func (m *MockQuicSession) OpenStreamSync(arg0 context.Context) (Stream, error) {
|
||||
func (m *MockQuicConn) OpenStreamSync(arg0 context.Context) (Stream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenStreamSync", arg0)
|
||||
ret0, _ := ret[0].(Stream)
|
||||
|
@ -189,13 +189,13 @@ func (m *MockQuicSession) OpenStreamSync(arg0 context.Context) (Stream, error) {
|
|||
}
|
||||
|
||||
// OpenStreamSync indicates an expected call of OpenStreamSync.
|
||||
func (mr *MockQuicSessionMockRecorder) OpenStreamSync(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) OpenStreamSync(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStreamSync", reflect.TypeOf((*MockQuicSession)(nil).OpenStreamSync), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenStreamSync", reflect.TypeOf((*MockQuicConn)(nil).OpenStreamSync), arg0)
|
||||
}
|
||||
|
||||
// OpenUniStream mocks base method.
|
||||
func (m *MockQuicSession) OpenUniStream() (SendStream, error) {
|
||||
func (m *MockQuicConn) OpenUniStream() (SendStream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenUniStream")
|
||||
ret0, _ := ret[0].(SendStream)
|
||||
|
@ -204,13 +204,13 @@ func (m *MockQuicSession) OpenUniStream() (SendStream, error) {
|
|||
}
|
||||
|
||||
// OpenUniStream indicates an expected call of OpenUniStream.
|
||||
func (mr *MockQuicSessionMockRecorder) OpenUniStream() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) OpenUniStream() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStream", reflect.TypeOf((*MockQuicSession)(nil).OpenUniStream))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStream", reflect.TypeOf((*MockQuicConn)(nil).OpenUniStream))
|
||||
}
|
||||
|
||||
// OpenUniStreamSync mocks base method.
|
||||
func (m *MockQuicSession) OpenUniStreamSync(arg0 context.Context) (SendStream, error) {
|
||||
func (m *MockQuicConn) OpenUniStreamSync(arg0 context.Context) (SendStream, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenUniStreamSync", arg0)
|
||||
ret0, _ := ret[0].(SendStream)
|
||||
|
@ -219,13 +219,13 @@ func (m *MockQuicSession) OpenUniStreamSync(arg0 context.Context) (SendStream, e
|
|||
}
|
||||
|
||||
// OpenUniStreamSync indicates an expected call of OpenUniStreamSync.
|
||||
func (mr *MockQuicSessionMockRecorder) OpenUniStreamSync(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) OpenUniStreamSync(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStreamSync", reflect.TypeOf((*MockQuicSession)(nil).OpenUniStreamSync), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenUniStreamSync", reflect.TypeOf((*MockQuicConn)(nil).OpenUniStreamSync), arg0)
|
||||
}
|
||||
|
||||
// ReceiveMessage mocks base method.
|
||||
func (m *MockQuicSession) ReceiveMessage() ([]byte, error) {
|
||||
func (m *MockQuicConn) ReceiveMessage() ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReceiveMessage")
|
||||
ret0, _ := ret[0].([]byte)
|
||||
|
@ -234,13 +234,13 @@ func (m *MockQuicSession) ReceiveMessage() ([]byte, error) {
|
|||
}
|
||||
|
||||
// ReceiveMessage indicates an expected call of ReceiveMessage.
|
||||
func (mr *MockQuicSessionMockRecorder) ReceiveMessage() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) ReceiveMessage() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveMessage", reflect.TypeOf((*MockQuicSession)(nil).ReceiveMessage))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveMessage", reflect.TypeOf((*MockQuicConn)(nil).ReceiveMessage))
|
||||
}
|
||||
|
||||
// RemoteAddr mocks base method.
|
||||
func (m *MockQuicSession) RemoteAddr() net.Addr {
|
||||
func (m *MockQuicConn) RemoteAddr() net.Addr {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RemoteAddr")
|
||||
ret0, _ := ret[0].(net.Addr)
|
||||
|
@ -248,13 +248,13 @@ func (m *MockQuicSession) RemoteAddr() net.Addr {
|
|||
}
|
||||
|
||||
// RemoteAddr indicates an expected call of RemoteAddr.
|
||||
func (mr *MockQuicSessionMockRecorder) RemoteAddr() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) RemoteAddr() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockQuicSession)(nil).RemoteAddr))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockQuicConn)(nil).RemoteAddr))
|
||||
}
|
||||
|
||||
// SendMessage mocks base method.
|
||||
func (m *MockQuicSession) SendMessage(arg0 []byte) error {
|
||||
func (m *MockQuicConn) SendMessage(arg0 []byte) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendMessage", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
@ -262,25 +262,25 @@ func (m *MockQuicSession) SendMessage(arg0 []byte) error {
|
|||
}
|
||||
|
||||
// SendMessage indicates an expected call of SendMessage.
|
||||
func (mr *MockQuicSessionMockRecorder) SendMessage(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) SendMessage(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMessage", reflect.TypeOf((*MockQuicSession)(nil).SendMessage), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMessage", reflect.TypeOf((*MockQuicConn)(nil).SendMessage), arg0)
|
||||
}
|
||||
|
||||
// destroy mocks base method.
|
||||
func (m *MockQuicSession) destroy(arg0 error) {
|
||||
func (m *MockQuicConn) destroy(arg0 error) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "destroy", arg0)
|
||||
}
|
||||
|
||||
// destroy indicates an expected call of destroy.
|
||||
func (mr *MockQuicSessionMockRecorder) destroy(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) destroy(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "destroy", reflect.TypeOf((*MockQuicSession)(nil).destroy), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "destroy", reflect.TypeOf((*MockQuicConn)(nil).destroy), arg0)
|
||||
}
|
||||
|
||||
// earlySessionReady mocks base method.
|
||||
func (m *MockQuicSession) earlySessionReady() <-chan struct{} {
|
||||
func (m *MockQuicConn) earlySessionReady() <-chan struct{} {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "earlySessionReady")
|
||||
ret0, _ := ret[0].(<-chan struct{})
|
||||
|
@ -288,13 +288,13 @@ func (m *MockQuicSession) earlySessionReady() <-chan struct{} {
|
|||
}
|
||||
|
||||
// earlySessionReady indicates an expected call of earlySessionReady.
|
||||
func (mr *MockQuicSessionMockRecorder) earlySessionReady() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) earlySessionReady() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "earlySessionReady", reflect.TypeOf((*MockQuicSession)(nil).earlySessionReady))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "earlySessionReady", reflect.TypeOf((*MockQuicConn)(nil).earlySessionReady))
|
||||
}
|
||||
|
||||
// getPerspective mocks base method.
|
||||
func (m *MockQuicSession) getPerspective() protocol.Perspective {
|
||||
func (m *MockQuicConn) getPerspective() protocol.Perspective {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "getPerspective")
|
||||
ret0, _ := ret[0].(protocol.Perspective)
|
||||
|
@ -302,25 +302,25 @@ func (m *MockQuicSession) getPerspective() protocol.Perspective {
|
|||
}
|
||||
|
||||
// getPerspective indicates an expected call of getPerspective.
|
||||
func (mr *MockQuicSessionMockRecorder) getPerspective() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) getPerspective() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getPerspective", reflect.TypeOf((*MockQuicSession)(nil).getPerspective))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getPerspective", reflect.TypeOf((*MockQuicConn)(nil).getPerspective))
|
||||
}
|
||||
|
||||
// handlePacket mocks base method.
|
||||
func (m *MockQuicSession) handlePacket(arg0 *receivedPacket) {
|
||||
func (m *MockQuicConn) handlePacket(arg0 *receivedPacket) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "handlePacket", arg0)
|
||||
}
|
||||
|
||||
// handlePacket indicates an expected call of handlePacket.
|
||||
func (mr *MockQuicSessionMockRecorder) handlePacket(arg0 interface{}) *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) handlePacket(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handlePacket", reflect.TypeOf((*MockQuicSession)(nil).handlePacket), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handlePacket", reflect.TypeOf((*MockQuicConn)(nil).handlePacket), arg0)
|
||||
}
|
||||
|
||||
// run mocks base method.
|
||||
func (m *MockQuicSession) run() error {
|
||||
func (m *MockQuicConn) run() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "run")
|
||||
ret0, _ := ret[0].(error)
|
||||
|
@ -328,19 +328,19 @@ func (m *MockQuicSession) run() error {
|
|||
}
|
||||
|
||||
// run indicates an expected call of run.
|
||||
func (mr *MockQuicSessionMockRecorder) run() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) run() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "run", reflect.TypeOf((*MockQuicSession)(nil).run))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "run", reflect.TypeOf((*MockQuicConn)(nil).run))
|
||||
}
|
||||
|
||||
// shutdown mocks base method.
|
||||
func (m *MockQuicSession) shutdown() {
|
||||
func (m *MockQuicConn) shutdown() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "shutdown")
|
||||
}
|
||||
|
||||
// shutdown indicates an expected call of shutdown.
|
||||
func (mr *MockQuicSessionMockRecorder) shutdown() *gomock.Call {
|
||||
func (mr *MockQuicConnMockRecorder) shutdown() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "shutdown", reflect.TypeOf((*MockQuicSession)(nil).shutdown))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "shutdown", reflect.TypeOf((*MockQuicConn)(nil).shutdown))
|
||||
}
|
|
@ -17,7 +17,7 @@ package quic
|
|||
//go:generate sh -c "./mockgen_private.sh quic mock_packer_test.go github.com/lucas-clemente/quic-go packer"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_mtu_discoverer_test.go github.com/lucas-clemente/quic-go mtuDiscoverer"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_session_runner_test.go github.com/lucas-clemente/quic-go sessionRunner"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_quic_session_test.go github.com/lucas-clemente/quic-go quicSession"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_quic_conn_test.go github.com/lucas-clemente/quic-go quicConn"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_packet_handler_test.go github.com/lucas-clemente/quic-go packetHandler"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_unknown_packet_handler_test.go github.com/lucas-clemente/quic-go unknownPacketHandler"
|
||||
//go:generate sh -c "./mockgen_private.sh quic mock_packet_handler_manager_test.go github.com/lucas-clemente/quic-go packetHandlerManager"
|
||||
|
|
14
server.go
14
server.go
|
@ -41,7 +41,7 @@ type packetHandlerManager interface {
|
|||
CloseServer()
|
||||
}
|
||||
|
||||
type quicSession interface {
|
||||
type quicConn interface {
|
||||
EarlyConnection
|
||||
earlySessionReady() <-chan struct{}
|
||||
handlePacket(*receivedPacket)
|
||||
|
@ -90,14 +90,14 @@ type baseServer struct {
|
|||
uint64,
|
||||
utils.Logger,
|
||||
protocol.VersionNumber,
|
||||
) quicSession
|
||||
) quicConn
|
||||
|
||||
serverError error
|
||||
errorChan chan struct{}
|
||||
closed bool
|
||||
running chan struct{} // closed as soon as run() returns
|
||||
|
||||
sessionQueue chan quicSession
|
||||
sessionQueue chan quicConn
|
||||
sessionQueueLen int32 // to be used as an atomic
|
||||
|
||||
logger utils.Logger
|
||||
|
@ -205,7 +205,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config, acceptEarl
|
|||
config: config,
|
||||
tokenGenerator: tokenGenerator,
|
||||
sessionHandler: sessionHandler,
|
||||
sessionQueue: make(chan quicSession),
|
||||
sessionQueue: make(chan quicConn),
|
||||
errorChan: make(chan struct{}),
|
||||
running: make(chan struct{}),
|
||||
receivedPackets: make(chan *receivedPacket, protocol.MaxServerUnprocessedPackets),
|
||||
|
@ -264,7 +264,7 @@ func (s *baseServer) Accept(ctx context.Context) (Connection, error) {
|
|||
return s.accept(ctx)
|
||||
}
|
||||
|
||||
func (s *baseServer) accept(ctx context.Context) (quicSession, error) {
|
||||
func (s *baseServer) accept(ctx context.Context) (quicConn, error) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
|
@ -452,7 +452,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
|
|||
return err
|
||||
}
|
||||
s.logger.Debugf("Changing connection ID to %s.", connID)
|
||||
var sess quicSession
|
||||
var sess quicConn
|
||||
tracingID := nextSessionTracingID()
|
||||
if added := s.sessionHandler.AddWithConnID(hdr.DestConnectionID, connID, func() packetHandler {
|
||||
var tracer logging.ConnectionTracer
|
||||
|
@ -500,7 +500,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *baseServer) handleNewSession(sess quicSession) {
|
||||
func (s *baseServer) handleNewSession(sess quicConn) {
|
||||
sessCtx := sess.Context()
|
||||
if s.acceptEarlySessions {
|
||||
// wait until the early session is ready (or the handshake fails)
|
||||
|
|
140
server_test.go
140
server_test.go
|
@ -323,7 +323,7 @@ var _ = Describe("Server", func() {
|
|||
return true
|
||||
})
|
||||
tracer.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveServer, protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde})
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
serv.newSession = func(
|
||||
_ sendConn,
|
||||
_ sessionRunner,
|
||||
|
@ -341,7 +341,7 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
Expect(enable0RTT).To(BeFalse())
|
||||
Expect(origDestConnID).To(Equal(protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde}))
|
||||
Expect(retrySrcConnID).To(Equal(&protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad}))
|
||||
|
@ -352,11 +352,11 @@ var _ = Describe("Server", func() {
|
|||
Expect(srcConnID).ToNot(Equal(hdr.SrcConnectionID))
|
||||
Expect(srcConnID).To(Equal(newConnID))
|
||||
Expect(tokenP).To(Equal(token))
|
||||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run().Do(func() { close(run) })
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return sess
|
||||
conn.EXPECT().handlePacket(p)
|
||||
conn.EXPECT().run().Do(func() { close(run) })
|
||||
conn.EXPECT().Context().Return(context.Background())
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
|
@ -602,7 +602,7 @@ var _ = Describe("Server", func() {
|
|||
})
|
||||
tracer.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveServer, protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
|
||||
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
serv.newSession = func(
|
||||
_ sendConn,
|
||||
_ sessionRunner,
|
||||
|
@ -620,7 +620,7 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
Expect(enable0RTT).To(BeFalse())
|
||||
Expect(origDestConnID).To(Equal(hdr.DestConnectionID))
|
||||
Expect(retrySrcConnID).To(BeNil())
|
||||
|
@ -631,11 +631,11 @@ var _ = Describe("Server", func() {
|
|||
Expect(srcConnID).ToNot(Equal(hdr.SrcConnectionID))
|
||||
Expect(srcConnID).To(Equal(newConnID))
|
||||
Expect(tokenP).To(Equal(token))
|
||||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run().Do(func() { close(run) })
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return sess
|
||||
conn.EXPECT().handlePacket(p)
|
||||
conn.EXPECT().run().Do(func() { close(run) })
|
||||
conn.EXPECT().Context().Return(context.Background())
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
|
@ -680,15 +680,15 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
<-acceptSession
|
||||
atomic.AddUint32(&counter, 1)
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().handlePacket(gomock.Any()).MaxTimes(1)
|
||||
sess.EXPECT().run().MaxTimes(1)
|
||||
sess.EXPECT().Context().Return(context.Background()).MaxTimes(1)
|
||||
sess.EXPECT().HandshakeComplete().Return(context.Background()).MaxTimes(1)
|
||||
return sess
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().handlePacket(gomock.Any()).MaxTimes(1)
|
||||
conn.EXPECT().run().MaxTimes(1)
|
||||
conn.EXPECT().Context().Return(context.Background()).MaxTimes(1)
|
||||
conn.EXPECT().HandshakeComplete().Return(context.Background()).MaxTimes(1)
|
||||
return conn
|
||||
}
|
||||
|
||||
p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8})
|
||||
|
@ -716,7 +716,7 @@ var _ = Describe("Server", func() {
|
|||
It("only creates a single session for a duplicate Initial", func() {
|
||||
serv.config.AcceptToken = func(_ net.Addr, _ *Token) bool { return true }
|
||||
var createdSession bool
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
serv.newSession = func(
|
||||
_ sendConn,
|
||||
runner sessionRunner,
|
||||
|
@ -734,9 +734,9 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
createdSession = true
|
||||
return sess
|
||||
return conn
|
||||
}
|
||||
|
||||
p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9})
|
||||
|
@ -765,15 +765,15 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().handlePacket(gomock.Any())
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
) quicConn {
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().handlePacket(gomock.Any())
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().Context().Return(context.Background())
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
sess.EXPECT().HandshakeComplete().Return(ctx)
|
||||
return sess
|
||||
conn.EXPECT().HandshakeComplete().Return(ctx)
|
||||
return conn
|
||||
}
|
||||
|
||||
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
|
||||
|
@ -819,7 +819,7 @@ var _ = Describe("Server", func() {
|
|||
p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
sessionCreated := make(chan struct{})
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
serv.newSession = func(
|
||||
_ sendConn,
|
||||
runner sessionRunner,
|
||||
|
@ -837,15 +837,15 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().Context().Return(ctx)
|
||||
) quicConn {
|
||||
conn.EXPECT().handlePacket(p)
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().Context().Return(ctx)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
sess.EXPECT().HandshakeComplete().Return(ctx)
|
||||
conn.EXPECT().HandshakeComplete().Return(ctx)
|
||||
close(sessionCreated)
|
||||
return sess
|
||||
return conn
|
||||
}
|
||||
|
||||
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
|
||||
|
@ -872,7 +872,7 @@ var _ = Describe("Server", func() {
|
|||
|
||||
// make the go routine return
|
||||
phm.EXPECT().CloseServer()
|
||||
sess.EXPECT().getPerspective().MaxTimes(2) // once for every conn ID
|
||||
conn.EXPECT().getPerspective().MaxTimes(2) // once for every conn ID
|
||||
Expect(serv.Close()).To(Succeed())
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
@ -919,14 +919,14 @@ var _ = Describe("Server", func() {
|
|||
})
|
||||
|
||||
It("accepts new sessions when the handshake completes", func() {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
s, err := serv.Accept(context.Background())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(s).To(Equal(sess))
|
||||
Expect(s).To(Equal(conn))
|
||||
close(done)
|
||||
}()
|
||||
|
||||
|
@ -949,12 +949,12 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
sess.EXPECT().handlePacket(gomock.Any())
|
||||
sess.EXPECT().HandshakeComplete().Return(ctx)
|
||||
sess.EXPECT().run().Do(func() {})
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
return sess
|
||||
) quicConn {
|
||||
conn.EXPECT().handlePacket(gomock.Any())
|
||||
conn.EXPECT().HandshakeComplete().Return(ctx)
|
||||
conn.EXPECT().run().Do(func() {})
|
||||
conn.EXPECT().Context().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
|
||||
phm.EXPECT().GetStatelessResetToken(gomock.Any())
|
||||
|
@ -993,14 +993,14 @@ var _ = Describe("Server", func() {
|
|||
})
|
||||
|
||||
It("accepts new sessions when they become ready", func() {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
s, err := serv.Accept(context.Background())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(s).To(Equal(sess))
|
||||
Expect(s).To(Equal(conn))
|
||||
close(done)
|
||||
}()
|
||||
|
||||
|
@ -1023,13 +1023,13 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
Expect(enable0RTT).To(BeTrue())
|
||||
sess.EXPECT().handlePacket(gomock.Any())
|
||||
sess.EXPECT().run().Do(func() {})
|
||||
sess.EXPECT().earlySessionReady().Return(ready)
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
return sess
|
||||
conn.EXPECT().handlePacket(gomock.Any())
|
||||
conn.EXPECT().run().Do(func() {})
|
||||
conn.EXPECT().earlySessionReady().Return(ready)
|
||||
conn.EXPECT().Context().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
|
||||
phm.EXPECT().GetStatelessResetToken(gomock.Any())
|
||||
|
@ -1066,15 +1066,15 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
ready := make(chan struct{})
|
||||
close(ready)
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().handlePacket(gomock.Any())
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().earlySessionReady().Return(ready)
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
return sess
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
conn.EXPECT().handlePacket(gomock.Any())
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().earlySessionReady().Return(ready)
|
||||
conn.EXPECT().Context().Return(context.Background())
|
||||
return conn
|
||||
}
|
||||
|
||||
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
|
||||
|
@ -1112,7 +1112,7 @@ var _ = Describe("Server", func() {
|
|||
p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
sessionCreated := make(chan struct{})
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
conn := NewMockQuicConn(mockCtrl)
|
||||
serv.newSession = func(
|
||||
_ sendConn,
|
||||
runner sessionRunner,
|
||||
|
@ -1130,13 +1130,13 @@ var _ = Describe("Server", func() {
|
|||
_ uint64,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
) quicSession {
|
||||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().earlySessionReady()
|
||||
sess.EXPECT().Context().Return(ctx)
|
||||
) quicConn {
|
||||
conn.EXPECT().handlePacket(p)
|
||||
conn.EXPECT().run()
|
||||
conn.EXPECT().earlySessionReady()
|
||||
conn.EXPECT().Context().Return(ctx)
|
||||
close(sessionCreated)
|
||||
return sess
|
||||
return conn
|
||||
}
|
||||
|
||||
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
|
||||
|
@ -1161,7 +1161,7 @@ var _ = Describe("Server", func() {
|
|||
|
||||
// make the go routine return
|
||||
phm.EXPECT().CloseServer()
|
||||
sess.EXPECT().getPerspective().MaxTimes(2) // once for every conn ID
|
||||
conn.EXPECT().getPerspective().MaxTimes(2) // once for every conn ID
|
||||
Expect(serv.Close()).To(Succeed())
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
|
|
@ -245,7 +245,7 @@ var newSession = func(
|
|||
tracingID uint64,
|
||||
logger utils.Logger,
|
||||
v protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
s := &session{
|
||||
conn: conn,
|
||||
config: conf,
|
||||
|
@ -376,7 +376,7 @@ var newClientSession = func(
|
|||
tracingID uint64,
|
||||
logger utils.Logger,
|
||||
v protocol.VersionNumber,
|
||||
) quicSession {
|
||||
) quicConn {
|
||||
s := &session{
|
||||
conn: conn,
|
||||
config: conf,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue