Class: ShadowsocksRuby::Connections::TCP::LocalBackendConnection

Inherits:
ServerConnection show all
Defined in:
lib/shadowsocks_ruby/connections/tcp/localbackend_connection.rb

Overview

A LocalBackendConnection's job is relay data from localbackend to destination.

Constant Summary

Constants inherited from Connection

Connection::PressureLevel

Instance Attribute Summary

Attributes inherited from ServerConnection

#packet_protocol, #params

Attributes inherited from Connection

#logger, #plexer

Instance Method Summary collapse

Methods inherited from ServerConnection

#create_plexer, #initialize, #post_init, #unbind

Methods inherited from Connection

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

Constructor Details

This class inherits a constructor from ShadowsocksRuby::Connections::ServerConnection

Instance Method Details

#process_first_packetObject Also known as: process_hook


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

def process_first_packet
  address_bin = packet_protocol.tcp_receive_from_localbackend(-1)
  host, port = Util::parse_address_bin(address_bin)
  logger.info('connection') { "connecting #{host}:#{port} from #{peer}" }
  create_plexer(host, port, DestinationConnection)
  class << self
    alias process_hook process_other_packet
  end
end

#process_other_packetObject


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

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