Module: ShadowsocksRuby::Connections::TCP::LocalBackendConnection

Includes:
Connection, ServerConnection
Defined in:
lib/shadowsocks_ruby/connections/tcp/localbackend_connection.rb

Overview

Mixed-in with an EventMachine::Connection Object to use this.

Constant Summary

Constants included from Connection

Connection::PressureLevel

Instance Attribute Summary

Attributes included from ServerConnection

#packet_protocol, #params

Attributes included from Connection

#logger, #plexer

Instance Method Summary collapse

Methods included from ServerConnection

#create_plexer, #initialize, #post_init

Methods included from Connection

#async_recv, #async_recv_until, #peer, #send_data, #unbind

Instance Method Details

#process_first_packetObject Also known as: process_hook



9
10
11
12
13
14
15
16
# File 'lib/shadowsocks_ruby/connections/tcp/localbackend_connection.rb', line 9

def process_first_packet
  address_bin = packet_protocol.tcp_receive_from_localbackend(-1)
  host, port = Util::parse_address_bin(address_bin)
  create_plexer(host, port, DestinationConnection)
  class << self
    alias process_hook process_other_packet
  end
end

#process_other_packetObject



21
22
23
24
# File 'lib/shadowsocks_ruby/connections/tcp/localbackend_connection.rb', line 21

def process_other_packet
  data = packet_protocol.tcp_receive_from_localbackend(-1)
  plexer.packet_protocol.tcp_send_to_destination(data)
end