Class: ForwardMachine::ControllerConnection
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- ForwardMachine::ControllerConnection
- Defined in:
- lib/forwardmachine/controller_connection.rb
Overview
Connection to controller server Sets up new forwarder to destination host given by client
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#ports ⇒ Object
readonly
Returns the value of attribute ports.
Instance Method Summary collapse
-
#initialize(host, ports) ⇒ ControllerConnection
constructor
Internal: Initialize new ForwardConnection host - Host on which forwarders (servers) will be created ports - Ports pool from which ports for forwarders will be taken.
-
#receive_data(data) ⇒ Object
Internal: Receives destination in format “host:port” from client, creates new forwarder, returns forwarder socket address in format “host:port” back to the client and closes the connection.
Constructor Details
#initialize(host, ports) ⇒ ControllerConnection
Internal: Initialize new ForwardConnection host - Host on which forwarders (servers) will be created ports - Ports pool from which ports for forwarders
will be taken
11 12 13 14 |
# File 'lib/forwardmachine/controller_connection.rb', line 11 def initialize(host, ports) @host = host @ports = ports end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/forwardmachine/controller_connection.rb', line 5 def host @host end |
#ports ⇒ Object (readonly)
Returns the value of attribute ports.
5 6 7 |
# File 'lib/forwardmachine/controller_connection.rb', line 5 def ports @ports end |
Instance Method Details
#receive_data(data) ⇒ Object
Internal: Receives destination in format “host:port” from client, creates new forwarder, returns forwarder socket address in format “host:port” back to the client and closes the connection.
20 21 22 23 24 |
# File 'lib/forwardmachine/controller_connection.rb', line 20 def receive_data(data) forwarder = Forwarder.new(host, data.strip, ports) send_data(forwarder.start) close_connection_after_writing end |