Skip to content

Commit

Permalink
Merge pull request #930 from dalpo/ensure-default-ftp-passive-mode
Browse files Browse the repository at this point in the history
Ensure the default FTP passive settings to false

The default passive setting has been changed between Ruby 2.2 and 2.3

Sources:
Ruby 2.2: https://docs.ruby-lang.org/en/2.2.0/Net/FTP.html - contains no default_passive, only passive set to false by default
Ruby 2.3: https://docs.ruby-lang.org/en/2.3.0/Net/FTP.html - default_passive set to true by default.
  • Loading branch information
tombruijn committed Oct 6, 2018
2 parents fdf5109 + cfd8a58 commit f85209e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/backup/storage/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def connection
Net::FTP.send(:remove_const, :FTP_PORT)
end; Net::FTP.send(:const_set, :FTP_PORT, port)

# Ensure default passive mode to false.
# Note: The default passive setting changed between Ruby 2.2 and 2.3
if Net::FTP.respond_to?(:default_passive=)
Net::FTP.default_passive = false
end

Net::FTP.open(ip, username, password) do |ftp|
if timeout
ftp.open_timeout = timeout
Expand Down

0 comments on commit f85209e

Please sign in to comment.