Class: Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/bettercap/monkey/em-proxy/proxy.rb

Class Method Summary collapse

Class Method Details

.start(options, &blk) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bettercap/monkey/em-proxy/proxy.rb', line 3

def self.start(options, &blk)
  # epoll is not supported on OSX!
  # EM.epoll
  EM.run do
    # We'll take care of this.
    #
    # trap("TERM") { stop }
    # trap("INT")  { stop }

    EventMachine::start_server(options[:host], options[:port],
                               EventMachine::ProxyServer::Connection, options) do |c|
      c.instance_eval(&blk)
    end
  end
end

.stopObject


19
20
21
22
# File 'lib/bettercap/monkey/em-proxy/proxy.rb', line 19

def self.stop
  EventMachine.stop
rescue
end