fix(#287): Clamp max websocket message size to 32MB
This commit is contained in:
parent
0da43e1643
commit
bb266f6899
1 changed files with 5 additions and 3 deletions
|
@ -53,10 +53,12 @@ impl TunnelWrite for WebsocketTunnelWrite {
|
|||
}
|
||||
|
||||
// If the buffer has been completely filled with previous read, Grows it !
|
||||
// For the buffer to not be a bottleneck when the TCP window scale
|
||||
// For udp, the buffer will never grows.
|
||||
// For the buffer to not be a bottleneck when the TCP window scale.
|
||||
// We clamp it to 32Mb to avoid unbounded growth and as websocket max frame size is 64Mb by default
|
||||
// For udp, the buffer will never grow.
|
||||
const _32_MB: usize = 32 * 1024 * 1024;
|
||||
buf.clear();
|
||||
if buf.capacity() == read_len {
|
||||
if buf.capacity() == read_len && buf.capacity() < _32_MB {
|
||||
let new_size = buf.capacity() + (buf.capacity() / 4); // grow buffer by 1.25 %
|
||||
buf.reserve(new_size);
|
||||
trace!(
|
||||
|
|
Loading…
Reference in a new issue