forked from quic-go/quic-go
implement the disable_migration transport parameter and use it
This commit is contained in:
@@ -256,6 +256,7 @@ func (c *client) dialTLS(ctx context.Context) error {
|
|||||||
OmitConnectionID: c.config.RequestConnectionIDOmission,
|
OmitConnectionID: c.config.RequestConnectionIDOmission,
|
||||||
MaxBidiStreams: uint16(c.config.MaxIncomingStreams),
|
MaxBidiStreams: uint16(c.config.MaxIncomingStreams),
|
||||||
MaxUniStreams: uint16(c.config.MaxIncomingUniStreams),
|
MaxUniStreams: uint16(c.config.MaxIncomingUniStreams),
|
||||||
|
DisableMigration: true,
|
||||||
}
|
}
|
||||||
csc := handshake.NewCryptoStreamConn(nil)
|
csc := handshake.NewCryptoStreamConn(nil)
|
||||||
extHandler := handshake.NewExtensionHandlerClient(params, c.initialVersion, c.config.Versions, c.version, c.logger)
|
extHandler := handshake.NewExtensionHandlerClient(params, c.initialVersion, c.config.Versions, c.version, c.logger)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const (
|
|||||||
maxPacketSizeParameterID transportParameterID = 0x5
|
maxPacketSizeParameterID transportParameterID = 0x5
|
||||||
statelessResetTokenParameterID transportParameterID = 0x6
|
statelessResetTokenParameterID transportParameterID = 0x6
|
||||||
initialMaxUniStreamsParameterID transportParameterID = 0x8
|
initialMaxUniStreamsParameterID transportParameterID = 0x8
|
||||||
|
disableMigrationParameterID transportParameterID = 0x9
|
||||||
)
|
)
|
||||||
|
|
||||||
type transportParameter struct {
|
type transportParameter struct {
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ var _ = Describe("Transport Parameters", func() {
|
|||||||
initialMaxUniStreamsParameterID: {0x44, 0x55},
|
initialMaxUniStreamsParameterID: {0x44, 0x55},
|
||||||
idleTimeoutParameterID: {0x13, 0x37},
|
idleTimeoutParameterID: {0x13, 0x37},
|
||||||
maxPacketSizeParameterID: {0x73, 0x31},
|
maxPacketSizeParameterID: {0x73, 0x31},
|
||||||
|
disableMigrationParameterID: {},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
It("reads parameters", func() {
|
It("reads parameters", func() {
|
||||||
@@ -144,6 +145,7 @@ var _ = Describe("Transport Parameters", func() {
|
|||||||
Expect(params.IdleTimeout).To(Equal(0x1337 * time.Second))
|
Expect(params.IdleTimeout).To(Equal(0x1337 * time.Second))
|
||||||
Expect(params.OmitConnectionID).To(BeFalse())
|
Expect(params.OmitConnectionID).To(BeFalse())
|
||||||
Expect(params.MaxPacketSize).To(Equal(protocol.ByteCount(0x7331)))
|
Expect(params.MaxPacketSize).To(Equal(protocol.ByteCount(0x7331)))
|
||||||
|
Expect(params.DisableMigration).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects the parameters if the initial_max_stream_data is missing", func() {
|
It("rejects the parameters if the initial_max_stream_data is missing", func() {
|
||||||
@@ -215,6 +217,12 @@ var _ = Describe("Transport Parameters", func() {
|
|||||||
Expect(err).To(MatchError("invalid value for max_packet_size: 1199 (minimum 1200)"))
|
Expect(err).To(MatchError("invalid value for max_packet_size: 1199 (minimum 1200)"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("rejects the parameters if disable_connection_migration has the wrong length", func() {
|
||||||
|
parameters[disableMigrationParameterID] = []byte{0x11} // should empty
|
||||||
|
_, err := readTransportParameters(paramsMapToList(parameters))
|
||||||
|
Expect(err).To(MatchError("wrong length for disable_migration: 1 (expected empty)"))
|
||||||
|
})
|
||||||
|
|
||||||
It("ignores unknown parameters", func() {
|
It("ignores unknown parameters", func() {
|
||||||
parameters[1337] = []byte{42}
|
parameters[1337] = []byte{42}
|
||||||
_, err := readTransportParameters(paramsMapToList(parameters))
|
_, err := readTransportParameters(paramsMapToList(parameters))
|
||||||
@@ -240,18 +248,20 @@ var _ = Describe("Transport Parameters", func() {
|
|||||||
IdleTimeout: 0xcafe * time.Second,
|
IdleTimeout: 0xcafe * time.Second,
|
||||||
MaxBidiStreams: 0x1234,
|
MaxBidiStreams: 0x1234,
|
||||||
MaxUniStreams: 0x4321,
|
MaxUniStreams: 0x4321,
|
||||||
|
DisableMigration: true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
It("creates the parameters list", func() {
|
It("creates the parameters list", func() {
|
||||||
values := paramsListToMap(params.getTransportParameters())
|
values := paramsListToMap(params.getTransportParameters())
|
||||||
Expect(values).To(HaveLen(6))
|
Expect(values).To(HaveLen(7))
|
||||||
Expect(values).To(HaveKeyWithValue(initialMaxStreamDataParameterID, []byte{0xde, 0xad, 0xbe, 0xef}))
|
Expect(values).To(HaveKeyWithValue(initialMaxStreamDataParameterID, []byte{0xde, 0xad, 0xbe, 0xef}))
|
||||||
Expect(values).To(HaveKeyWithValue(initialMaxDataParameterID, []byte{0xde, 0xca, 0xfb, 0xad}))
|
Expect(values).To(HaveKeyWithValue(initialMaxDataParameterID, []byte{0xde, 0xca, 0xfb, 0xad}))
|
||||||
Expect(values).To(HaveKeyWithValue(initialMaxBidiStreamsParameterID, []byte{0x12, 0x34}))
|
Expect(values).To(HaveKeyWithValue(initialMaxBidiStreamsParameterID, []byte{0x12, 0x34}))
|
||||||
Expect(values).To(HaveKeyWithValue(initialMaxUniStreamsParameterID, []byte{0x43, 0x21}))
|
Expect(values).To(HaveKeyWithValue(initialMaxUniStreamsParameterID, []byte{0x43, 0x21}))
|
||||||
Expect(values).To(HaveKeyWithValue(idleTimeoutParameterID, []byte{0xca, 0xfe}))
|
Expect(values).To(HaveKeyWithValue(idleTimeoutParameterID, []byte{0xca, 0xfe}))
|
||||||
Expect(values).To(HaveKeyWithValue(maxPacketSizeParameterID, []byte{0x5, 0xac})) // 1452 = 0x5ac
|
Expect(values).To(HaveKeyWithValue(maxPacketSizeParameterID, []byte{0x5, 0xac})) // 1452 = 0x5ac
|
||||||
|
Expect(values).To(HaveKeyWithValue(disableMigrationParameterID, []byte{}))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ type TransportParameters struct {
|
|||||||
|
|
||||||
OmitConnectionID bool // only used for gQUIC
|
OmitConnectionID bool // only used for gQUIC
|
||||||
IdleTimeout time.Duration
|
IdleTimeout time.Duration
|
||||||
|
DisableMigration bool // only used for IETF QUIC
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// readHelloMap reads the transport parameters from the tags sent in a gQUIC handshake message
|
// readHelloMap reads the transport parameters from the tags sent in a gQUIC handshake message
|
||||||
@@ -141,6 +143,11 @@ func readTransportParameters(paramsList []transportParameter) (*TransportParamet
|
|||||||
return nil, fmt.Errorf("invalid value for max_packet_size: %d (minimum 1200)", maxPacketSize)
|
return nil, fmt.Errorf("invalid value for max_packet_size: %d (minimum 1200)", maxPacketSize)
|
||||||
}
|
}
|
||||||
params.MaxPacketSize = maxPacketSize
|
params.MaxPacketSize = maxPacketSize
|
||||||
|
case disableMigrationParameterID:
|
||||||
|
if len(p.Value) != 0 {
|
||||||
|
return nil, fmt.Errorf("wrong length for disable_migration: %d (expected empty)", len(p.Value))
|
||||||
|
}
|
||||||
|
params.DisableMigration = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +180,9 @@ func (p *TransportParameters) getTransportParameters() []transportParameter {
|
|||||||
{idleTimeoutParameterID, idleTimeout},
|
{idleTimeoutParameterID, idleTimeout},
|
||||||
{maxPacketSizeParameterID, maxPacketSize},
|
{maxPacketSizeParameterID, maxPacketSize},
|
||||||
}
|
}
|
||||||
|
if p.DisableMigration {
|
||||||
|
params = append(params, transportParameter{disableMigrationParameterID, nil})
|
||||||
|
}
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ func newServerTLS(
|
|||||||
IdleTimeout: config.IdleTimeout,
|
IdleTimeout: config.IdleTimeout,
|
||||||
MaxBidiStreams: uint16(config.MaxIncomingStreams),
|
MaxBidiStreams: uint16(config.MaxIncomingStreams),
|
||||||
MaxUniStreams: uint16(config.MaxIncomingUniStreams),
|
MaxUniStreams: uint16(config.MaxIncomingUniStreams),
|
||||||
|
DisableMigration: true,
|
||||||
},
|
},
|
||||||
newSession: newTLSServerSession,
|
newSession: newTLSServerSession,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
|||||||
Reference in New Issue
Block a user