rename the quicSession to quicConnection

This commit is contained in:
Marten Seemann 2022-03-26 15:15:30 +01:00
parent 6aaa9a817c
commit e7c2e7e147
7 changed files with 219 additions and 220 deletions

View file

@ -35,7 +35,7 @@ type client struct {
handshakeChan chan struct{} handshakeChan chan struct{}
session quicSession session quicConn
tracer logging.ConnectionTracer tracer logging.ConnectionTracer
tracingID uint64 tracingID uint64
@ -105,7 +105,7 @@ func dialAddrContext(
tlsConf *tls.Config, tlsConf *tls.Config,
config *Config, config *Config,
use0RTT bool, use0RTT bool,
) (quicSession, error) { ) (quicConn, error) {
udpAddr, err := net.ResolveUDPAddr("udp", addr) udpAddr, err := net.ResolveUDPAddr("udp", addr)
if err != nil { if err != nil {
return nil, err return nil, err
@ -185,7 +185,7 @@ func dialContext(
config *Config, config *Config,
use0RTT bool, use0RTT bool,
createdPacketConn bool, createdPacketConn bool,
) (quicSession, error) { ) (quicConn, error) {
if tlsConf == nil { if tlsConf == nil {
return nil, errors.New("quic: tls.Config not set") return nil, errors.New("quic: tls.Config not set")
} }

View file

@ -45,7 +45,7 @@ var _ = Describe("Client", func() {
tracingID uint64, tracingID uint64,
logger utils.Logger, logger utils.Logger,
v protocol.VersionNumber, v protocol.VersionNumber,
) quicSession ) quicConn
) )
BeforeEach(func() { BeforeEach(func() {
@ -57,7 +57,6 @@ var _ = Describe("Client", func() {
tr.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveClient, gomock.Any()).Return(tracer).MaxTimes(1) tr.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveClient, gomock.Any()).Return(tracer).MaxTimes(1)
config = &Config{Tracer: tr, Versions: []protocol.VersionNumber{protocol.VersionTLS}} config = &Config{Tracer: tr, Versions: []protocol.VersionNumber{protocol.VersionTLS}}
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
// sess = NewMockQuicSession(mockCtrl)
addr = &net.UDPAddr{IP: net.IPv4(192, 168, 100, 200), Port: 1337} addr = &net.UDPAddr{IP: net.IPv4(192, 168, 100, 200), Port: 1337}
packetConn = NewMockPacketConn(mockCtrl) packetConn = NewMockPacketConn(mockCtrl)
packetConn.EXPECT().LocalAddr().Return(&net.UDPAddr{}).AnyTimes() packetConn.EXPECT().LocalAddr().Return(&net.UDPAddr{}).AnyTimes()
@ -120,7 +119,7 @@ var _ = Describe("Client", func() {
remoteAddrChan := make(chan string, 1) remoteAddrChan := make(chan string, 1)
newClientSession = func( newClientSession = func(
conn sendConn, sconn sendConn,
_ sessionRunner, _ sessionRunner,
_ protocol.ConnectionID, _ protocol.ConnectionID,
_ protocol.ConnectionID, _ protocol.ConnectionID,
@ -133,12 +132,12 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
remoteAddrChan <- conn.RemoteAddr().String() remoteAddrChan <- sconn.RemoteAddr().String()
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
return sess return conn
} }
_, err := DialAddr("localhost:17890", tlsConf, &Config{HandshakeIdleTimeout: time.Millisecond}) _, err := DialAddr("localhost:17890", tlsConf, &Config{HandshakeIdleTimeout: time.Millisecond})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -166,12 +165,12 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
hostnameChan <- tlsConf.ServerName hostnameChan <- tlsConf.ServerName
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
return sess return conn
} }
tlsConf.ServerName = "foobar" tlsConf.ServerName = "foobar"
_, err := DialAddr("localhost:17890", tlsConf, nil) _, err := DialAddr("localhost:17890", tlsConf, nil)
@ -199,12 +198,12 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
hostnameChan <- tlsConf.ServerName hostnameChan <- tlsConf.ServerName
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
sess.EXPECT().run() conn.EXPECT().run()
return sess return conn
} }
tracer.EXPECT().StartedConnection(packetConn.LocalAddr(), addr, gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(packetConn.LocalAddr(), addr, gomock.Any(), gomock.Any())
_, err := Dial( _, err := Dial(
@ -238,14 +237,14 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
Expect(enable0RTT).To(BeFalse()) Expect(enable0RTT).To(BeFalse())
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run().Do(func() { close(run) }) conn.EXPECT().run().Do(func() { close(run) })
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
cancel() cancel()
sess.EXPECT().HandshakeComplete().Return(ctx) conn.EXPECT().HandshakeComplete().Return(ctx)
return sess return conn
} }
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
s, err := Dial( s, err := Dial(
@ -281,13 +280,13 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
Expect(enable0RTT).To(BeTrue()) Expect(enable0RTT).To(BeTrue())
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run().Do(func() { <-done }) conn.EXPECT().run().Do(func() { <-done })
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
sess.EXPECT().earlySessionReady().Return(readyChan) conn.EXPECT().earlySessionReady().Return(readyChan)
return sess return conn
} }
go func() { go func() {
@ -329,11 +328,11 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run().Return(testErr) conn.EXPECT().run().Return(testErr)
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
return sess return conn
} }
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
_, err := Dial( _, err := Dial(
@ -353,11 +352,11 @@ var _ = Describe("Client", func() {
sessionRunning := make(chan struct{}) sessionRunning := make(chan struct{})
defer close(sessionRunning) defer close(sessionRunning)
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run().Do(func() { conn.EXPECT().run().Do(func() {
<-sessionRunning <-sessionRunning
}) })
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
newClientSession = func( newClientSession = func(
_ sendConn, _ sendConn,
_ sessionRunner, _ sessionRunner,
@ -372,8 +371,8 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
return sess return conn
} }
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
dialed := make(chan struct{}) dialed := make(chan struct{})
@ -392,7 +391,7 @@ var _ = Describe("Client", func() {
close(dialed) close(dialed)
}() }()
Consistently(dialed).ShouldNot(BeClosed()) Consistently(dialed).ShouldNot(BeClosed())
sess.EXPECT().shutdown() conn.EXPECT().shutdown()
cancel() cancel()
Eventually(dialed).Should(BeClosed()) 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) mockMultiplexer.EXPECT().AddConn(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(manager, nil)
manager.EXPECT().Add(gomock.Any(), gomock.Any()) manager.EXPECT().Add(gomock.Any(), gomock.Any())
var conn sendConn var sconn sendConn
run := make(chan struct{}) run := make(chan struct{})
sessionCreated := make(chan struct{}) sessionCreated := make(chan struct{})
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
newClientSession = func( newClientSession = func(
connP sendConn, connP sendConn,
_ sessionRunner, _ sessionRunner,
@ -424,15 +423,15 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
conn = connP sconn = connP
close(sessionCreated) close(sessionCreated)
return sess return conn
} }
sess.EXPECT().run().Do(func() { conn.EXPECT().run().Do(func() {
<-run <-run
}) })
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
@ -445,7 +444,7 @@ var _ = Describe("Client", func() {
Eventually(sessionCreated).Should(BeClosed()) Eventually(sessionCreated).Should(BeClosed())
// check that the connection is not closed // check that the connection is not closed
Expect(conn.Write([]byte("foobar"))).To(Succeed()) Expect(sconn.Write([]byte("foobar"))).To(Succeed())
manager.EXPECT().Destroy() manager.EXPECT().Destroy()
close(run) close(run)
@ -544,16 +543,16 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
versionP protocol.VersionNumber, versionP protocol.VersionNumber,
) quicSession { ) quicConn {
cconn = connP cconn = connP
version = versionP version = versionP
conf = configP conf = configP
close(c) close(c)
// TODO: check connection IDs? // TODO: check connection IDs?
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
return sess return conn
} }
_, err := Dial(packetConn, addr, "localhost:1337", tlsConf, config) _, err := Dial(packetConn, addr, "localhost:1337", tlsConf, config)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@ -584,23 +583,23 @@ var _ = Describe("Client", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
versionP protocol.VersionNumber, versionP protocol.VersionNumber,
) quicSession { ) quicConn {
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
if counter == 0 { if counter == 0 {
Expect(pn).To(BeZero()) Expect(pn).To(BeZero())
Expect(hasNegotiatedVersion).To(BeFalse()) Expect(hasNegotiatedVersion).To(BeFalse())
sess.EXPECT().run().Return(&errCloseForRecreating{ conn.EXPECT().run().Return(&errCloseForRecreating{
nextPacketNumber: 109, nextPacketNumber: 109,
nextVersion: 789, nextVersion: 789,
}) })
} else { } else {
Expect(pn).To(Equal(protocol.PacketNumber(109))) Expect(pn).To(Equal(protocol.PacketNumber(109)))
Expect(hasNegotiatedVersion).To(BeTrue()) Expect(hasNegotiatedVersion).To(BeTrue())
sess.EXPECT().run() conn.EXPECT().run()
} }
counter++ counter++
return sess return conn
} }
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())

View file

@ -13,31 +13,31 @@ import (
protocol "github.com/lucas-clemente/quic-go/internal/protocol" protocol "github.com/lucas-clemente/quic-go/internal/protocol"
) )
// MockQuicSession is a mock of QuicSession interface. // MockQuicConn is a mock of QuicConn interface.
type MockQuicSession struct { type MockQuicConn struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockQuicSessionMockRecorder recorder *MockQuicConnMockRecorder
} }
// MockQuicSessionMockRecorder is the mock recorder for MockQuicSession. // MockQuicConnMockRecorder is the mock recorder for MockQuicConn.
type MockQuicSessionMockRecorder struct { type MockQuicConnMockRecorder struct {
mock *MockQuicSession mock *MockQuicConn
} }
// NewMockQuicSession creates a new mock instance. // NewMockQuicConn creates a new mock instance.
func NewMockQuicSession(ctrl *gomock.Controller) *MockQuicSession { func NewMockQuicConn(ctrl *gomock.Controller) *MockQuicConn {
mock := &MockQuicSession{ctrl: ctrl} mock := &MockQuicConn{ctrl: ctrl}
mock.recorder = &MockQuicSessionMockRecorder{mock} mock.recorder = &MockQuicConnMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use. // EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockQuicSession) EXPECT() *MockQuicSessionMockRecorder { func (m *MockQuicConn) EXPECT() *MockQuicConnMockRecorder {
return m.recorder return m.recorder
} }
// AcceptStream mocks base method. // 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() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AcceptStream", arg0) ret := m.ctrl.Call(m, "AcceptStream", arg0)
ret0, _ := ret[0].(Stream) ret0, _ := ret[0].(Stream)
@ -46,13 +46,13 @@ func (m *MockQuicSession) AcceptStream(arg0 context.Context) (Stream, error) {
} }
// AcceptStream indicates an expected call of AcceptStream. // 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() 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. // 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() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AcceptUniStream", arg0) ret := m.ctrl.Call(m, "AcceptUniStream", arg0)
ret0, _ := ret[0].(ReceiveStream) ret0, _ := ret[0].(ReceiveStream)
@ -61,13 +61,13 @@ func (m *MockQuicSession) AcceptUniStream(arg0 context.Context) (ReceiveStream,
} }
// AcceptUniStream indicates an expected call of AcceptUniStream. // 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() 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. // 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() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1) ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -75,13 +75,13 @@ func (m *MockQuicSession) CloseWithError(arg0 ApplicationErrorCode, arg1 string)
} }
// CloseWithError indicates an expected call of CloseWithError. // 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() 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. // ConnectionState mocks base method.
func (m *MockQuicSession) ConnectionState() ConnectionState { func (m *MockQuicConn) ConnectionState() ConnectionState {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConnectionState") ret := m.ctrl.Call(m, "ConnectionState")
ret0, _ := ret[0].(ConnectionState) ret0, _ := ret[0].(ConnectionState)
@ -89,13 +89,13 @@ func (m *MockQuicSession) ConnectionState() ConnectionState {
} }
// ConnectionState indicates an expected call of 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() 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. // Context mocks base method.
func (m *MockQuicSession) Context() context.Context { func (m *MockQuicConn) Context() context.Context {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Context") ret := m.ctrl.Call(m, "Context")
ret0, _ := ret[0].(context.Context) ret0, _ := ret[0].(context.Context)
@ -103,13 +103,13 @@ func (m *MockQuicSession) Context() context.Context {
} }
// Context indicates an expected call of 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() 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. // GetVersion mocks base method.
func (m *MockQuicSession) GetVersion() protocol.VersionNumber { func (m *MockQuicConn) GetVersion() protocol.VersionNumber {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetVersion") ret := m.ctrl.Call(m, "GetVersion")
ret0, _ := ret[0].(protocol.VersionNumber) ret0, _ := ret[0].(protocol.VersionNumber)
@ -117,13 +117,13 @@ func (m *MockQuicSession) GetVersion() protocol.VersionNumber {
} }
// GetVersion indicates an expected call of GetVersion. // GetVersion indicates an expected call of GetVersion.
func (mr *MockQuicSessionMockRecorder) GetVersion() *gomock.Call { func (mr *MockQuicConnMockRecorder) GetVersion() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // HandshakeComplete mocks base method.
func (m *MockQuicSession) HandshakeComplete() context.Context { func (m *MockQuicConn) HandshakeComplete() context.Context {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HandshakeComplete") ret := m.ctrl.Call(m, "HandshakeComplete")
ret0, _ := ret[0].(context.Context) ret0, _ := ret[0].(context.Context)
@ -131,13 +131,13 @@ func (m *MockQuicSession) HandshakeComplete() context.Context {
} }
// HandshakeComplete indicates an expected call of HandshakeComplete. // HandshakeComplete indicates an expected call of HandshakeComplete.
func (mr *MockQuicSessionMockRecorder) HandshakeComplete() *gomock.Call { func (mr *MockQuicConnMockRecorder) HandshakeComplete() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // LocalAddr mocks base method.
func (m *MockQuicSession) LocalAddr() net.Addr { func (m *MockQuicConn) LocalAddr() net.Addr {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LocalAddr") ret := m.ctrl.Call(m, "LocalAddr")
ret0, _ := ret[0].(net.Addr) ret0, _ := ret[0].(net.Addr)
@ -145,13 +145,13 @@ func (m *MockQuicSession) LocalAddr() net.Addr {
} }
// LocalAddr indicates an expected call of LocalAddr. // LocalAddr indicates an expected call of LocalAddr.
func (mr *MockQuicSessionMockRecorder) LocalAddr() *gomock.Call { func (mr *MockQuicConnMockRecorder) LocalAddr() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // NextConnection mocks base method.
func (m *MockQuicSession) NextConnection() Connection { func (m *MockQuicConn) NextConnection() Connection {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NextConnection") ret := m.ctrl.Call(m, "NextConnection")
ret0, _ := ret[0].(Connection) ret0, _ := ret[0].(Connection)
@ -159,13 +159,13 @@ func (m *MockQuicSession) NextConnection() Connection {
} }
// NextConnection indicates an expected call of NextConnection. // NextConnection indicates an expected call of NextConnection.
func (mr *MockQuicSessionMockRecorder) NextConnection() *gomock.Call { func (mr *MockQuicConnMockRecorder) NextConnection() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // OpenStream mocks base method.
func (m *MockQuicSession) OpenStream() (Stream, error) { func (m *MockQuicConn) OpenStream() (Stream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenStream") ret := m.ctrl.Call(m, "OpenStream")
ret0, _ := ret[0].(Stream) ret0, _ := ret[0].(Stream)
@ -174,13 +174,13 @@ func (m *MockQuicSession) OpenStream() (Stream, error) {
} }
// OpenStream indicates an expected call of OpenStream. // OpenStream indicates an expected call of OpenStream.
func (mr *MockQuicSessionMockRecorder) OpenStream() *gomock.Call { func (mr *MockQuicConnMockRecorder) OpenStream() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // 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() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenStreamSync", arg0) ret := m.ctrl.Call(m, "OpenStreamSync", arg0)
ret0, _ := ret[0].(Stream) ret0, _ := ret[0].(Stream)
@ -189,13 +189,13 @@ func (m *MockQuicSession) OpenStreamSync(arg0 context.Context) (Stream, error) {
} }
// OpenStreamSync indicates an expected call of OpenStreamSync. // 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() 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. // OpenUniStream mocks base method.
func (m *MockQuicSession) OpenUniStream() (SendStream, error) { func (m *MockQuicConn) OpenUniStream() (SendStream, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenUniStream") ret := m.ctrl.Call(m, "OpenUniStream")
ret0, _ := ret[0].(SendStream) ret0, _ := ret[0].(SendStream)
@ -204,13 +204,13 @@ func (m *MockQuicSession) OpenUniStream() (SendStream, error) {
} }
// OpenUniStream indicates an expected call of OpenUniStream. // OpenUniStream indicates an expected call of OpenUniStream.
func (mr *MockQuicSessionMockRecorder) OpenUniStream() *gomock.Call { func (mr *MockQuicConnMockRecorder) OpenUniStream() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // 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() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "OpenUniStreamSync", arg0) ret := m.ctrl.Call(m, "OpenUniStreamSync", arg0)
ret0, _ := ret[0].(SendStream) ret0, _ := ret[0].(SendStream)
@ -219,13 +219,13 @@ func (m *MockQuicSession) OpenUniStreamSync(arg0 context.Context) (SendStream, e
} }
// OpenUniStreamSync indicates an expected call of OpenUniStreamSync. // 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() 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. // ReceiveMessage mocks base method.
func (m *MockQuicSession) ReceiveMessage() ([]byte, error) { func (m *MockQuicConn) ReceiveMessage() ([]byte, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ReceiveMessage") ret := m.ctrl.Call(m, "ReceiveMessage")
ret0, _ := ret[0].([]byte) ret0, _ := ret[0].([]byte)
@ -234,13 +234,13 @@ func (m *MockQuicSession) ReceiveMessage() ([]byte, error) {
} }
// ReceiveMessage indicates an expected call of ReceiveMessage. // ReceiveMessage indicates an expected call of ReceiveMessage.
func (mr *MockQuicSessionMockRecorder) ReceiveMessage() *gomock.Call { func (mr *MockQuicConnMockRecorder) ReceiveMessage() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // RemoteAddr mocks base method.
func (m *MockQuicSession) RemoteAddr() net.Addr { func (m *MockQuicConn) RemoteAddr() net.Addr {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "RemoteAddr") ret := m.ctrl.Call(m, "RemoteAddr")
ret0, _ := ret[0].(net.Addr) ret0, _ := ret[0].(net.Addr)
@ -248,13 +248,13 @@ func (m *MockQuicSession) RemoteAddr() net.Addr {
} }
// RemoteAddr indicates an expected call of RemoteAddr. // RemoteAddr indicates an expected call of RemoteAddr.
func (mr *MockQuicSessionMockRecorder) RemoteAddr() *gomock.Call { func (mr *MockQuicConnMockRecorder) RemoteAddr() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // SendMessage mocks base method.
func (m *MockQuicSession) SendMessage(arg0 []byte) error { func (m *MockQuicConn) SendMessage(arg0 []byte) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendMessage", arg0) ret := m.ctrl.Call(m, "SendMessage", arg0)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -262,25 +262,25 @@ func (m *MockQuicSession) SendMessage(arg0 []byte) error {
} }
// SendMessage indicates an expected call of SendMessage. // 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() 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. // destroy mocks base method.
func (m *MockQuicSession) destroy(arg0 error) { func (m *MockQuicConn) destroy(arg0 error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
m.ctrl.Call(m, "destroy", arg0) m.ctrl.Call(m, "destroy", arg0)
} }
// destroy indicates an expected call of destroy. // 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() 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. // earlySessionReady mocks base method.
func (m *MockQuicSession) earlySessionReady() <-chan struct{} { func (m *MockQuicConn) earlySessionReady() <-chan struct{} {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "earlySessionReady") ret := m.ctrl.Call(m, "earlySessionReady")
ret0, _ := ret[0].(<-chan struct{}) ret0, _ := ret[0].(<-chan struct{})
@ -288,13 +288,13 @@ func (m *MockQuicSession) earlySessionReady() <-chan struct{} {
} }
// earlySessionReady indicates an expected call of earlySessionReady. // earlySessionReady indicates an expected call of earlySessionReady.
func (mr *MockQuicSessionMockRecorder) earlySessionReady() *gomock.Call { func (mr *MockQuicConnMockRecorder) earlySessionReady() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // getPerspective mocks base method.
func (m *MockQuicSession) getPerspective() protocol.Perspective { func (m *MockQuicConn) getPerspective() protocol.Perspective {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "getPerspective") ret := m.ctrl.Call(m, "getPerspective")
ret0, _ := ret[0].(protocol.Perspective) ret0, _ := ret[0].(protocol.Perspective)
@ -302,25 +302,25 @@ func (m *MockQuicSession) getPerspective() protocol.Perspective {
} }
// getPerspective indicates an expected call of getPerspective. // getPerspective indicates an expected call of getPerspective.
func (mr *MockQuicSessionMockRecorder) getPerspective() *gomock.Call { func (mr *MockQuicConnMockRecorder) getPerspective() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // handlePacket mocks base method.
func (m *MockQuicSession) handlePacket(arg0 *receivedPacket) { func (m *MockQuicConn) handlePacket(arg0 *receivedPacket) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
m.ctrl.Call(m, "handlePacket", arg0) m.ctrl.Call(m, "handlePacket", arg0)
} }
// handlePacket indicates an expected call of handlePacket. // 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() 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. // run mocks base method.
func (m *MockQuicSession) run() error { func (m *MockQuicConn) run() error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "run") ret := m.ctrl.Call(m, "run")
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -328,19 +328,19 @@ func (m *MockQuicSession) run() error {
} }
// run indicates an expected call of run. // run indicates an expected call of run.
func (mr *MockQuicSessionMockRecorder) run() *gomock.Call { func (mr *MockQuicConnMockRecorder) run() *gomock.Call {
mr.mock.ctrl.T.Helper() 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. // shutdown mocks base method.
func (m *MockQuicSession) shutdown() { func (m *MockQuicConn) shutdown() {
m.ctrl.T.Helper() m.ctrl.T.Helper()
m.ctrl.Call(m, "shutdown") m.ctrl.Call(m, "shutdown")
} }
// shutdown indicates an expected call of 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() 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))
} }

View file

@ -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_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_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_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_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_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" //go:generate sh -c "./mockgen_private.sh quic mock_packet_handler_manager_test.go github.com/lucas-clemente/quic-go packetHandlerManager"

View file

@ -41,7 +41,7 @@ type packetHandlerManager interface {
CloseServer() CloseServer()
} }
type quicSession interface { type quicConn interface {
EarlyConnection EarlyConnection
earlySessionReady() <-chan struct{} earlySessionReady() <-chan struct{}
handlePacket(*receivedPacket) handlePacket(*receivedPacket)
@ -90,14 +90,14 @@ type baseServer struct {
uint64, uint64,
utils.Logger, utils.Logger,
protocol.VersionNumber, protocol.VersionNumber,
) quicSession ) quicConn
serverError error serverError error
errorChan chan struct{} errorChan chan struct{}
closed bool closed bool
running chan struct{} // closed as soon as run() returns running chan struct{} // closed as soon as run() returns
sessionQueue chan quicSession sessionQueue chan quicConn
sessionQueueLen int32 // to be used as an atomic sessionQueueLen int32 // to be used as an atomic
logger utils.Logger logger utils.Logger
@ -205,7 +205,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config, acceptEarl
config: config, config: config,
tokenGenerator: tokenGenerator, tokenGenerator: tokenGenerator,
sessionHandler: sessionHandler, sessionHandler: sessionHandler,
sessionQueue: make(chan quicSession), sessionQueue: make(chan quicConn),
errorChan: make(chan struct{}), errorChan: make(chan struct{}),
running: make(chan struct{}), running: make(chan struct{}),
receivedPackets: make(chan *receivedPacket, protocol.MaxServerUnprocessedPackets), receivedPackets: make(chan *receivedPacket, protocol.MaxServerUnprocessedPackets),
@ -264,7 +264,7 @@ func (s *baseServer) Accept(ctx context.Context) (Connection, error) {
return s.accept(ctx) return s.accept(ctx)
} }
func (s *baseServer) accept(ctx context.Context) (quicSession, error) { func (s *baseServer) accept(ctx context.Context) (quicConn, error) {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return nil, ctx.Err() return nil, ctx.Err()
@ -452,7 +452,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
return err return err
} }
s.logger.Debugf("Changing connection ID to %s.", connID) s.logger.Debugf("Changing connection ID to %s.", connID)
var sess quicSession var sess quicConn
tracingID := nextSessionTracingID() tracingID := nextSessionTracingID()
if added := s.sessionHandler.AddWithConnID(hdr.DestConnectionID, connID, func() packetHandler { if added := s.sessionHandler.AddWithConnID(hdr.DestConnectionID, connID, func() packetHandler {
var tracer logging.ConnectionTracer var tracer logging.ConnectionTracer
@ -500,7 +500,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
return nil return nil
} }
func (s *baseServer) handleNewSession(sess quicSession) { func (s *baseServer) handleNewSession(sess quicConn) {
sessCtx := sess.Context() sessCtx := sess.Context()
if s.acceptEarlySessions { if s.acceptEarlySessions {
// wait until the early session is ready (or the handshake fails) // wait until the early session is ready (or the handshake fails)

View file

@ -323,7 +323,7 @@ var _ = Describe("Server", func() {
return true return true
}) })
tracer.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveServer, protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde}) tracer.EXPECT().TracerForConnection(gomock.Any(), protocol.PerspectiveServer, protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde})
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
serv.newSession = func( serv.newSession = func(
_ sendConn, _ sendConn,
_ sessionRunner, _ sessionRunner,
@ -341,7 +341,7 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
Expect(enable0RTT).To(BeFalse()) Expect(enable0RTT).To(BeFalse())
Expect(origDestConnID).To(Equal(protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde})) Expect(origDestConnID).To(Equal(protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde}))
Expect(retrySrcConnID).To(Equal(&protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad})) 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).ToNot(Equal(hdr.SrcConnectionID))
Expect(srcConnID).To(Equal(newConnID)) Expect(srcConnID).To(Equal(newConnID))
Expect(tokenP).To(Equal(token)) Expect(tokenP).To(Equal(token))
sess.EXPECT().handlePacket(p) conn.EXPECT().handlePacket(p)
sess.EXPECT().run().Do(func() { close(run) }) conn.EXPECT().run().Do(func() { close(run) })
sess.EXPECT().Context().Return(context.Background()) conn.EXPECT().Context().Return(context.Background())
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
return sess return conn
} }
done := make(chan struct{}) 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}) 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( serv.newSession = func(
_ sendConn, _ sendConn,
_ sessionRunner, _ sessionRunner,
@ -620,7 +620,7 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
Expect(enable0RTT).To(BeFalse()) Expect(enable0RTT).To(BeFalse())
Expect(origDestConnID).To(Equal(hdr.DestConnectionID)) Expect(origDestConnID).To(Equal(hdr.DestConnectionID))
Expect(retrySrcConnID).To(BeNil()) Expect(retrySrcConnID).To(BeNil())
@ -631,11 +631,11 @@ var _ = Describe("Server", func() {
Expect(srcConnID).ToNot(Equal(hdr.SrcConnectionID)) Expect(srcConnID).ToNot(Equal(hdr.SrcConnectionID))
Expect(srcConnID).To(Equal(newConnID)) Expect(srcConnID).To(Equal(newConnID))
Expect(tokenP).To(Equal(token)) Expect(tokenP).To(Equal(token))
sess.EXPECT().handlePacket(p) conn.EXPECT().handlePacket(p)
sess.EXPECT().run().Do(func() { close(run) }) conn.EXPECT().run().Do(func() { close(run) })
sess.EXPECT().Context().Return(context.Background()) conn.EXPECT().Context().Return(context.Background())
sess.EXPECT().HandshakeComplete().Return(context.Background()) conn.EXPECT().HandshakeComplete().Return(context.Background())
return sess return conn
} }
done := make(chan struct{}) done := make(chan struct{})
@ -680,15 +680,15 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
<-acceptSession <-acceptSession
atomic.AddUint32(&counter, 1) atomic.AddUint32(&counter, 1)
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().handlePacket(gomock.Any()).MaxTimes(1) conn.EXPECT().handlePacket(gomock.Any()).MaxTimes(1)
sess.EXPECT().run().MaxTimes(1) conn.EXPECT().run().MaxTimes(1)
sess.EXPECT().Context().Return(context.Background()).MaxTimes(1) conn.EXPECT().Context().Return(context.Background()).MaxTimes(1)
sess.EXPECT().HandshakeComplete().Return(context.Background()).MaxTimes(1) conn.EXPECT().HandshakeComplete().Return(context.Background()).MaxTimes(1)
return sess return conn
} }
p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8}) 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() { It("only creates a single session for a duplicate Initial", func() {
serv.config.AcceptToken = func(_ net.Addr, _ *Token) bool { return true } serv.config.AcceptToken = func(_ net.Addr, _ *Token) bool { return true }
var createdSession bool var createdSession bool
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
serv.newSession = func( serv.newSession = func(
_ sendConn, _ sendConn,
runner sessionRunner, runner sessionRunner,
@ -734,9 +734,9 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
createdSession = true createdSession = true
return sess return conn
} }
p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9}) p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9})
@ -765,15 +765,15 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().handlePacket(gomock.Any()) conn.EXPECT().handlePacket(gomock.Any())
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().Context().Return(context.Background()) conn.EXPECT().Context().Return(context.Background())
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
cancel() cancel()
sess.EXPECT().HandshakeComplete().Return(ctx) conn.EXPECT().HandshakeComplete().Return(ctx)
return sess return conn
} }
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool { 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}) p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
sessionCreated := make(chan struct{}) sessionCreated := make(chan struct{})
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
serv.newSession = func( serv.newSession = func(
_ sendConn, _ sendConn,
runner sessionRunner, runner sessionRunner,
@ -837,15 +837,15 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
sess.EXPECT().handlePacket(p) conn.EXPECT().handlePacket(p)
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().Context().Return(ctx) conn.EXPECT().Context().Return(ctx)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
cancel() cancel()
sess.EXPECT().HandshakeComplete().Return(ctx) conn.EXPECT().HandshakeComplete().Return(ctx)
close(sessionCreated) close(sessionCreated)
return sess return conn
} }
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool { 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 // make the go routine return
phm.EXPECT().CloseServer() 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()) Expect(serv.Close()).To(Succeed())
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -919,14 +919,14 @@ var _ = Describe("Server", func() {
}) })
It("accepts new sessions when the handshake completes", func() { It("accepts new sessions when the handshake completes", func() {
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
s, err := serv.Accept(context.Background()) s, err := serv.Accept(context.Background())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(s).To(Equal(sess)) Expect(s).To(Equal(conn))
close(done) close(done)
}() }()
@ -949,12 +949,12 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
sess.EXPECT().handlePacket(gomock.Any()) conn.EXPECT().handlePacket(gomock.Any())
sess.EXPECT().HandshakeComplete().Return(ctx) conn.EXPECT().HandshakeComplete().Return(ctx)
sess.EXPECT().run().Do(func() {}) conn.EXPECT().run().Do(func() {})
sess.EXPECT().Context().Return(context.Background()) conn.EXPECT().Context().Return(context.Background())
return sess return conn
} }
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool { phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
phm.EXPECT().GetStatelessResetToken(gomock.Any()) phm.EXPECT().GetStatelessResetToken(gomock.Any())
@ -993,14 +993,14 @@ var _ = Describe("Server", func() {
}) })
It("accepts new sessions when they become ready", func() { It("accepts new sessions when they become ready", func() {
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
defer GinkgoRecover() defer GinkgoRecover()
s, err := serv.Accept(context.Background()) s, err := serv.Accept(context.Background())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(s).To(Equal(sess)) Expect(s).To(Equal(conn))
close(done) close(done)
}() }()
@ -1023,13 +1023,13 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
Expect(enable0RTT).To(BeTrue()) Expect(enable0RTT).To(BeTrue())
sess.EXPECT().handlePacket(gomock.Any()) conn.EXPECT().handlePacket(gomock.Any())
sess.EXPECT().run().Do(func() {}) conn.EXPECT().run().Do(func() {})
sess.EXPECT().earlySessionReady().Return(ready) conn.EXPECT().earlySessionReady().Return(ready)
sess.EXPECT().Context().Return(context.Background()) conn.EXPECT().Context().Return(context.Background())
return sess return conn
} }
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool { phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool {
phm.EXPECT().GetStatelessResetToken(gomock.Any()) phm.EXPECT().GetStatelessResetToken(gomock.Any())
@ -1066,15 +1066,15 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
ready := make(chan struct{}) ready := make(chan struct{})
close(ready) close(ready)
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
sess.EXPECT().handlePacket(gomock.Any()) conn.EXPECT().handlePacket(gomock.Any())
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().earlySessionReady().Return(ready) conn.EXPECT().earlySessionReady().Return(ready)
sess.EXPECT().Context().Return(context.Background()) conn.EXPECT().Context().Return(context.Background())
return sess return conn
} }
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool { 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}) p := getInitial(protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
sessionCreated := make(chan struct{}) sessionCreated := make(chan struct{})
sess := NewMockQuicSession(mockCtrl) conn := NewMockQuicConn(mockCtrl)
serv.newSession = func( serv.newSession = func(
_ sendConn, _ sendConn,
runner sessionRunner, runner sessionRunner,
@ -1130,13 +1130,13 @@ var _ = Describe("Server", func() {
_ uint64, _ uint64,
_ utils.Logger, _ utils.Logger,
_ protocol.VersionNumber, _ protocol.VersionNumber,
) quicSession { ) quicConn {
sess.EXPECT().handlePacket(p) conn.EXPECT().handlePacket(p)
sess.EXPECT().run() conn.EXPECT().run()
sess.EXPECT().earlySessionReady() conn.EXPECT().earlySessionReady()
sess.EXPECT().Context().Return(ctx) conn.EXPECT().Context().Return(ctx)
close(sessionCreated) close(sessionCreated)
return sess return conn
} }
phm.EXPECT().AddWithConnID(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ protocol.ConnectionID, fn func() packetHandler) bool { 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 // make the go routine return
phm.EXPECT().CloseServer() 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()) Expect(serv.Close()).To(Succeed())
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })

View file

@ -245,7 +245,7 @@ var newSession = func(
tracingID uint64, tracingID uint64,
logger utils.Logger, logger utils.Logger,
v protocol.VersionNumber, v protocol.VersionNumber,
) quicSession { ) quicConn {
s := &session{ s := &session{
conn: conn, conn: conn,
config: conf, config: conf,
@ -376,7 +376,7 @@ var newClientSession = func(
tracingID uint64, tracingID uint64,
logger utils.Logger, logger utils.Logger,
v protocol.VersionNumber, v protocol.VersionNumber,
) quicSession { ) quicConn {
s := &session{ s := &session{
conn: conn, conn: conn,
config: conf, config: conf,