diff --git a/client.go b/client.go index 3446799e7..4f7cc184f 100644 --- a/client.go +++ b/client.go @@ -169,9 +169,11 @@ func (c *client) dialTLS() error { params := &handshake.TransportParameters{ StreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow, ConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow, - MaxStreams: protocol.MaxIncomingStreams, IdleTimeout: c.config.IdleTimeout, OmitConnectionID: c.config.RequestConnectionIDOmission, + // TODO(#1150): set reasonable limits + MaxBidiStreamID: 0xffffffff, + MaxUniStreamID: 0xffffffff, } csc := handshake.NewCryptoStreamConn(nil) extHandler := handshake.NewExtensionHandlerClient(params, c.initialVersion, c.config.Versions, c.version) diff --git a/internal/handshake/tls_extension_handler_server.go b/internal/handshake/tls_extension_handler_server.go index 313751c9f..3e7e2705f 100644 --- a/internal/handshake/tls_extension_handler_server.go +++ b/internal/handshake/tls_extension_handler_server.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "fmt" - "math" "github.com/lucas-clemente/quic-go/qerr" @@ -105,8 +104,6 @@ func (h *extensionHandlerServer) Receive(hType mint.HandshakeType, el *mint.Exte if err != nil { return err } - // TODO(#878): remove this when implementing the MAX_STREAM_ID frame - params.MaxStreams = math.MaxUint32 h.paramsChan <- *params return nil } diff --git a/internal/handshake/transport_parameter_test.go b/internal/handshake/transport_parameter_test.go index 17f6c26c6..2de372f8c 100644 --- a/internal/handshake/transport_parameter_test.go +++ b/internal/handshake/transport_parameter_test.go @@ -127,6 +127,8 @@ var _ = Describe("Transport Parameters", func() { Expect(err).ToNot(HaveOccurred()) Expect(params.StreamFlowControlWindow).To(Equal(protocol.ByteCount(0x11223344))) Expect(params.ConnectionFlowControlWindow).To(Equal(protocol.ByteCount(0x22334455))) + Expect(params.MaxBidiStreamID).To(Equal(protocol.StreamID(0x33445566))) + Expect(params.MaxUniStreamID).To(Equal(protocol.StreamID(0x44556677))) Expect(params.IdleTimeout).To(Equal(0x1337 * time.Second)) Expect(params.OmitConnectionID).To(BeFalse()) }) @@ -224,18 +226,20 @@ var _ = Describe("Transport Parameters", func() { StreamFlowControlWindow: 0xdeadbeef, ConnectionFlowControlWindow: 0xdecafbad, IdleTimeout: 0xcafe * time.Second, + MaxBidiStreamID: 0xbadf000d, + MaxUniStreamID: 0xface, } }) It("creates the parameters list", func() { values := paramsListToMap(params.getTransportParameters()) - Expect(values).To(HaveLen(5)) + Expect(values).To(HaveLen(6)) Expect(values).To(HaveKeyWithValue(initialMaxStreamDataParameterID, []byte{0xde, 0xad, 0xbe, 0xef})) Expect(values).To(HaveKeyWithValue(initialMaxDataParameterID, []byte{0xde, 0xca, 0xfb, 0xad})) - Expect(values).To(HaveKeyWithValue(initialMaxStreamIDBiDiParameterID, []byte{0xff, 0xff, 0xff, 0xff})) + Expect(values).To(HaveKeyWithValue(initialMaxStreamIDBiDiParameterID, []byte{0xba, 0xdf, 0x00, 0x0d})) + Expect(values).To(HaveKeyWithValue(initialMaxStreamIDUniParameterID, []byte{0x0, 0x0, 0xfa, 0xce})) Expect(values).To(HaveKeyWithValue(idleTimeoutParameterID, []byte{0xca, 0xfe})) Expect(values).To(HaveKeyWithValue(maxPacketSizeParameterID, []byte{0x5, 0xac})) // 1452 = 0x5ac - Expect(values).ToNot(HaveKey(initialMaxStreamIDUniParameterID)) }) It("request ommision of the connection ID", func() { diff --git a/internal/handshake/transport_parameters.go b/internal/handshake/transport_parameters.go index e2d6df72e..a02835823 100644 --- a/internal/handshake/transport_parameters.go +++ b/internal/handshake/transport_parameters.go @@ -5,7 +5,6 @@ import ( "encoding/binary" "errors" "fmt" - "math" "time" "github.com/lucas-clemente/quic-go/internal/protocol" @@ -21,7 +20,9 @@ type TransportParameters struct { StreamFlowControlWindow protocol.ByteCount ConnectionFlowControlWindow protocol.ByteCount - MaxStreams uint32 + MaxBidiStreamID protocol.StreamID // only used for IETF QUIC + MaxUniStreamID protocol.StreamID // only used for IETF QUIC + MaxStreams uint32 // only used for gQUIC OmitConnectionID bool IdleTimeout time.Duration @@ -117,12 +118,14 @@ func readTransportParamters(paramsList []transportParameter) (*TransportParamete if len(p.Value) != 4 { return nil, fmt.Errorf("wrong length for initial_max_stream_id_bidi: %d (expected 4)", len(p.Value)) } - // TODO: handle this value + // TODO(#1154): validate the stream ID + params.MaxBidiStreamID = protocol.StreamID(binary.BigEndian.Uint32(p.Value)) case initialMaxStreamIDUniParameterID: if len(p.Value) != 4 { return nil, fmt.Errorf("wrong length for initial_max_stream_id_uni: %d (expected 4)", len(p.Value)) } - // TODO: handle this value + // TODO(#1154): validate the stream ID + params.MaxUniStreamID = protocol.StreamID(binary.BigEndian.Uint32(p.Value)) case idleTimeoutParameterID: foundIdleTimeout = true if len(p.Value) != 2 { @@ -150,9 +153,10 @@ func (p *TransportParameters) getTransportParameters() []transportParameter { binary.BigEndian.PutUint32(initialMaxStreamData, uint32(p.StreamFlowControlWindow)) initialMaxData := make([]byte, 4) binary.BigEndian.PutUint32(initialMaxData, uint32(p.ConnectionFlowControlWindow)) - initialMaxStreamIDBiDi := make([]byte, 4) - // TODO: use a reasonable value here - binary.BigEndian.PutUint32(initialMaxStreamIDBiDi, math.MaxUint32) + initialMaxBidiStreamID := make([]byte, 4) + binary.BigEndian.PutUint32(initialMaxBidiStreamID, uint32(p.MaxBidiStreamID)) + initialMaxUniStreamID := make([]byte, 4) + binary.BigEndian.PutUint32(initialMaxUniStreamID, uint32(p.MaxUniStreamID)) idleTimeout := make([]byte, 2) binary.BigEndian.PutUint16(idleTimeout, uint16(p.IdleTimeout/time.Second)) maxPacketSize := make([]byte, 2) @@ -160,7 +164,8 @@ func (p *TransportParameters) getTransportParameters() []transportParameter { params := []transportParameter{ {initialMaxStreamDataParameterID, initialMaxStreamData}, {initialMaxDataParameterID, initialMaxData}, - {initialMaxStreamIDBiDiParameterID, initialMaxStreamIDBiDi}, + {initialMaxStreamIDBiDiParameterID, initialMaxBidiStreamID}, + {initialMaxStreamIDUniParameterID, initialMaxUniStreamID}, {idleTimeoutParameterID, idleTimeout}, {maxPacketSizeParameterID, maxPacketSize}, } diff --git a/server_tls.go b/server_tls.go index ff766d067..1648459d5 100644 --- a/server_tls.go +++ b/server_tls.go @@ -66,8 +66,10 @@ func newServerTLS( params: &handshake.TransportParameters{ StreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow, ConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow, - MaxStreams: protocol.MaxIncomingStreams, IdleTimeout: config.IdleTimeout, + // TODO(#1150): set reasonable limits + MaxBidiStreamID: 0xffffffff, + MaxUniStreamID: 0xffffffff, }, } s.newMintConn = s.newMintConnImpl