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
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
(see ServerConnection#params
)
Public Class Methods
If clild class override initialize, make sure to call super
@param [Protocols::ProtocolStack] protocol_stack @param [Hash] params @return [Connection_Object]
# 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
# File lib/shadowsocks_ruby/connections/backend_connection.rb, line 39 def connection_completed @connected.succeed end
Buffer data until the connection to the backend server is established and is ready for use
# File lib/shadowsocks_ruby/connections/backend_connection.rb, line 45 def send_data data @connected.callback { super data } end