Class: RTunnel::RemoteListenServer
- Inherits:
-
GServer
- Object
- GServer
- RTunnel::RemoteListenServer
- Defined in:
- lib/server.rb
Overview
listens for incoming connections to tunnel
Constant Summary collapse
- CONNECTIONS =
{}
- CONTROL_CONNECTION_MAPPING =
{}
Instance Method Summary collapse
-
#initialize(port, host, control_connection) ⇒ RemoteListenServer
constructor
A new instance of RemoteListenServer.
- #serve(sock) ⇒ Object
Constructor Details
#initialize(port, host, control_connection) ⇒ RemoteListenServer
Returns a new instance of RemoteListenServer.
18 19 20 21 22 |
# File 'lib/server.rb', line 18 def initialize(port, host, control_connection) super(port, host, 10) @control_connection = control_connection @maxConnections = 1024 end |
Instance Method Details
#serve(sock) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/server.rb', line 24 def serve(sock) D "new incoming connection" conn_id = UUID..hexdigest CONNECTIONS[conn_id] = sock CONTROL_CONNECTION_MAPPING[conn_id] = @control_connection begin ControlServer.new_tunnel(conn_id) sock.while_reading do |buf| begin ControlServer.send_data(conn_id, buf) rescue Exception D "error talking on control connection, dropping incoming connection: #{$!.inspect}" break end end rescue IOError raise unless $!. =~ /stream closed/i end ControlServer.close_tunnel(conn_id) CONNECTIONS.delete conn_id CONTROL_CONNECTION_MAPPING.delete conn_id D "sock closed" rescue p $! puts $!.backtrace.join("\n") end |