Add support for proxying in `WebsocketClient`
This patch was authored by @rnro and released by @0xTim.
Added support for TLS and plain text proxying of Websocket traffic.
-
In the TLS case a
CONNECT
header is first sent establishing the proxied traffic. -
In the plain text case the modified URI in the initial upgrade request header indicates to the proxy server that the traffic is to be proxied.
-
Use
NIOWebSocketFrameAggregator
to handle aggregating frame fragments. This brings with it more protections e.g. against memory exhaustion. -
Accompanying config has been added to support this change.
This change also includes some performance gains by reducing the allocation and copies necessary to send ByteBuffer
and ByteBufferView
through WebSocket.send
.
-
Sending
ByteBuffer
orByteBufferView
doesn’t require any allocation or copy of the data. Sending aString
now correctly pre allocates theByteBuffer
if multibyte characters are present in theString
. -
Remove custom random websocket mask generation which would only generate bytes between
UInt8.min..<UInt8.max
, therefore excludingUInt8.max
i.e.255
.