Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/net/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,19 +356,14 @@ def return_code=(s) # :nodoc:
# SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is
# returned.
def open_socket(host, port) # :nodoc:
if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
@passive = true
Timeout.timeout(@open_timeout, OpenTimeout) do
return Timeout.timeout(@open_timeout, OpenTimeout) {
if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
@passive = true
SOCKSSocket.open(host, port)
else
Socket.tcp(host, port)
end
else
begin
Socket.tcp host, port, nil, nil, connect_timeout: @open_timeout
rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
raise Net::OpenTimeout, "Timeout to open TCP connection to "\
"#{host}:#{port} (exceeds #{@open_timeout} seconds)"
end
end
}
end
private :open_socket

Expand Down