net-ftp 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/net/ftp.rb +15 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb3a59b7b4a2153ab8e56bdf8dbad9402c9ae73aeb5dc765a990dc0fe491dd46
4
- data.tar.gz: 0c5552bcd67be7ae0087d83345716a8b6014d2d5347348ca72a48c5e1c306a2b
3
+ metadata.gz: 8a662c5a1b1201b6381d8c674ef0fcbe4a5a882ca023a24bd0606b607ec2a9cf
4
+ data.tar.gz: a89263fa37869d75365ffa13206244fae8efcaa2dcd8a24aa032ebdaf58bbbd4
5
5
  SHA512:
6
- metadata.gz: 4a67c6f9918df76bfb390cbaa44216e5180ab8f28c703da4fbf2cc83dccd062d420eb180a7db489a37fdc8dfbb676dee78695b71082a622172e208fa220a4a2c
7
- data.tar.gz: b501f9ee7c06712ed74eef5b5f414d9abb772d41f639a4bd71824e58cc62230715f5a23d139ccb0ff6c4cbf3033cb931c5921b9616e6f06c249fdcdcd8547af8
6
+ metadata.gz: cd09e0b10d7188943dcbdf8a7af4482d2798f4207fbdd5e42c44e6156ccb40b29e6f026b38c773d10b69e3549776ee79a266a1c7fb33315ad899faf0e25852f9
7
+ data.tar.gz: 76ca5bc18729d1ad8f0aaf732845a08ed6d21539d60db29bdadab43d9d3801f53772fd9312f1bd900fbd4e16f533b61b2c08cf60bfef87f4a3ebb7ced2e51630
data/lib/net/ftp.rb CHANGED
@@ -85,7 +85,7 @@ module Net
85
85
  end
86
86
 
87
87
  # :stopdoc:
88
- VERSION = "0.1.2"
88
+ VERSION = "0.1.3"
89
89
  FTP_PORT = 21
90
90
  CRLF = "\r\n"
91
91
  DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
@@ -98,6 +98,10 @@ module Net
98
98
  # When +true+, the connection is in passive mode. Default: +true+.
99
99
  attr_accessor :passive
100
100
 
101
+ # When +true+, use the IP address in PASV responses. Otherwise, it uses
102
+ # the same IP address for the control connection. Default: +false+.
103
+ attr_accessor :use_pasv_ip
104
+
101
105
  # When +true+, all traffic to and from the server is written
102
106
  # to +$stdout+. Default: +false+.
103
107
  attr_accessor :debug_mode
@@ -206,6 +210,9 @@ module Net
206
210
  # handshake.
207
211
  # See Net::FTP#ssl_handshake_timeout for
208
212
  # details. Default: +nil+.
213
+ # use_pasv_ip:: When +true+, use the IP address in PASV responses.
214
+ # Otherwise, it uses the same IP address for the control
215
+ # connection. Default: +false+.
209
216
  # debug_mode:: When +true+, all traffic to and from the server is
210
217
  # written to +$stdout+. Default: +false+.
211
218
  #
@@ -266,6 +273,7 @@ module Net
266
273
  @open_timeout = options[:open_timeout]
267
274
  @ssl_handshake_timeout = options[:ssl_handshake_timeout]
268
275
  @read_timeout = options[:read_timeout] || 60
276
+ @use_pasv_ip = options[:use_pasv_ip] || false
269
277
  if host
270
278
  connect(host, options[:port] || FTP_PORT)
271
279
  if options[:username]
@@ -1381,7 +1389,12 @@ module Net
1381
1389
  raise FTPReplyError, resp
1382
1390
  end
1383
1391
  if m = /\((?<host>\d+(?:,\d+){3}),(?<port>\d+,\d+)\)/.match(resp)
1384
- return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
1392
+ if @use_pasv_ip
1393
+ host = parse_pasv_ipv4_host(m["host"])
1394
+ else
1395
+ host = @bare_sock.remote_address.ip_address
1396
+ end
1397
+ return host, parse_pasv_port(m["port"])
1385
1398
  else
1386
1399
  raise FTPProtoError, resp
1387
1400
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-protocol