Module: ShadowsocksRuby::Connections::BackendConnection
- Included in:
- TCP::DestinationConnection, TCP::RemoteServerConnection, UDP::DestinationConnection, UDP::RemoteServerConnection
- Defined in:
- lib/shadowsocks_ruby/connections/backend_connection.rb
Overview
Mixed-in code to provide functionality to a BackendConnection ,whose peer is a upstream peer, like a Destinatiion or a RemoteServer.
Instance Attribute Summary collapse
-
#packet_protocol ⇒ ShadowsocksRuby::Protocols::SomePacketProtocol
Packet Protocol.
-
#params ⇒ Hash
readonly
Params.
Instance Method Summary collapse
- #connection_completed ⇒ Object
-
#initialize(protocol_stack, params) ⇒ Connection_Object
If clild class override initialize, make sure to call super.
-
#send_data(data) ⇒ Object
Buffer data until the connection to the backend server is established and is ready for use.
Instance Attribute Details
#packet_protocol ⇒ ShadowsocksRuby::Protocols::SomePacketProtocol
Packet Protocol
A Strategy Pattern for replacing protocol algorithm
all read from ShadowsocksRuby::Connections::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
19 20 21 |
# File 'lib/shadowsocks_ruby/connections/backend_connection.rb', line 19 def packet_protocol @packet_protocol end |
#params ⇒ Hash (readonly)
Params
22 23 24 |
# File 'lib/shadowsocks_ruby/connections/backend_connection.rb', line 22 def params @params end |
Instance Method Details
#connection_completed ⇒ Object
39 40 41 |
# File 'lib/shadowsocks_ruby/connections/backend_connection.rb', line 39 def connection_completed @connected.succeed end |
#initialize(protocol_stack, params) ⇒ Connection_Object
If clild class override initialize, make sure to call super
29 30 31 32 33 34 35 36 |
# 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 |
#send_data(data) ⇒ Object
Buffer data until the connection to the backend server is established and is ready for use
45 46 47 |
# File 'lib/shadowsocks_ruby/connections/backend_connection.rb', line 45 def send_data data @connected.callback { super data } end |