shadowsocks-org icon indicating copy to clipboard operation
shadowsocks-org copied to clipboard

feature request: sip003 mux / multiplexing spec

Open liudongmiao opened this issue 11 months ago • 1 comments

There is no relay in sip003, currenty it's implemented by plugin self.

As it's shadowsocks is based on socks, entire payload can be encrypted, so there is no mux solution on shadowsocks payload.

Then, the mux should be done on plugin:

  1. mux on payload, add mux header before payload
    1. Mux.Cool
    2. please note: it seems no way to compatible mux and non mux solution as mux header is not optional
  2. mux on plugin's underlying protocol
    1. websockets based on http/1.1, use websockets's rsv and/or opcode.
      1. please note, there should be some simple stream flow control
    2. http2/http3, special stream and stream flow control
    3. other: I don't think other protocol can be supported by cdn

liudongmiao avatar Feb 29 '24 01:02 liudongmiao

There is another simple mux by @IrineSistiana at https://github.com/IrineSistiana/simple-mux

However, it's not standard, and the head length is 7 bytes.

For websocket, the head length is maximum 14 bytes, however, if we don't support more than 2**16 = 64K, the client data frame is 6 or 8 bytes (including mask 4 bytes), and the server data frame is 2 or 4 bytes (without mask 4 bytes). For mux, we can use 3 rsv bits, can support max 8 channel, and there are 10 unused opcodes, can be max to 18. For close stream, I'd suggest a payload length 0, as it's illegal for underlyling data, they never send data in 0. For ping / pong, there're in websockets.

liudongmiao avatar Mar 07 '24 02:03 liudongmiao