Module: SocksHandler::TCPSocketSocksify

Defined in:
lib/socks_handler/tcpsocket_socksify.rb

Instance Method Summary collapse

Instance Method Details

#initialize(remote_host, remote_port, local_host = nil, local_port = nil, connect_timeout: nil) ⇒ Object

Parameters:

  • remote_host (String)
  • remote_port (Integer, String)
  • local_host (String, nil) (defaults to: nil)
  • local_port (Integer, String) (defaults to: nil)
  • connect_timeout (Integer, Float, nil) (defaults to: nil)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/socks_handler/tcpsocket_socksify.rb', line 10

def initialize(remote_host, remote_port, local_host = nil, local_port = nil, connect_timeout: nil)
  rule = SocksHandler::TCP.find_rule(remote_host)
  return super if rule.nil? || rule.direct

  super(rule.host, rule.port, local_host, local_port, connect_timeout: connect_timeout)
  begin
    SocksHandler::TCP.establish_connection(self, remote_host, remote_port, rule.username, rule.password)
  rescue
    close
    raise
  end
end