Class: TunnelClient::TunnelConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- TunnelClient::TunnelConnection
- Defined in:
- lib/lds-cf-plugin/tunnel/tunnelclient.rb
Instance Method Summary collapse
-
#initialize(listener) ⇒ TunnelConnection
constructor
A new instance of TunnelConnection.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #ssl_handshake_completed ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(listener) ⇒ TunnelConnection
Returns a new instance of TunnelConnection.
46 47 48 |
# File 'lib/lds-cf-plugin/tunnel/tunnelclient.rb', line 46 def initialize(listener) @listener = listener end |
Instance Method Details
#post_init ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/lds-cf-plugin/tunnel/tunnelclient.rb', line 50 def post_init puts "Connection opened" if @listener.use_tls start_tls else send_initialization end end |
#receive_data(data) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/lds-cf-plugin/tunnel/tunnelclient.rb', line 63 def receive_data(data) (@buf ||= '') << data while @buf.bytesize >= FRAME_HEADER_LENGTH frame_type, frame_length = @buf.unpack("A1N") if @buf.bytesize >= FRAME_HEADER_LENGTH + frame_length @buf.slice!(0,FRAME_HEADER_LENGTH) frame_body = @buf.slice!(0,frame_length) case frame_type when 'E', 'e' # Error close_connection raise frame_body when 'R', 'r' @listener.resume proxy_incoming_to @listener @listener.proxy_incoming_to self else close_connection raise "Received invalid frame type '#{frame_type}' from Tunnel Server" end end end end |
#ssl_handshake_completed ⇒ Object
59 60 61 |
# File 'lib/lds-cf-plugin/tunnel/tunnelclient.rb', line 59 def ssl_handshake_completed send_initialization end |
#unbind ⇒ Object
88 89 90 |
# File 'lib/lds-cf-plugin/tunnel/tunnelclient.rb', line 88 def unbind @listener.close_connection_after_writing end |