Module: ShadowsocksRuby::Protocols

Defined in:
lib/shadowsocks_ruby/protocols/protocol.rb,
lib/shadowsocks_ruby/protocols/packet/plain.rb,
lib/shadowsocks_ruby/protocols/packet/socks5.rb,
lib/shadowsocks_ruby/protocols/protocol_stack.rb,
lib/shadowsocks_ruby/protocols/obfs/tls_ticket.rb,
lib/shadowsocks_ruby/protocols/cipher/iv_cipher.rb,
lib/shadowsocks_ruby/protocols/obfs/http_simple.rb,
lib/shadowsocks_ruby/protocols/cipher/verify_sha1.rb,
lib/shadowsocks_ruby/protocols/packet/shadowsocks.rb,
lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb

Overview

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.

Defined Under Namespace

Modules: BufferHelper, DummyHelper, PlainProtocol, Socks5Protocol Classes: HttpSimpleProtocol, IvCipherProtocol, NoIvCipherProtocol, ProtocolStack, ShadowsocksProtocol, TlsTicketProtocol, VerifySha1Protocol