module ShadowsocksRuby::Connections::BackendConnection

Mixed-in code to provide functionality to a BackendConnection ,whose peer is a upstream peer, like a Destinatiion or a RemoteServer.

Attributes

packet_protocol[RW]

Packet Protocol

A Strategy Pattern for replacing protocol algorithm

all read from {BackendConnection}'s {packet_protocol} is just data,

the first send to {packet_protocol} chould be address_bin (for a {RemoteServerConnection}) or data (for a {DestinationConnection}), other send to {packet_protocol} should be just data

@return [ShadowsocksRuby::Protocols::SomePacketProtocol] @see ShadowsocksRuby::Protocols

params[R]

Public Class Methods

new(protocol_stack, params) click to toggle source

If clild class override initialize, make sure to call super

@param [Protocols::ProtocolStack] protocol_stack @param [Hash] params @return [Connection_Object]

Calls superclass method
# File lib/shadowsocks_ruby/connections/backend_connection.rb, line 29
def initialize protocol_stack, params
  super()

  @packet_protocol = protocol_stack.build!(self)    

  @params = params
  @connected = EM::DefaultDeferrable.new
end

Public Instance Methods

connection_completed() click to toggle source
# File lib/shadowsocks_ruby/connections/backend_connection.rb, line 39
def connection_completed
  @connected.succeed
end
send_data(data) click to toggle source

Buffer data until the connection to the backend server is established and is ready for use

Calls superclass method
# File lib/shadowsocks_ruby/connections/backend_connection.rb, line 45
def send_data data
  @connected.callback { super data }
end