Class: RTunnel::Server::TunnelConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- RTunnel::Server::TunnelConnection
- Defined in:
- lib/rtunnel/server.rb
Overview
A connection to a tunnelled port.
Constant Summary
Constants included from RTunnel
DEFAULT_CONTROL_PORT, KEEP_ALIVE_INTERVAL, TUNNEL_TIMEOUT
Instance Attribute Summary collapse
-
#connection_id ⇒ Object
readonly
Returns the value of attribute connection_id.
-
#control_connection ⇒ Object
Returns the value of attribute control_connection.
Instance Method Summary collapse
- #close_from_tunnel ⇒ Object
-
#initialize(control_connection, listen_host, listen_port) ⇒ TunnelConnection
constructor
A new instance of TunnelConnection.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Methods included from Logging
Methods included from RTunnel
resolve_address, run_client, run_server
Constructor Details
#initialize(control_connection, listen_host, listen_port) ⇒ TunnelConnection
Returns a new instance of TunnelConnection.
314 315 316 317 318 319 320 321 322 323 |
# File 'lib/rtunnel/server.rb', line 314 def initialize(control_connection, listen_host, listen_port) # listen_host and listen_port are passed for logging purposes only @listen_host = listen_host @listen_port = listen_port @control_connection = control_connection @server = @control_connection.server @hasher = nil init_log :to => @server end |
Instance Attribute Details
#connection_id ⇒ Object (readonly)
Returns the value of attribute connection_id.
311 312 313 |
# File 'lib/rtunnel/server.rb', line 311 def connection_id @connection_id end |
#control_connection ⇒ Object
Returns the value of attribute control_connection.
312 313 314 |
# File 'lib/rtunnel/server.rb', line 312 def control_connection @control_connection end |
Instance Method Details
#close_from_tunnel ⇒ Object
342 343 344 345 |
# File 'lib/rtunnel/server.rb', line 342 def close_from_tunnel @tunnel_closed = true close_connection_after_writing end |
#post_init ⇒ Object
325 326 327 328 329 330 331 |
# File 'lib/rtunnel/server.rb', line 325 def post_init @connection_id = @server.new_connection_id peer = Socket.unpack_sockaddr_in(get_peername).reverse.join ':' D "Tunnel connection from #{peer} on #{@connection_id}" @server.register_tunnel_connection self @control_connection.send_command CreateConnectionCommand.new(@connection_id) end |
#receive_data(data) ⇒ Object
347 348 349 350 |
# File 'lib/rtunnel/server.rb', line 347 def receive_data(data) D "Data: #{data.length} bytes for #{@connection_id}" @control_connection.send_command SendDataCommand.new(@connection_id, data) end |
#unbind ⇒ Object
333 334 335 336 337 338 339 340 |
# File 'lib/rtunnel/server.rb', line 333 def unbind unless @tunnel_closed D "Closed from client end: #{@connection_id}" close_command = CloseConnectionCommand.new(@connection_id) @control_connection.send_command close_command end @server.deregister_tunnel_connection self end |