Class: Netpump::Server
- Inherits:
-
Object
- Object
- Netpump::Server
- Defined in:
- lib/netpump/server.rb
Instance Method Summary collapse
-
#initialize(host: "0.0.0.0", port: 10000, proxy_host: "127.0.0.1", proxy_port: 0) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(host: "0.0.0.0", port: 10000, proxy_host: "127.0.0.1", proxy_port: 0) ⇒ Server
9 10 11 12 13 14 15 |
# File 'lib/netpump/server.rb', line 9 def initialize(host: "0.0.0.0", port: 10000, proxy_host: "127.0.0.1", proxy_port: 0) @host = host @port = port @proxy_host = proxy_host @proxy_port = proxy_port @log = lambda { |msg, **ctx| log(msg, s: true, **ctx) } end |
Instance Method Details
#start ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/netpump/server.rb', line 17 def start @log.call "[+] netpump server is starting.", host: @host, port: @port start_websocket_server proxy = EventMachine.start_server( @proxy_host, @proxy_port, EventMachine::Protocols::CONNECT ) do |c| fail "inactivity timeout" unless c.comm_inactivity_timeout.zero? end @proxy_port, @proxy_host = Socket.unpack_sockaddr_in(EventMachine.get_sockname(proxy)) end |