Method: Proxifier::Proxy#open

Defined in:
lib/proxifier/env.rb,
lib/proxifier/proxy.rb

#open(host, port, local_host = nil, local_port = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/proxifier/env.rb', line 6

def open(host, port, local_host = nil, local_port = nil)
  return TCPSocket.new(host, port, local_host, local_port, :proxy => nil) unless proxify?(host)

  socket = TCPSocket.new(self.host, self.port, local_host, local_port, :proxy => nil)

  begin
    proxify(socket, host, port)
  rescue
    socket.close
    raise
  end

  socket
end