mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 05:37:36 +03:00
move the transport parameters from the handshake to the wire package
This commit is contained in:
parent
699c988917
commit
0ef4f06189
17 changed files with 82 additions and 86 deletions
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/lucas-clemente/quic-go/qlog"
|
"github.com/lucas-clemente/quic-go/qlog"
|
||||||
"github.com/marten-seemann/qtls"
|
"github.com/marten-seemann/qtls"
|
||||||
)
|
)
|
||||||
|
@ -64,8 +65,8 @@ type cryptoSetup struct {
|
||||||
|
|
||||||
messageChan chan []byte
|
messageChan chan []byte
|
||||||
|
|
||||||
ourParams *TransportParameters
|
ourParams *wire.TransportParameters
|
||||||
peerParams *TransportParameters
|
peerParams *wire.TransportParameters
|
||||||
paramsChan <-chan []byte
|
paramsChan <-chan []byte
|
||||||
|
|
||||||
runner handshakeRunner
|
runner handshakeRunner
|
||||||
|
@ -76,9 +77,9 @@ type cryptoSetup struct {
|
||||||
// is closed when Close() is called
|
// is closed when Close() is called
|
||||||
closeChan chan struct{}
|
closeChan chan struct{}
|
||||||
|
|
||||||
zeroRTTParameters *TransportParameters
|
zeroRTTParameters *wire.TransportParameters
|
||||||
clientHelloWritten bool
|
clientHelloWritten bool
|
||||||
clientHelloWrittenChan chan *TransportParameters
|
clientHelloWrittenChan chan *wire.TransportParameters
|
||||||
|
|
||||||
receivedWriteKey chan struct{}
|
receivedWriteKey chan struct{}
|
||||||
receivedReadKey chan struct{}
|
receivedReadKey chan struct{}
|
||||||
|
@ -129,14 +130,14 @@ func NewCryptoSetupClient(
|
||||||
connID protocol.ConnectionID,
|
connID protocol.ConnectionID,
|
||||||
localAddr net.Addr,
|
localAddr net.Addr,
|
||||||
remoteAddr net.Addr,
|
remoteAddr net.Addr,
|
||||||
tp *TransportParameters,
|
tp *wire.TransportParameters,
|
||||||
runner handshakeRunner,
|
runner handshakeRunner,
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
rttStats *congestion.RTTStats,
|
rttStats *congestion.RTTStats,
|
||||||
qlogger qlog.Tracer,
|
qlogger qlog.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
) (CryptoSetup, <-chan *TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
) (CryptoSetup, <-chan *wire.TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
||||||
cs, clientHelloWritten := newCryptoSetup(
|
cs, clientHelloWritten := newCryptoSetup(
|
||||||
initialStream,
|
initialStream,
|
||||||
handshakeStream,
|
handshakeStream,
|
||||||
|
@ -161,7 +162,7 @@ func NewCryptoSetupServer(
|
||||||
connID protocol.ConnectionID,
|
connID protocol.ConnectionID,
|
||||||
localAddr net.Addr,
|
localAddr net.Addr,
|
||||||
remoteAddr net.Addr,
|
remoteAddr net.Addr,
|
||||||
tp *TransportParameters,
|
tp *wire.TransportParameters,
|
||||||
runner handshakeRunner,
|
runner handshakeRunner,
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
|
@ -190,7 +191,7 @@ func newCryptoSetup(
|
||||||
initialStream io.Writer,
|
initialStream io.Writer,
|
||||||
handshakeStream io.Writer,
|
handshakeStream io.Writer,
|
||||||
connID protocol.ConnectionID,
|
connID protocol.ConnectionID,
|
||||||
tp *TransportParameters,
|
tp *wire.TransportParameters,
|
||||||
runner handshakeRunner,
|
runner handshakeRunner,
|
||||||
tlsConf *tls.Config,
|
tlsConf *tls.Config,
|
||||||
enable0RTT bool,
|
enable0RTT bool,
|
||||||
|
@ -198,7 +199,7 @@ func newCryptoSetup(
|
||||||
qlogger qlog.Tracer,
|
qlogger qlog.Tracer,
|
||||||
logger utils.Logger,
|
logger utils.Logger,
|
||||||
perspective protocol.Perspective,
|
perspective protocol.Perspective,
|
||||||
) (*cryptoSetup, <-chan *TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
) (*cryptoSetup, <-chan *wire.TransportParameters /* ClientHello written. Receive nil for non-0-RTT */) {
|
||||||
initialSealer, initialOpener := NewInitialAEAD(connID, perspective)
|
initialSealer, initialOpener := NewInitialAEAD(connID, perspective)
|
||||||
if qlogger != nil {
|
if qlogger != nil {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
@ -223,7 +224,7 @@ func newCryptoSetup(
|
||||||
perspective: perspective,
|
perspective: perspective,
|
||||||
handshakeDone: make(chan struct{}),
|
handshakeDone: make(chan struct{}),
|
||||||
alertChan: make(chan uint8),
|
alertChan: make(chan uint8),
|
||||||
clientHelloWrittenChan: make(chan *TransportParameters, 1),
|
clientHelloWrittenChan: make(chan *wire.TransportParameters, 1),
|
||||||
messageChan: make(chan []byte, 100),
|
messageChan: make(chan []byte, 100),
|
||||||
receivedReadKey: make(chan struct{}),
|
receivedReadKey: make(chan struct{}),
|
||||||
receivedWriteKey: make(chan struct{}),
|
receivedWriteKey: make(chan struct{}),
|
||||||
|
@ -448,7 +449,7 @@ func (h *cryptoSetup) handleMessageForClient(msgType messageType) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *cryptoSetup) handleTransportParameters(data []byte) {
|
func (h *cryptoSetup) handleTransportParameters(data []byte) {
|
||||||
var tp TransportParameters
|
var tp wire.TransportParameters
|
||||||
if err := tp.Unmarshal(data, h.perspective.Opposite()); err != nil {
|
if err := tp.Unmarshal(data, h.perspective.Opposite()); err != nil {
|
||||||
h.runner.OnError(qerr.Error(qerr.TransportParameterError, err.Error()))
|
h.runner.OnError(qerr.Error(qerr.TransportParameterError, err.Error()))
|
||||||
}
|
}
|
||||||
|
@ -472,17 +473,9 @@ func (h *cryptoSetup) handlePeerParamsFromSessionState(data []byte) {
|
||||||
h.zeroRTTParameters = tp
|
h.zeroRTTParameters = tp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *cryptoSetup) handlePeerParamsFromSessionStateImpl(data []byte) (*TransportParameters, error) {
|
func (h *cryptoSetup) handlePeerParamsFromSessionStateImpl(data []byte) (*wire.TransportParameters, error) {
|
||||||
r := bytes.NewReader(data)
|
var tp wire.TransportParameters
|
||||||
version, err := utils.ReadVarInt(r)
|
if err := tp.UnmarshalFromSessionTicket(data); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if version != transportParameterMarshalingVersion {
|
|
||||||
return nil, fmt.Errorf("unknown transport parameter marshaling version: %d", version)
|
|
||||||
}
|
|
||||||
var tp TransportParameters
|
|
||||||
if err := tp.Unmarshal(data[len(data)-r.Len():], protocol.PerspectiveServer); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &tp, nil
|
return &tp, nil
|
||||||
|
|
|
@ -11,14 +11,16 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/testdata"
|
"github.com/lucas-clemente/quic-go/internal/testdata"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/marten-seemann/qtls"
|
"github.com/marten-seemann/qtls"
|
||||||
|
|
||||||
|
"github.com/golang/mock/gomock"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
@ -92,7 +94,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
NewMockHandshakeRunner(mockCtrl),
|
NewMockHandshakeRunner(mockCtrl),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
false,
|
false,
|
||||||
|
@ -125,7 +127,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
runner,
|
runner,
|
||||||
testdata.GetTLSConfig(),
|
testdata.GetTLSConfig(),
|
||||||
false,
|
false,
|
||||||
|
@ -164,7 +166,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
runner,
|
runner,
|
||||||
testdata.GetTLSConfig(),
|
testdata.GetTLSConfig(),
|
||||||
false,
|
false,
|
||||||
|
@ -206,7 +208,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
runner,
|
runner,
|
||||||
serverConf,
|
serverConf,
|
||||||
false,
|
false,
|
||||||
|
@ -241,7 +243,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
NewMockHandshakeRunner(mockCtrl),
|
NewMockHandshakeRunner(mockCtrl),
|
||||||
serverConf,
|
serverConf,
|
||||||
false,
|
false,
|
||||||
|
@ -336,7 +338,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
cRunner,
|
cRunner,
|
||||||
clientConf,
|
clientConf,
|
||||||
enable0RTT,
|
enable0RTT,
|
||||||
|
@ -359,7 +361,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{StatelessResetToken: &token},
|
&wire.TransportParameters{StatelessResetToken: &token},
|
||||||
sRunner,
|
sRunner,
|
||||||
serverConf,
|
serverConf,
|
||||||
enable0RTT,
|
enable0RTT,
|
||||||
|
@ -413,7 +415,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
runner,
|
runner,
|
||||||
&tls.Config{InsecureSkipVerify: true},
|
&tls.Config{InsecureSkipVerify: true},
|
||||||
false,
|
false,
|
||||||
|
@ -443,11 +445,11 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("receives transport parameters", func() {
|
It("receives transport parameters", func() {
|
||||||
var cTransportParametersRcvd, sTransportParametersRcvd *TransportParameters
|
var cTransportParametersRcvd, sTransportParametersRcvd *wire.TransportParameters
|
||||||
cChunkChan, cInitialStream, cHandshakeStream := initStreams()
|
cChunkChan, cInitialStream, cHandshakeStream := initStreams()
|
||||||
cTransportParameters := &TransportParameters{MaxIdleTimeout: 0x42 * time.Second}
|
cTransportParameters := &wire.TransportParameters{MaxIdleTimeout: 0x42 * time.Second}
|
||||||
cRunner := NewMockHandshakeRunner(mockCtrl)
|
cRunner := NewMockHandshakeRunner(mockCtrl)
|
||||||
cRunner.EXPECT().OnReceivedParams(gomock.Any()).Do(func(tp *TransportParameters) { sTransportParametersRcvd = tp })
|
cRunner.EXPECT().OnReceivedParams(gomock.Any()).Do(func(tp *wire.TransportParameters) { sTransportParametersRcvd = tp })
|
||||||
cRunner.EXPECT().OnHandshakeComplete()
|
cRunner.EXPECT().OnHandshakeComplete()
|
||||||
client, _ := NewCryptoSetupClient(
|
client, _ := NewCryptoSetupClient(
|
||||||
cInitialStream,
|
cInitialStream,
|
||||||
|
@ -467,9 +469,9 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
sChunkChan, sInitialStream, sHandshakeStream := initStreams()
|
sChunkChan, sInitialStream, sHandshakeStream := initStreams()
|
||||||
var token [16]byte
|
var token [16]byte
|
||||||
sRunner := NewMockHandshakeRunner(mockCtrl)
|
sRunner := NewMockHandshakeRunner(mockCtrl)
|
||||||
sRunner.EXPECT().OnReceivedParams(gomock.Any()).Do(func(tp *TransportParameters) { cTransportParametersRcvd = tp })
|
sRunner.EXPECT().OnReceivedParams(gomock.Any()).Do(func(tp *wire.TransportParameters) { cTransportParametersRcvd = tp })
|
||||||
sRunner.EXPECT().OnHandshakeComplete()
|
sRunner.EXPECT().OnHandshakeComplete()
|
||||||
sTransportParameters := &TransportParameters{
|
sTransportParameters := &wire.TransportParameters{
|
||||||
MaxIdleTimeout: 0x1337 * time.Second,
|
MaxIdleTimeout: 0x1337 * time.Second,
|
||||||
StatelessResetToken: &token,
|
StatelessResetToken: &token,
|
||||||
}
|
}
|
||||||
|
@ -512,7 +514,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
cRunner,
|
cRunner,
|
||||||
clientConf,
|
clientConf,
|
||||||
false,
|
false,
|
||||||
|
@ -531,7 +533,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
sRunner,
|
sRunner,
|
||||||
serverConf,
|
serverConf,
|
||||||
false,
|
false,
|
||||||
|
@ -571,7 +573,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
cRunner,
|
cRunner,
|
||||||
clientConf,
|
clientConf,
|
||||||
false,
|
false,
|
||||||
|
@ -590,7 +592,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
sRunner,
|
sRunner,
|
||||||
serverConf,
|
serverConf,
|
||||||
false,
|
false,
|
||||||
|
@ -702,7 +704,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
cRunner,
|
cRunner,
|
||||||
clientConf,
|
clientConf,
|
||||||
true,
|
true,
|
||||||
|
@ -721,7 +723,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
sRunner,
|
sRunner,
|
||||||
serverConf,
|
serverConf,
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
"github.com/marten-seemann/qtls"
|
"github.com/marten-seemann/qtls"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ type tlsExtensionHandler interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type handshakeRunner interface {
|
type handshakeRunner interface {
|
||||||
OnReceivedParams(*TransportParameters)
|
OnReceivedParams(*wire.TransportParameters)
|
||||||
OnHandshakeComplete()
|
OnHandshakeComplete()
|
||||||
OnError(error)
|
OnError(error)
|
||||||
DropKeys(protocol.EncryptionLevel)
|
DropKeys(protocol.EncryptionLevel)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockHandshakeRunner is a mock of HandshakeRunner interface
|
// MockHandshakeRunner is a mock of HandshakeRunner interface
|
||||||
|
@ -71,7 +72,7 @@ func (mr *MockHandshakeRunnerMockRecorder) OnHandshakeComplete() *gomock.Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnReceivedParams mocks base method
|
// OnReceivedParams mocks base method
|
||||||
func (m *MockHandshakeRunner) OnReceivedParams(arg0 *TransportParameters) {
|
func (m *MockHandshakeRunner) OnReceivedParams(arg0 *wire.TransportParameters) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "OnReceivedParams", arg0)
|
m.ctrl.Call(m, "OnReceivedParams", arg0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
const sessionTicketRevision = 2
|
const sessionTicketRevision = 2
|
||||||
|
|
||||||
type sessionTicket struct {
|
type sessionTicket struct {
|
||||||
Parameters *TransportParameters
|
Parameters *wire.TransportParameters
|
||||||
RTT time.Duration // to be encoded in mus
|
RTT time.Duration // to be encoded in mus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ func (t *sessionTicket) Unmarshal(b []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("failed to read RTT")
|
return errors.New("failed to read RTT")
|
||||||
}
|
}
|
||||||
var tp TransportParameters
|
var tp wire.TransportParameters
|
||||||
if err := tp.UnmarshalFromSessionTicket(b[len(b)-r.Len():]); err != nil {
|
if err := tp.UnmarshalFromSessionTicket(b[len(b)-r.Len():]); err != nil {
|
||||||
return fmt.Errorf("unmarshaling transport parameters from session ticket failed: %s", err.Error())
|
return fmt.Errorf("unmarshaling transport parameters from session ticket failed: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
@ -13,7 +14,7 @@ import (
|
||||||
var _ = Describe("Session Ticket", func() {
|
var _ = Describe("Session Ticket", func() {
|
||||||
It("marshals and unmarshals a session ticket", func() {
|
It("marshals and unmarshals a session ticket", func() {
|
||||||
ticket := &sessionTicket{
|
ticket := &sessionTicket{
|
||||||
Parameters: &TransportParameters{
|
Parameters: &wire.TransportParameters{
|
||||||
InitialMaxStreamDataBidiLocal: 1,
|
InitialMaxStreamDataBidiLocal: 1,
|
||||||
InitialMaxStreamDataBidiRemote: 2,
|
InitialMaxStreamDataBidiRemote: 2,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package handshake
|
package wire
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -39,7 +39,7 @@ var _ = Describe("Transport Parameters", func() {
|
||||||
StatelessResetToken: &[16]byte{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00},
|
StatelessResetToken: &[16]byte{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00},
|
||||||
ActiveConnectionIDLimit: 123,
|
ActiveConnectionIDLimit: 123,
|
||||||
}
|
}
|
||||||
Expect(p.String()).To(Equal("&handshake.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 0x1234, InitialMaxStreamDataBidiRemote: 0x2345, InitialMaxStreamDataUni: 0x3456, InitialMaxData: 0x4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37ms, ActiveConnectionIDLimit: 123, StatelessResetToken: 0x112233445566778899aabbccddeeff00}"))
|
Expect(p.String()).To(Equal("&wire.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 0x1234, InitialMaxStreamDataBidiRemote: 0x2345, InitialMaxStreamDataUni: 0x3456, InitialMaxData: 0x4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37ms, ActiveConnectionIDLimit: 123, StatelessResetToken: 0x112233445566778899aabbccddeeff00}"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("has a string representation, if there's no stateless reset token", func() {
|
It("has a string representation, if there's no stateless reset token", func() {
|
||||||
|
@ -56,7 +56,7 @@ var _ = Describe("Transport Parameters", func() {
|
||||||
MaxAckDelay: 37 * time.Second,
|
MaxAckDelay: 37 * time.Second,
|
||||||
ActiveConnectionIDLimit: 89,
|
ActiveConnectionIDLimit: 89,
|
||||||
}
|
}
|
||||||
Expect(p.String()).To(Equal("&handshake.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 0x1234, InitialMaxStreamDataBidiRemote: 0x2345, InitialMaxStreamDataUni: 0x3456, InitialMaxData: 0x4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37s, ActiveConnectionIDLimit: 89}"))
|
Expect(p.String()).To(Equal("&wire.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 0x1234, InitialMaxStreamDataBidiRemote: 0x2345, InitialMaxStreamDataUni: 0x3456, InitialMaxData: 0x4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37s, ActiveConnectionIDLimit: 89}"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("marshals and unmarshals", func() {
|
It("marshals and unmarshals", func() {
|
|
@ -1,4 +1,4 @@
|
||||||
package handshake
|
package wire
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -413,7 +413,7 @@ func (p *TransportParameters) ValidFor0RTT(tp *TransportParameters) bool {
|
||||||
|
|
||||||
// String returns a string representation, intended for logging.
|
// String returns a string representation, intended for logging.
|
||||||
func (p *TransportParameters) String() string {
|
func (p *TransportParameters) String() string {
|
||||||
logString := "&handshake.TransportParameters{OriginalConnectionID: %s, InitialMaxStreamDataBidiLocal: %#x, InitialMaxStreamDataBidiRemote: %#x, InitialMaxStreamDataUni: %#x, InitialMaxData: %#x, MaxBidiStreamNum: %d, MaxUniStreamNum: %d, MaxIdleTimeout: %s, AckDelayExponent: %d, MaxAckDelay: %s, ActiveConnectionIDLimit: %d"
|
logString := "&wire.TransportParameters{OriginalConnectionID: %s, InitialMaxStreamDataBidiLocal: %#x, InitialMaxStreamDataBidiRemote: %#x, InitialMaxStreamDataUni: %#x, InitialMaxData: %#x, MaxBidiStreamNum: %d, MaxUniStreamNum: %d, MaxIdleTimeout: %s, AckDelayExponent: %d, MaxAckDelay: %s, ActiveConnectionIDLimit: %d"
|
||||||
logParams := []interface{}{p.OriginalConnectionID, p.InitialMaxStreamDataBidiLocal, p.InitialMaxStreamDataBidiRemote, p.InitialMaxStreamDataUni, p.InitialMaxData, p.MaxBidiStreamNum, p.MaxUniStreamNum, p.MaxIdleTimeout, p.AckDelayExponent, p.MaxAckDelay, p.ActiveConnectionIDLimit}
|
logParams := []interface{}{p.OriginalConnectionID, p.InitialMaxStreamDataBidiLocal, p.InitialMaxStreamDataBidiRemote, p.InitialMaxStreamDataUni, p.InitialMaxData, p.MaxBidiStreamNum, p.MaxUniStreamNum, p.MaxIdleTimeout, p.AckDelayExponent, p.MaxAckDelay, p.ActiveConnectionIDLimit}
|
||||||
if p.StatelessResetToken != nil { // the client never sends a stateless reset token
|
if p.StatelessResetToken != nil { // the client never sends a stateless reset token
|
||||||
logString += ", StatelessResetToken: %#x"
|
logString += ", StatelessResetToken: %#x"
|
|
@ -8,9 +8,9 @@ import (
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
handshake "github.com/lucas-clemente/quic-go/internal/handshake"
|
|
||||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
qerr "github.com/lucas-clemente/quic-go/internal/qerr"
|
qerr "github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
|
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockPacker is a mock of Packer interface
|
// MockPacker is a mock of Packer interface
|
||||||
|
@ -37,7 +37,7 @@ func (m *MockPacker) EXPECT() *MockPackerMockRecorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleTransportParameters mocks base method
|
// HandleTransportParameters mocks base method
|
||||||
func (m *MockPacker) HandleTransportParameters(arg0 *handshake.TransportParameters) {
|
func (m *MockPacker) HandleTransportParameters(arg0 *wire.TransportParameters) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "HandleTransportParameters", arg0)
|
m.ctrl.Call(m, "HandleTransportParameters", arg0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
handshake "github.com/lucas-clemente/quic-go/internal/handshake"
|
|
||||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
)
|
)
|
||||||
|
@ -198,7 +197,7 @@ func (mr *MockStreamManagerMockRecorder) OpenUniStreamSync(arg0 interface{}) *go
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateLimits mocks base method
|
// UpdateLimits mocks base method
|
||||||
func (m *MockStreamManager) UpdateLimits(arg0 *handshake.TransportParameters) error {
|
func (m *MockStreamManager) UpdateLimits(arg0 *wire.TransportParameters) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "UpdateLimits", arg0)
|
ret := m.ctrl.Call(m, "UpdateLimits", arg0)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
|
|
|
@ -23,7 +23,7 @@ type packer interface {
|
||||||
MaybePackAckPacket(handshakeConfirmed bool) (*packedPacket, error)
|
MaybePackAckPacket(handshakeConfirmed bool) (*packedPacket, error)
|
||||||
PackConnectionClose(*qerr.QuicError) (*coalescedPacket, error)
|
PackConnectionClose(*qerr.QuicError) (*coalescedPacket, error)
|
||||||
|
|
||||||
HandleTransportParameters(*handshake.TransportParameters)
|
HandleTransportParameters(*wire.TransportParameters)
|
||||||
SetToken([]byte)
|
SetToken([]byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,7 +738,7 @@ func (p *packetPacker) SetToken(token []byte) {
|
||||||
p.token = token
|
p.token = token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *packetPacker) HandleTransportParameters(params *handshake.TransportParameters) {
|
func (p *packetPacker) HandleTransportParameters(params *wire.TransportParameters) {
|
||||||
if params.MaxPacketSize != 0 {
|
if params.MaxPacketSize != 0 {
|
||||||
p.maxPacketSize = utils.MinByteCount(p.maxPacketSize, params.MaxPacketSize)
|
p.maxPacketSize = utils.MinByteCount(p.maxPacketSize, params.MaxPacketSize)
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,7 +731,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
_, err := packer.PackPacket()
|
_, err := packer.PackPacket()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
// now reduce the maxPacketSize
|
// now reduce the maxPacketSize
|
||||||
packer.HandleTransportParameters(&handshake.TransportParameters{
|
packer.HandleTransportParameters(&wire.TransportParameters{
|
||||||
MaxPacketSize: maxPacketSize - 10,
|
MaxPacketSize: maxPacketSize - 10,
|
||||||
})
|
})
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any()).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount) ([]ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any()).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
|
@ -756,7 +756,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
_, err := packer.PackPacket()
|
_, err := packer.PackPacket()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
// now try to increase the maxPacketSize
|
// now try to increase the maxPacketSize
|
||||||
packer.HandleTransportParameters(&handshake.TransportParameters{
|
packer.HandleTransportParameters(&wire.TransportParameters{
|
||||||
MaxPacketSize: maxPacketSize + 10,
|
MaxPacketSize: maxPacketSize + 10,
|
||||||
})
|
})
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any()).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount) ([]ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any()).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
|
|
|
@ -295,7 +295,7 @@ var _ = Describe("Server", func() {
|
||||||
destConnID := protocol.ConnectionID{1, 2, 3, 4, 5, 6}
|
destConnID := protocol.ConnectionID{1, 2, 3, 4, 5, 6}
|
||||||
packet := getPacket(&wire.Header{
|
packet := getPacket(&wire.Header{
|
||||||
IsLongHeader: true,
|
IsLongHeader: true,
|
||||||
Type: protocol.PacketTypeInitial,
|
Type: protocol.PacketTypeHandshake,
|
||||||
SrcConnectionID: srcConnID,
|
SrcConnectionID: srcConnID,
|
||||||
DestConnectionID: destConnID,
|
DestConnectionID: destConnID,
|
||||||
Version: 0x42,
|
Version: 0x42,
|
||||||
|
|
16
session.go
16
session.go
|
@ -43,7 +43,7 @@ type streamManager interface {
|
||||||
AcceptStream(context.Context) (Stream, error)
|
AcceptStream(context.Context) (Stream, error)
|
||||||
AcceptUniStream(context.Context) (ReceiveStream, error)
|
AcceptUniStream(context.Context) (ReceiveStream, error)
|
||||||
DeleteStream(protocol.StreamID) error
|
DeleteStream(protocol.StreamID) error
|
||||||
UpdateLimits(*handshake.TransportParameters) error
|
UpdateLimits(*wire.TransportParameters) error
|
||||||
HandleMaxStreamsFrame(*wire.MaxStreamsFrame) error
|
HandleMaxStreamsFrame(*wire.MaxStreamsFrame) error
|
||||||
CloseWithError(error)
|
CloseWithError(error)
|
||||||
}
|
}
|
||||||
|
@ -87,13 +87,13 @@ type sessionRunner interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type handshakeRunner struct {
|
type handshakeRunner struct {
|
||||||
onReceivedParams func(*handshake.TransportParameters)
|
onReceivedParams func(*wire.TransportParameters)
|
||||||
onError func(error)
|
onError func(error)
|
||||||
dropKeys func(protocol.EncryptionLevel)
|
dropKeys func(protocol.EncryptionLevel)
|
||||||
onHandshakeComplete func()
|
onHandshakeComplete func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *handshakeRunner) OnReceivedParams(tp *handshake.TransportParameters) { r.onReceivedParams(tp) }
|
func (r *handshakeRunner) OnReceivedParams(tp *wire.TransportParameters) { r.onReceivedParams(tp) }
|
||||||
func (r *handshakeRunner) OnError(e error) { r.onError(e) }
|
func (r *handshakeRunner) OnError(e error) { r.onError(e) }
|
||||||
func (r *handshakeRunner) DropKeys(el protocol.EncryptionLevel) { r.dropKeys(el) }
|
func (r *handshakeRunner) DropKeys(el protocol.EncryptionLevel) { r.dropKeys(el) }
|
||||||
func (r *handshakeRunner) OnHandshakeComplete() { r.onHandshakeComplete() }
|
func (r *handshakeRunner) OnHandshakeComplete() { r.onHandshakeComplete() }
|
||||||
|
@ -160,7 +160,7 @@ type session struct {
|
||||||
|
|
||||||
undecryptablePackets []*receivedPacket
|
undecryptablePackets []*receivedPacket
|
||||||
|
|
||||||
clientHelloWritten <-chan *handshake.TransportParameters
|
clientHelloWritten <-chan *wire.TransportParameters
|
||||||
earlySessionReadyChan chan struct{}
|
earlySessionReadyChan chan struct{}
|
||||||
handshakeCompleteChan chan struct{} // is closed when the handshake completes
|
handshakeCompleteChan chan struct{} // is closed when the handshake completes
|
||||||
handshakeComplete bool
|
handshakeComplete bool
|
||||||
|
@ -178,7 +178,7 @@ type session struct {
|
||||||
// pacingDeadline is the time when the next packet should be sent
|
// pacingDeadline is the time when the next packet should be sent
|
||||||
pacingDeadline time.Time
|
pacingDeadline time.Time
|
||||||
|
|
||||||
peerParams *handshake.TransportParameters
|
peerParams *wire.TransportParameters
|
||||||
|
|
||||||
timer *utils.Timer
|
timer *utils.Timer
|
||||||
// keepAlivePingSent stores whether a keep alive PING is in flight.
|
// keepAlivePingSent stores whether a keep alive PING is in flight.
|
||||||
|
@ -260,7 +260,7 @@ var newSession = func(
|
||||||
)
|
)
|
||||||
initialStream := newCryptoStream()
|
initialStream := newCryptoStream()
|
||||||
handshakeStream := newCryptoStream()
|
handshakeStream := newCryptoStream()
|
||||||
params := &handshake.TransportParameters{
|
params := &wire.TransportParameters{
|
||||||
InitialMaxStreamDataBidiLocal: protocol.InitialMaxStreamData,
|
InitialMaxStreamDataBidiLocal: protocol.InitialMaxStreamData,
|
||||||
InitialMaxStreamDataBidiRemote: protocol.InitialMaxStreamData,
|
InitialMaxStreamDataBidiRemote: protocol.InitialMaxStreamData,
|
||||||
InitialMaxStreamDataUni: protocol.InitialMaxStreamData,
|
InitialMaxStreamDataUni: protocol.InitialMaxStreamData,
|
||||||
|
@ -374,7 +374,7 @@ var newClientSession = func(
|
||||||
)
|
)
|
||||||
initialStream := newCryptoStream()
|
initialStream := newCryptoStream()
|
||||||
handshakeStream := newCryptoStream()
|
handshakeStream := newCryptoStream()
|
||||||
params := &handshake.TransportParameters{
|
params := &wire.TransportParameters{
|
||||||
InitialMaxStreamDataBidiRemote: protocol.InitialMaxStreamData,
|
InitialMaxStreamDataBidiRemote: protocol.InitialMaxStreamData,
|
||||||
InitialMaxStreamDataBidiLocal: protocol.InitialMaxStreamData,
|
InitialMaxStreamDataBidiLocal: protocol.InitialMaxStreamData,
|
||||||
InitialMaxStreamDataUni: protocol.InitialMaxStreamData,
|
InitialMaxStreamDataUni: protocol.InitialMaxStreamData,
|
||||||
|
@ -1169,7 +1169,7 @@ func (s *session) dropEncryptionLevel(encLevel protocol.EncryptionLevel) {
|
||||||
s.receivedPacketHandler.DropPackets(encLevel)
|
s.receivedPacketHandler.DropPackets(encLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) processTransportParameters(params *handshake.TransportParameters) {
|
func (s *session) processTransportParameters(params *wire.TransportParameters) {
|
||||||
// check the Retry token
|
// check the Retry token
|
||||||
if s.perspective == protocol.PerspectiveClient && !params.OriginalConnectionID.Equal(s.origDestConnID) {
|
if s.perspective == protocol.PerspectiveClient && !params.OriginalConnectionID.Equal(s.origDestConnID) {
|
||||||
s.closeLocal(qerr.Error(qerr.TransportParameterError, fmt.Sprintf("expected original_connection_id to equal %s, is %s", s.origDestConnID, params.OriginalConnectionID)))
|
s.closeLocal(qerr.Error(qerr.TransportParameterError, fmt.Sprintf("expected original_connection_id to equal %s, is %s", s.origDestConnID, params.OriginalConnectionID)))
|
||||||
|
|
|
@ -1430,7 +1430,7 @@ var _ = Describe("Session", func() {
|
||||||
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
|
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
|
||||||
sess.run()
|
sess.run()
|
||||||
}()
|
}()
|
||||||
params := &handshake.TransportParameters{
|
params := &wire.TransportParameters{
|
||||||
MaxIdleTimeout: 90 * time.Second,
|
MaxIdleTimeout: 90 * time.Second,
|
||||||
InitialMaxStreamDataBidiLocal: 0x5000,
|
InitialMaxStreamDataBidiLocal: 0x5000,
|
||||||
InitialMaxData: 0x5000,
|
InitialMaxData: 0x5000,
|
||||||
|
@ -1465,7 +1465,7 @@ var _ = Describe("Session", func() {
|
||||||
setRemoteIdleTimeout := func(t time.Duration) {
|
setRemoteIdleTimeout := func(t time.Duration) {
|
||||||
streamManager.EXPECT().UpdateLimits(gomock.Any())
|
streamManager.EXPECT().UpdateLimits(gomock.Any())
|
||||||
packer.EXPECT().HandleTransportParameters(gomock.Any())
|
packer.EXPECT().HandleTransportParameters(gomock.Any())
|
||||||
sess.processTransportParameters(&handshake.TransportParameters{MaxIdleTimeout: t})
|
sess.processTransportParameters(&wire.TransportParameters{MaxIdleTimeout: t})
|
||||||
}
|
}
|
||||||
|
|
||||||
runSession := func() {
|
runSession := func() {
|
||||||
|
@ -1956,8 +1956,8 @@ var _ = Describe("Client Session", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("uses the preferred_address connection ID", func() {
|
It("uses the preferred_address connection ID", func() {
|
||||||
params := &handshake.TransportParameters{
|
params := &wire.TransportParameters{
|
||||||
PreferredAddress: &handshake.PreferredAddress{
|
PreferredAddress: &wire.PreferredAddress{
|
||||||
IPv4: net.IPv4(127, 0, 0, 1),
|
IPv4: net.IPv4(127, 0, 0, 1),
|
||||||
IPv6: net.IP{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
IPv6: net.IP{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
||||||
ConnectionID: protocol.ConnectionID{1, 2, 3, 4},
|
ConnectionID: protocol.ConnectionID{1, 2, 3, 4},
|
||||||
|
@ -1979,7 +1979,7 @@ var _ = Describe("Client Session", func() {
|
||||||
|
|
||||||
It("uses the minimum of the peers' idle timeouts", func() {
|
It("uses the minimum of the peers' idle timeouts", func() {
|
||||||
sess.config.MaxIdleTimeout = 19 * time.Second
|
sess.config.MaxIdleTimeout = 19 * time.Second
|
||||||
params := &handshake.TransportParameters{
|
params := &wire.TransportParameters{
|
||||||
MaxIdleTimeout: 18 * time.Second,
|
MaxIdleTimeout: 18 * time.Second,
|
||||||
}
|
}
|
||||||
packer.EXPECT().HandleTransportParameters(gomock.Any())
|
packer.EXPECT().HandleTransportParameters(gomock.Any())
|
||||||
|
@ -1989,7 +1989,7 @@ var _ = Describe("Client Session", func() {
|
||||||
|
|
||||||
It("errors if the TransportParameters contain an original_connection_id, although no Retry was performed", func() {
|
It("errors if the TransportParameters contain an original_connection_id, although no Retry was performed", func() {
|
||||||
expectClose()
|
expectClose()
|
||||||
sess.processTransportParameters(&handshake.TransportParameters{
|
sess.processTransportParameters(&wire.TransportParameters{
|
||||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
OriginalConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
||||||
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
||||||
})
|
})
|
||||||
|
@ -1999,7 +1999,7 @@ var _ = Describe("Client Session", func() {
|
||||||
It("errors if the TransportParameters contain a wrong original_connection_id", func() {
|
It("errors if the TransportParameters contain a wrong original_connection_id", func() {
|
||||||
sess.origDestConnID = protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}
|
sess.origDestConnID = protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}
|
||||||
expectClose()
|
expectClose()
|
||||||
sess.processTransportParameters(&handshake.TransportParameters{
|
sess.processTransportParameters(&wire.TransportParameters{
|
||||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
OriginalConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
||||||
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
|
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/handshake"
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
@ -223,7 +222,7 @@ func (m *streamsMap) HandleMaxStreamsFrame(f *wire.MaxStreamsFrame) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *streamsMap) UpdateLimits(p *handshake.TransportParameters) error {
|
func (m *streamsMap) UpdateLimits(p *wire.TransportParameters) error {
|
||||||
if p.MaxBidiStreamNum > protocol.MaxStreamCount ||
|
if p.MaxBidiStreamNum > protocol.MaxStreamCount ||
|
||||||
p.MaxUniStreamNum > protocol.MaxStreamCount {
|
p.MaxUniStreamNum > protocol.MaxStreamCount {
|
||||||
return qerr.StreamLimitError
|
return qerr.StreamLimitError
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
|
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/handshake"
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
"github.com/lucas-clemente/quic-go/internal/mocks"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
|
@ -81,7 +80,7 @@ var _ = Describe("Streams Map", func() {
|
||||||
)
|
)
|
||||||
|
|
||||||
allowUnlimitedStreams := func() {
|
allowUnlimitedStreams := func() {
|
||||||
m.UpdateLimits(&handshake.TransportParameters{
|
m.UpdateLimits(&wire.TransportParameters{
|
||||||
MaxBidiStreamNum: protocol.MaxStreamCount,
|
MaxBidiStreamNum: protocol.MaxStreamCount,
|
||||||
MaxUniStreamNum: protocol.MaxStreamCount,
|
MaxUniStreamNum: protocol.MaxStreamCount,
|
||||||
})
|
})
|
||||||
|
@ -331,7 +330,7 @@ var _ = Describe("Streams Map", func() {
|
||||||
m.perspective = pers
|
m.perspective = pers
|
||||||
_, err := m.OpenStream()
|
_, err := m.OpenStream()
|
||||||
expectTooManyStreamsError(err)
|
expectTooManyStreamsError(err)
|
||||||
Expect(m.UpdateLimits(&handshake.TransportParameters{
|
Expect(m.UpdateLimits(&wire.TransportParameters{
|
||||||
MaxBidiStreamNum: 5,
|
MaxBidiStreamNum: 5,
|
||||||
MaxUniStreamNum: 8,
|
MaxUniStreamNum: 8,
|
||||||
})).To(Succeed())
|
})).To(Succeed())
|
||||||
|
@ -357,13 +356,13 @@ var _ = Describe("Streams Map", func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
It("rejects parameters with too large unidirectional stream counts", func() {
|
It("rejects parameters with too large unidirectional stream counts", func() {
|
||||||
Expect(m.UpdateLimits(&handshake.TransportParameters{
|
Expect(m.UpdateLimits(&wire.TransportParameters{
|
||||||
MaxUniStreamNum: protocol.MaxStreamCount + 1,
|
MaxUniStreamNum: protocol.MaxStreamCount + 1,
|
||||||
})).To(MatchError(qerr.StreamLimitError))
|
})).To(MatchError(qerr.StreamLimitError))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects parameters with too large unidirectional stream counts", func() {
|
It("rejects parameters with too large unidirectional stream counts", func() {
|
||||||
Expect(m.UpdateLimits(&handshake.TransportParameters{
|
Expect(m.UpdateLimits(&wire.TransportParameters{
|
||||||
MaxBidiStreamNum: protocol.MaxStreamCount + 1,
|
MaxBidiStreamNum: protocol.MaxStreamCount + 1,
|
||||||
})).To(MatchError(qerr.StreamLimitError))
|
})).To(MatchError(qerr.StreamLimitError))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue