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:
-
tcp_receive_from_client
-
tcp_send_to_client
-
tcp_receive_from_remoteserver
-
tcp_send_to_remoteserver
-
tcp_receive_from_localbackend
-
tcp_send_to_localbackend
-
tcp_receive_from_destination
-
tcp_send_to_destination
-
udp_receive_from_client
-
udp_send_to_client
-
udp_receive_from_remoteserver
-
udp_send_to_remoteserver
-
udp_receive_from_localbackend
-
udp_send_to_localbackend
-
udp_receive_from_destination
-
udp_send_to_destination
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