12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/socks_handler/socket_socksify.rb', line 12
def tcp(remote_host, remote_port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil, &block)
rule = SocksHandler::TCP.find_rule(remote_host)
return super if rule.nil? || rule.direct
socket = super(rule.host, rule.port, local_host, local_port, connect_timeout: connect_timeout, resolv_timeout: resolv_timeout, &block)
begin
SocksHandler::TCP.establish_connection(socket, remote_host, remote_port, rule.username, rule.password)
rescue
socket.close
raise
end
socket
end
|