Class: ShadowsocksRuby::Connections::UDP::LocalBackendConnection

Inherits:
ServerConnection show all
Defined in:
lib/shadowsocks_ruby/connections/udp/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
# File 'lib/shadowsocks_ruby/connections/udp/localbackend_connection.rb', line 7

def process_first_packet
  address_bin = packet_protocol.udp_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



19
20
21
22
# File 'lib/shadowsocks_ruby/connections/udp/localbackend_connection.rb', line 19

def process_other_packet
  data = packet_protocol.udp_receive_from_localbackend(-1)
  plexer.packet_protocol.udp_send_to_destination(data)
end