module ShadowsocksRuby::Protocols

Protocols are layered. Each layer know nothing about other layers.

   (data)   |   TOP: HTTP, FTP, STMP ...     ^   (data)
     Pack   |   layer 3 protocol packet      |   Unpack
  Encrypt   |   layer 2 protocol cipher      |   Decrypt
Obfuscate   |   layer 1 protocol obfuscate   |   DeObfuscate
 (opaque)   V   Bottom: TCP/UDP              |   (opaque)

Protocols

There are 16 hooks can be called on protocols, which are:

Each receive_from hook's job is to return data of exact length required by upper level protocol.

Each send_to hook's job is to get the send work done, with the data it received from the upper level protocol.

Each hook can call next layer protocols's corresponding receive_from and send_to hook,

The bottom layer calls Connection's corresponding receive_from and send_to hook.

The Connection then map corresponding receive_from and send_to hook to real data transfer methods async_recv and send_data.

@see Connections @see ProtocolStack