forked from quic-go/quic-go
move initialization of the server's transport parameters to the session
This commit is contained in:
@@ -46,6 +46,20 @@ func (mr *MockSessionRunnerMockRecorder) AddResetToken(arg0, arg1 interface{}) *
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddResetToken", reflect.TypeOf((*MockSessionRunner)(nil).AddResetToken), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetStatelessResetToken mocks base method
|
||||
func (m *MockSessionRunner) GetStatelessResetToken(arg0 protocol.ConnectionID) [16]byte {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetStatelessResetToken", arg0)
|
||||
ret0, _ := ret[0].([16]byte)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetStatelessResetToken indicates an expected call of GetStatelessResetToken
|
||||
func (mr *MockSessionRunnerMockRecorder) GetStatelessResetToken(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatelessResetToken", reflect.TypeOf((*MockSessionRunner)(nil).GetStatelessResetToken), arg0)
|
||||
}
|
||||
|
||||
// Remove mocks base method
|
||||
func (m *MockSessionRunner) Remove(arg0 protocol.ConnectionID) {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
21
server.go
21
server.go
@@ -35,7 +35,6 @@ type unknownPacketHandler interface {
|
||||
type packetHandlerManager interface {
|
||||
io.Closer
|
||||
Add(protocol.ConnectionID, packetHandler)
|
||||
GetStatelessResetToken(protocol.ConnectionID) [16]byte
|
||||
SetServer(unknownPacketHandler)
|
||||
CloseServer()
|
||||
sessionRunner
|
||||
@@ -72,7 +71,7 @@ type baseServer struct {
|
||||
sessionHandler packetHandlerManager
|
||||
|
||||
// set as a member, so they can be set in the tests
|
||||
newSession func(connection, sessionRunner, protocol.ConnectionID /* original connection ID */, protocol.ConnectionID /* destination connection ID */, protocol.ConnectionID /* source connection ID */, *Config, *tls.Config, *handshake.TransportParameters, *handshake.TokenGenerator, utils.Logger, protocol.VersionNumber) quicSession
|
||||
newSession func(connection, sessionRunner, protocol.ConnectionID /* original connection ID */, protocol.ConnectionID /* client dest connection ID */, protocol.ConnectionID /* destination connection ID */, protocol.ConnectionID /* source connection ID */, *Config, *tls.Config, *handshake.TokenGenerator, utils.Logger, protocol.VersionNumber) quicSession
|
||||
|
||||
serverError error
|
||||
errorChan chan struct{}
|
||||
@@ -434,31 +433,15 @@ func (s *baseServer) createNewSession(
|
||||
srcConnID protocol.ConnectionID,
|
||||
version protocol.VersionNumber,
|
||||
) quicSession {
|
||||
token := s.sessionHandler.GetStatelessResetToken(srcConnID)
|
||||
params := &handshake.TransportParameters{
|
||||
InitialMaxStreamDataBidiLocal: protocol.InitialMaxStreamData,
|
||||
InitialMaxStreamDataBidiRemote: protocol.InitialMaxStreamData,
|
||||
InitialMaxStreamDataUni: protocol.InitialMaxStreamData,
|
||||
InitialMaxData: protocol.InitialMaxData,
|
||||
IdleTimeout: s.config.IdleTimeout,
|
||||
MaxBidiStreamNum: protocol.StreamNum(s.config.MaxIncomingStreams),
|
||||
MaxUniStreamNum: protocol.StreamNum(s.config.MaxIncomingUniStreams),
|
||||
MaxAckDelay: protocol.MaxAckDelayInclGranularity,
|
||||
AckDelayExponent: protocol.AckDelayExponent,
|
||||
DisableMigration: true,
|
||||
StatelessResetToken: &token,
|
||||
OriginalConnectionID: origDestConnID,
|
||||
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs,
|
||||
}
|
||||
sess := s.newSession(
|
||||
&conn{pconn: s.conn, currentAddr: remoteAddr},
|
||||
s.sessionHandler,
|
||||
origDestConnID,
|
||||
clientDestConnID,
|
||||
destConnID,
|
||||
srcConnID,
|
||||
s.config,
|
||||
s.tlsConf,
|
||||
params,
|
||||
s.tokenGenerator,
|
||||
s.logger,
|
||||
version,
|
||||
|
||||
@@ -285,12 +285,12 @@ var _ = Describe("Server", func() {
|
||||
serv.newSession = func(
|
||||
_ connection,
|
||||
_ sessionRunner,
|
||||
_ protocol.ConnectionID,
|
||||
origConnID protocol.ConnectionID,
|
||||
destConnID protocol.ConnectionID,
|
||||
srcConnID protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
@@ -340,9 +340,9 @@ var _ = Describe("Server", func() {
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
@@ -401,9 +401,9 @@ var _ = Describe("Server", func() {
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
@@ -498,9 +498,9 @@ var _ = Describe("Server", func() {
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
@@ -546,9 +546,9 @@ var _ = Describe("Server", func() {
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
@@ -583,9 +583,9 @@ var _ = Describe("Server", func() {
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
@@ -644,9 +644,9 @@ var _ = Describe("Server", func() {
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ protocol.ConnectionID,
|
||||
_ *Config,
|
||||
_ *tls.Config,
|
||||
_ *handshake.TransportParameters,
|
||||
_ *handshake.TokenGenerator,
|
||||
_ utils.Logger,
|
||||
_ protocol.VersionNumber,
|
||||
|
||||
19
session.go
19
session.go
@@ -79,6 +79,7 @@ type sessionRunner interface {
|
||||
AddResetToken([16]byte, packetHandler)
|
||||
RemoveResetToken([16]byte)
|
||||
RetireResetToken([16]byte)
|
||||
GetStatelessResetToken(protocol.ConnectionID) [16]byte
|
||||
}
|
||||
|
||||
type handshakeRunner struct {
|
||||
@@ -186,12 +187,12 @@ var _ streamSender = &session{}
|
||||
var newSession = func(
|
||||
conn connection,
|
||||
runner sessionRunner,
|
||||
origDestConnID protocol.ConnectionID,
|
||||
clientDestConnID protocol.ConnectionID,
|
||||
destConnID protocol.ConnectionID,
|
||||
srcConnID protocol.ConnectionID,
|
||||
conf *Config,
|
||||
tlsConf *tls.Config,
|
||||
params *handshake.TransportParameters,
|
||||
tokenGenerator *handshake.TokenGenerator,
|
||||
logger utils.Logger,
|
||||
v protocol.VersionNumber,
|
||||
@@ -219,6 +220,22 @@ var newSession = func(
|
||||
initialStream := newCryptoStream()
|
||||
handshakeStream := newCryptoStream()
|
||||
oneRTTStream := newPostHandshakeCryptoStream(s.framer)
|
||||
token := s.sessionRunner.GetStatelessResetToken(srcConnID)
|
||||
params := &handshake.TransportParameters{
|
||||
InitialMaxStreamDataBidiLocal: protocol.InitialMaxStreamData,
|
||||
InitialMaxStreamDataBidiRemote: protocol.InitialMaxStreamData,
|
||||
InitialMaxStreamDataUni: protocol.InitialMaxStreamData,
|
||||
InitialMaxData: protocol.InitialMaxData,
|
||||
IdleTimeout: s.config.IdleTimeout,
|
||||
MaxBidiStreamNum: protocol.StreamNum(s.config.MaxIncomingStreams),
|
||||
MaxUniStreamNum: protocol.StreamNum(s.config.MaxIncomingUniStreams),
|
||||
MaxAckDelay: protocol.MaxAckDelayInclGranularity,
|
||||
AckDelayExponent: protocol.AckDelayExponent,
|
||||
DisableMigration: true,
|
||||
StatelessResetToken: &token,
|
||||
OriginalConnectionID: origDestConnID,
|
||||
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs,
|
||||
}
|
||||
cs := handshake.NewCryptoSetupServer(
|
||||
initialStream,
|
||||
handshakeStream,
|
||||
|
||||
@@ -104,18 +104,19 @@ var _ = Describe("Session", func() {
|
||||
Eventually(areSessionsRunning).Should(BeFalse())
|
||||
|
||||
sessionRunner = NewMockSessionRunner(mockCtrl)
|
||||
sessionRunner.EXPECT().GetStatelessResetToken(gomock.Any())
|
||||
mconn = newMockConnection()
|
||||
tokenGenerator, err := handshake.NewTokenGenerator()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
sess = newSession(
|
||||
mconn,
|
||||
sessionRunner,
|
||||
nil,
|
||||
protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
destConnID,
|
||||
protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
populateServerConfig(&Config{}),
|
||||
nil, // tls.Config
|
||||
&handshake.TransportParameters{},
|
||||
tokenGenerator,
|
||||
utils.DefaultLogger,
|
||||
protocol.VersionTLS,
|
||||
|
||||
Reference in New Issue
Block a user