Class: Weblink
- Inherits:
-
Object
- Object
- Weblink
- Defined in:
- lib/weblink.rb
Instance Method Summary collapse
-
#initialize(client: nil, server: nil, host: "0.0.0.0", port: "8080", connection_inactivity_timeout: 30.0, proxy_host_loc: "0.0.0.0", proxy_port_loc: 3128, proxy_host_rem: "127.0.0.1", proxy_port_rem: 55000, websocket_pool_batch_size: 1, websocket_pool_max_size: 20) ⇒ Weblink
constructor
A new instance of Weblink.
- #run ⇒ Object
Constructor Details
#initialize(client: nil, server: nil, host: "0.0.0.0", port: "8080", connection_inactivity_timeout: 30.0, proxy_host_loc: "0.0.0.0", proxy_port_loc: 3128, proxy_host_rem: "127.0.0.1", proxy_port_rem: 55000, websocket_pool_batch_size: 1, websocket_pool_max_size: 20) ⇒ Weblink
Returns a new instance of Weblink.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/weblink.rb', line 9 def initialize( client: nil, server: nil, host: "0.0.0.0", port: "8080", connection_inactivity_timeout: 30.0, proxy_host_loc: "0.0.0.0", proxy_port_loc: 3128, proxy_host_rem: "127.0.0.1", proxy_port_rem: 55000, websocket_pool_batch_size: 1, websocket_pool_max_size: 20 ) @client = client || client == server @server = server @host = host @port = port @connection_inactivity_timeout = connection_inactivity_timeout @proxy_host_loc = proxy_host_loc @proxy_port_loc = proxy_port_loc @proxy_host_rem = proxy_host_rem @proxy_port_rem = proxy_port_rem @websocket_pool = EventMachine::Queue.new @websocket_pool_batch_size = websocket_pool_batch_size @websocket_pool_max_size = websocket_pool_max_size end |
Instance Method Details
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/weblink.rb', line 36 def run EventMachine.epoll EventMachine.error_handler do |e| log "[!] unexpected errback", error: e end EventMachine.run do trap(:INT) { puts; stop_eventmachine "[-] shutting down weblink.", signal: "sigint" } trap(:TERM) { stop_eventmachine "[-] shutting down weblink.", signal: "sigterm" } log "[+] starting weblink.", client: @client, server: @server, epoll: EventMachine.epoll? start_proxy_rem if @server start_websocket_server print_open_url if @client end end |