Class: ForwardMachine::Controller
- Inherits:
-
Object
- Object
- ForwardMachine::Controller
- Defined in:
- lib/forwardmachine/controller.rb
Overview
Server which listens for forward requests. It should be run on internal address, like localhost because it doesn’t have any authentication. Each connection is handled by ControllerConnection
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Controller
constructor
A new instance of Controller.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Controller
Returns a new instance of Controller.
7 8 9 10 11 12 |
# File 'lib/forwardmachine/controller.rb', line 7 def initialize( = {}) @host = [:host] || "localhost" @port = [:port] || 8899 @forwarder_host = [:forwarder_host] || @host @ports = PortsPool.new([:ports_range] || (23200..23500)) end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/forwardmachine/controller.rb', line 14 def run EM.run { EM.error_handler { |error| logger.error(error.) logger.error(error.backtrace.join("\n")) } EM.start_server(@host, @port, ControllerConnection, @forwarder_host, @ports) logger.info("Started controller at #{@host}:#{@port}") } end |