Method: TCPProxy#initialize

Defined in:
lib/tcp_proxy.rb

#initialize(host, from_port, to_port) ⇒ TCPProxy

Returns a new instance of TCPProxy.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tcp_proxy.rb', line 9

def initialize(host, from_port, to_port)
  @ins  = TCPServer.new(host, from_port)

  @host = host
  @from_port, @to_port = from_port, to_port

  # Active connections and mutex to protect access to it.
  @connections = []
  @connections_m = Mutex.new
  
  # Are we currently accepting new connections?
  @accept_new = true
  
  @thread = Thread.start(&method(:thread_main))
end