add a method to update the packer's max packet size

This commit is contained in:
Marten Seemann
2021-01-31 14:25:18 +08:00
parent c6ae91a8cf
commit 142071253d
2 changed files with 36 additions and 2 deletions

View File

@@ -862,6 +862,13 @@ func (p *packetPacker) SetToken(token []byte) {
p.token = token
}
// When a higher MTU is discovered, use it.
func (p *packetPacker) SetMaxPacketSize(s protocol.ByteCount) {
p.maxPacketSize = s
}
// If the peer sets a max_packet_size that's smaller than the size we're currently using,
// we need to reduce the size of packets we send.
func (p *packetPacker) HandleTransportParameters(params *wire.TransportParameters) {
if params.MaxUDPPayloadSize != 0 {
p.maxPacketSize = utils.MinByteCount(p.maxPacketSize, params.MaxUDPPayloadSize)