Closed rnro closed 1 year ago
Thanks for the review @0xTim. I've pushed the changes you requested and also some performance improvements in a separate commit.
Merging #130 (777ef32) into main (e0faccd) will decrease coverage by
3.62%
. The diff coverage is78.80%
.
Sorry about the delay. The missing DocC comments should now be there.
FYI nightly error is being tracked at https://github.com/apple/swift/issues/65064
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
andByteBufferView
throughWebSocket.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
.