"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/net/ftp.rb" between
ruby-2.7.3.tar.gz and ruby-2.7.4.tar.gz

About: Ruby is an interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). Stable release of 2.7 series.

ftp.rb  (ruby-2.7.3):ftp.rb  (ruby-2.7.4)
skipping to change at line 100 skipping to change at line 100
DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
@@default_passive = true @@default_passive = true
# :startdoc: # :startdoc:
# When +true+, transfers are performed in binary mode. Default: +true+. # When +true+, transfers are performed in binary mode. Default: +true+.
attr_reader :binary attr_reader :binary
# When +true+, the connection is in passive mode. Default: +true+. # When +true+, the connection is in passive mode. Default: +true+.
attr_accessor :passive attr_accessor :passive
# When +true+, use the IP address in PASV responses. Otherwise, it uses
# the same IP address for the control connection. Default: +false+.
attr_accessor :use_pasv_ip
# When +true+, all traffic to and from the server is written # When +true+, all traffic to and from the server is written
# to +$stdout+. Default: +false+. # to +$stdout+. Default: +false+.
attr_accessor :debug_mode attr_accessor :debug_mode
# Sets or retrieves the +resume+ status, which decides whether incomplete # Sets or retrieves the +resume+ status, which decides whether incomplete
# transfers are resumed or restarted. Default: +false+. # transfers are resumed or restarted. Default: +false+.
attr_accessor :resume attr_accessor :resume
# Number of seconds to wait for the connection to open. Any number # Number of seconds to wait for the connection to open. Any number
# may be used, including Floats for fractional seconds. If the FTP # may be used, including Floats for fractional seconds. If the FTP
skipping to change at line 208 skipping to change at line 212
# passive:: When +true+, the connection is in passive mode. Default: # passive:: When +true+, the connection is in passive mode. Default:
# +true+. # +true+.
# open_timeout:: Number of seconds to wait for the connection to open. # open_timeout:: Number of seconds to wait for the connection to open.
# See Net::FTP#open_timeout for details. Default: +nil+. # See Net::FTP#open_timeout for details. Default: +nil+.
# read_timeout:: Number of seconds to wait for one block to be read. # read_timeout:: Number of seconds to wait for one block to be read.
# See Net::FTP#read_timeout for details. Default: +60+. # See Net::FTP#read_timeout for details. Default: +60+.
# ssl_handshake_timeout:: Number of seconds to wait for the TLS # ssl_handshake_timeout:: Number of seconds to wait for the TLS
# handshake. # handshake.
# See Net::FTP#ssl_handshake_timeout for # See Net::FTP#ssl_handshake_timeout for
# details. Default: +nil+. # details. Default: +nil+.
# use_pasv_ip:: When +true+, use the IP address in PASV responses.
# Otherwise, it uses the same IP address for the control
# connection. Default: +false+.
# debug_mode:: When +true+, all traffic to and from the server is # debug_mode:: When +true+, all traffic to and from the server is
# written to +$stdout+. Default: +false+. # written to +$stdout+. Default: +false+.
# #
def initialize(host = nil, user_or_options = {}, passwd = nil, acct = nil) def initialize(host = nil, user_or_options = {}, passwd = nil, acct = nil)
super() super()
begin begin
options = user_or_options.to_hash options = user_or_options.to_hash
rescue NoMethodError rescue NoMethodError
# for backward compatibility # for backward compatibility
options = {} options = {}
skipping to change at line 268 skipping to change at line 275
@debug_mode = false @debug_mode = false
else else
@debug_mode = options[:debug_mode] @debug_mode = options[:debug_mode]
end end
@resume = false @resume = false
@bare_sock = @sock = NullSocket.new @bare_sock = @sock = NullSocket.new
@logged_in = false @logged_in = false
@open_timeout = options[:open_timeout] @open_timeout = options[:open_timeout]
@ssl_handshake_timeout = options[:ssl_handshake_timeout] @ssl_handshake_timeout = options[:ssl_handshake_timeout]
@read_timeout = options[:read_timeout] || 60 @read_timeout = options[:read_timeout] || 60
@use_pasv_ip = options[:use_pasv_ip] || false
if host if host
connect(host, options[:port] || FTP_PORT) connect(host, options[:port] || FTP_PORT)
if options[:username] if options[:username]
login(options[:username], options[:password], options[:account]) login(options[:username], options[:password], options[:account])
end end
end end
end end
# A setter to toggle transfers in binary mode. # A setter to toggle transfers in binary mode.
# +newmode+ is either +true+ or +false+ # +newmode+ is either +true+ or +false+
skipping to change at line 1373 skipping to change at line 1381
# handler for response code 227 # handler for response code 227
# (Entering Passive Mode (h1,h2,h3,h4,p1,p2)) # (Entering Passive Mode (h1,h2,h3,h4,p1,p2))
# #
# Returns host and port. # Returns host and port.
def parse227(resp) # :nodoc: def parse227(resp) # :nodoc:
if !resp.start_with?("227") if !resp.start_with?("227")
raise FTPReplyError, resp raise FTPReplyError, resp
end end
if m = /\((?<host>\d+(,\d+){3}),(?<port>\d+,\d+)\)/.match(resp) if m = /\((?<host>\d+(,\d+){3}),(?<port>\d+,\d+)\)/.match(resp)
return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"]) if @use_pasv_ip
host = parse_pasv_ipv4_host(m["host"])
else
host = @bare_sock.remote_address.ip_address
end
return host, parse_pasv_port(m["port"])
else else
raise FTPProtoError, resp raise FTPProtoError, resp
end end
end end
private :parse227 private :parse227
# handler for response code 228 # handler for response code 228
# (Entering Long Passive Mode) # (Entering Long Passive Mode)
# #
# Returns host and port. # Returns host and port.
 End of changes. 4 change blocks. 
1 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)