net-ftp 0.1.3 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/push_gem.yml +48 -0
- data/.github/workflows/test.yml +10 -3
- data/BSDL +22 -0
- data/COPYING +56 -0
- data/LICENSE.txt +2 -22
- data/lib/net/ftp.rb +79 -56
- data/net-ftp.gemspec +2 -4
- metadata +9 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e481d7fa04c36757bf0f4a60bc8821b56d37d20343f3ffee84f863a351bab45b
|
4
|
+
data.tar.gz: 27dfd640949af2161f80d5899a426fecd2a2d979ee08158cc5c4300cb3c98ae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a90b945499fce5fc21da0b67a8776c0a6aa814670d8d1cbcd40dd5eb3f5d788834991bf4b15c3db4f91e57bba5588c1d1d091ac0b885e40bb878426e1de336
|
7
|
+
data.tar.gz: 04454bccbb3088db4510b2805f8a4c38aac2feca903d5a25dd5e7eeb51bb25a89a9c66c336fe1e112ffe063094aac3c1e939fdf8a54add77dde3a3577ee2aa36
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: Publish gem to rubygems.org
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*'
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
push:
|
13
|
+
if: github.repository == 'ruby/net-ftp'
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
environment:
|
17
|
+
name: rubygems.org
|
18
|
+
url: https://rubygems.org/gems/net-ftp
|
19
|
+
|
20
|
+
permissions:
|
21
|
+
contents: write
|
22
|
+
id-token: write
|
23
|
+
|
24
|
+
steps:
|
25
|
+
# Set up
|
26
|
+
- name: Harden Runner
|
27
|
+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
|
28
|
+
with:
|
29
|
+
egress-policy: audit
|
30
|
+
|
31
|
+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
32
|
+
|
33
|
+
- name: Set up Ruby
|
34
|
+
uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
|
35
|
+
with:
|
36
|
+
bundler-cache: true
|
37
|
+
ruby-version: ruby
|
38
|
+
|
39
|
+
# Release
|
40
|
+
- name: Publish to RubyGems
|
41
|
+
uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1
|
42
|
+
|
43
|
+
- name: Create GitHub release
|
44
|
+
run: |
|
45
|
+
tag_name="$(git describe --tags --abbrev=0)"
|
46
|
+
gh release create "${tag_name}" --verify-tag --draft --generate-notes
|
47
|
+
env:
|
48
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.github/workflows/test.yml
CHANGED
@@ -3,15 +3,22 @@ name: ubuntu
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
+
ruby-versions:
|
7
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
8
|
+
with:
|
9
|
+
engine: cruby
|
10
|
+
min_version: 2.6
|
11
|
+
|
6
12
|
build:
|
13
|
+
needs: ruby-versions
|
7
14
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
15
|
strategy:
|
9
16
|
matrix:
|
10
|
-
ruby:
|
11
|
-
os: [ ubuntu-latest, macos-latest ]
|
17
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
18
|
+
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
12
19
|
runs-on: ${{ matrix.os }}
|
13
20
|
steps:
|
14
|
-
- uses: actions/checkout@
|
21
|
+
- uses: actions/checkout@v4
|
15
22
|
- name: Set up Ruby
|
16
23
|
uses: ruby/setup-ruby@v1
|
17
24
|
with:
|
data/BSDL
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Redistribution and use in source and binary forms, with or without
|
4
|
-
modification, are permitted provided that the following conditions
|
5
|
-
are met:
|
6
|
-
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
8
|
-
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
11
|
-
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
-
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
-
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
-
SUCH DAMAGE.
|
1
|
+
All the files in this distribution are covered under either the Ruby license or
|
2
|
+
the BSD-2-Clause license (see the file COPYING).
|
data/lib/net/ftp.rb
CHANGED
@@ -77,6 +77,10 @@ module Net
|
|
77
77
|
# - #rename
|
78
78
|
# - #delete
|
79
79
|
#
|
80
|
+
# == Mainframe User Support
|
81
|
+
# - #literal
|
82
|
+
# - #quote
|
83
|
+
#
|
80
84
|
class FTP < Protocol
|
81
85
|
include MonitorMixin
|
82
86
|
if defined?(OpenSSL::SSL)
|
@@ -85,7 +89,7 @@ module Net
|
|
85
89
|
end
|
86
90
|
|
87
91
|
# :stopdoc:
|
88
|
-
VERSION = "0.
|
92
|
+
VERSION = "0.3.8"
|
89
93
|
FTP_PORT = 21
|
90
94
|
CRLF = "\r\n"
|
91
95
|
DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
|
@@ -106,6 +110,11 @@ module Net
|
|
106
110
|
# to +$stdout+. Default: +false+.
|
107
111
|
attr_accessor :debug_mode
|
108
112
|
|
113
|
+
# Sets or retrieves the output stream for debugging.
|
114
|
+
# Output stream will be used only when +debug_mode+ is set to true.
|
115
|
+
# The default value is +$stdout+.
|
116
|
+
attr_accessor :debug_output
|
117
|
+
|
109
118
|
# Sets or retrieves the +resume+ status, which decides whether incomplete
|
110
119
|
# transfers are resumed or restarted. Default: +false+.
|
111
120
|
attr_accessor :resume
|
@@ -195,6 +204,8 @@ module Net
|
|
195
204
|
# as parameters.
|
196
205
|
# private_data_connection:: If true, TLS is used for data connections.
|
197
206
|
# Default: +true+ when +options+[:ssl] is true.
|
207
|
+
# implicit_ftps:: If true, TLS is established on initial connection.
|
208
|
+
# Default: +false+
|
198
209
|
# username:: Username for login. If +options+[:username] is the string
|
199
210
|
# "anonymous" and the +options+[:password] is +nil+,
|
200
211
|
# "anonymous@" is used as a password.
|
@@ -238,16 +249,26 @@ module Net
|
|
238
249
|
if defined?(VerifyCallbackProc)
|
239
250
|
@ssl_context.verify_callback = VerifyCallbackProc
|
240
251
|
end
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
252
|
+
|
253
|
+
# jruby-openssl does not support session caching
|
254
|
+
unless RUBY_ENGINE == "jruby"
|
255
|
+
@ssl_context.session_cache_mode =
|
256
|
+
OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
|
257
|
+
OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
|
258
|
+
@ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess }
|
259
|
+
end
|
260
|
+
|
245
261
|
@ssl_session = nil
|
246
262
|
if options[:private_data_connection].nil?
|
247
263
|
@private_data_connection = true
|
248
264
|
else
|
249
265
|
@private_data_connection = options[:private_data_connection]
|
250
266
|
end
|
267
|
+
if options[:implicit_ftps].nil?
|
268
|
+
@implicit_ftps = false
|
269
|
+
else
|
270
|
+
@implicit_ftps = options[:implicit_ftps]
|
271
|
+
end
|
251
272
|
else
|
252
273
|
@ssl_context = nil
|
253
274
|
if options[:private_data_connection]
|
@@ -255,6 +276,11 @@ module Net
|
|
255
276
|
"private_data_connection can be set to true only when ssl is enabled"
|
256
277
|
end
|
257
278
|
@private_data_connection = false
|
279
|
+
if options[:implicit_ftps]
|
280
|
+
raise ArgumentError,
|
281
|
+
"implicit_ftps can be set to true only when ssl is enabled"
|
282
|
+
end
|
283
|
+
@implicit_ftps = false
|
258
284
|
end
|
259
285
|
@binary = true
|
260
286
|
if options[:passive].nil?
|
@@ -267,6 +293,7 @@ module Net
|
|
267
293
|
else
|
268
294
|
@debug_mode = options[:debug_mode]
|
269
295
|
end
|
296
|
+
@debug_output = $stdout
|
270
297
|
@resume = false
|
271
298
|
@bare_sock = @sock = NullSocket.new
|
272
299
|
@logged_in = false
|
@@ -338,19 +365,14 @@ module Net
|
|
338
365
|
# SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is
|
339
366
|
# returned.
|
340
367
|
def open_socket(host, port) # :nodoc:
|
341
|
-
|
342
|
-
|
343
|
-
|
368
|
+
return Timeout.timeout(@open_timeout, OpenTimeout) {
|
369
|
+
if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
|
370
|
+
@passive = true
|
344
371
|
SOCKSSocket.open(host, port)
|
372
|
+
else
|
373
|
+
Socket.tcp(host, port)
|
345
374
|
end
|
346
|
-
|
347
|
-
begin
|
348
|
-
Socket.tcp host, port, nil, nil, connect_timeout: @open_timeout
|
349
|
-
rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
|
350
|
-
raise Net::OpenTimeout, "Timeout to open TCP connection to "\
|
351
|
-
"#{host}:#{port} (exceeds #{@open_timeout} seconds)"
|
352
|
-
end
|
353
|
-
end
|
375
|
+
}
|
354
376
|
end
|
355
377
|
private :open_socket
|
356
378
|
|
@@ -378,19 +400,17 @@ module Net
|
|
378
400
|
# <tt>Errno::ECONNREFUSED</tt>) if the connection cannot be established.
|
379
401
|
#
|
380
402
|
def connect(host, port = FTP_PORT)
|
381
|
-
|
382
|
-
print "connect: ", host, ", ", port, "\n"
|
383
|
-
end
|
403
|
+
debug_print "connect: #{host}:#{port}"
|
384
404
|
synchronize do
|
385
405
|
@host = host
|
386
406
|
@bare_sock = open_socket(host, port)
|
387
|
-
@sock = BufferedSocket.new(@bare_sock, read_timeout: @read_timeout)
|
388
|
-
voidresp
|
389
407
|
if @ssl_context
|
390
408
|
begin
|
391
|
-
|
392
|
-
|
393
|
-
|
409
|
+
unless @implicit_ftps
|
410
|
+
set_socket(BufferedSocket.new(@bare_sock, read_timeout: @read_timeout))
|
411
|
+
voidcmd("AUTH TLS")
|
412
|
+
end
|
413
|
+
set_socket(BufferedSSLSocket.new(start_tls_session(@bare_sock), read_timeout: @read_timeout), @implicit_ftps)
|
394
414
|
if @private_data_connection
|
395
415
|
voidcmd("PBSZ 0")
|
396
416
|
voidcmd("PROT P")
|
@@ -399,6 +419,8 @@ module Net
|
|
399
419
|
@sock.close
|
400
420
|
raise
|
401
421
|
end
|
422
|
+
else
|
423
|
+
set_socket(BufferedSocket.new(@bare_sock, read_timeout: @read_timeout))
|
402
424
|
end
|
403
425
|
end
|
404
426
|
end
|
@@ -430,9 +452,7 @@ module Net
|
|
430
452
|
# Ensures that +line+ has a control return / line feed (CRLF) and writes
|
431
453
|
# it to the socket.
|
432
454
|
def putline(line) # :nodoc:
|
433
|
-
|
434
|
-
print "put: ", sanitize(line), "\n"
|
435
|
-
end
|
455
|
+
debug_print "put: #{sanitize(line)}"
|
436
456
|
if /[\r\n]/ =~ line
|
437
457
|
raise ArgumentError, "A line must not contain CR or LF"
|
438
458
|
end
|
@@ -445,9 +465,7 @@ module Net
|
|
445
465
|
def getline # :nodoc:
|
446
466
|
line = @sock.readline # if get EOF, raise EOFError
|
447
467
|
line.sub!(/(\r\n|\n|\r)\z/n, "")
|
448
|
-
|
449
|
-
print "get: ", sanitize(line), "\n"
|
450
|
-
end
|
468
|
+
debug_print "get: #{sanitize(line)}"
|
451
469
|
return line
|
452
470
|
end
|
453
471
|
private :getline
|
@@ -545,7 +563,6 @@ module Net
|
|
545
563
|
host, port = parse227(sendcmd("PASV"))
|
546
564
|
else
|
547
565
|
host, port = parse229(sendcmd("EPSV"))
|
548
|
-
# host, port = parse228(sendcmd("LPSV"))
|
549
566
|
end
|
550
567
|
return host, port
|
551
568
|
end
|
@@ -555,6 +572,7 @@ module Net
|
|
555
572
|
def transfercmd(cmd, rest_offset = nil) # :nodoc:
|
556
573
|
if @passive
|
557
574
|
host, port = makepasv
|
575
|
+
succeeded = false
|
558
576
|
begin
|
559
577
|
conn = open_socket(host, port)
|
560
578
|
if @resume and rest_offset
|
@@ -569,8 +587,9 @@ module Net
|
|
569
587
|
if !resp.start_with?("1")
|
570
588
|
raise FTPReplyError, resp
|
571
589
|
end
|
590
|
+
succeeded = true
|
572
591
|
ensure
|
573
|
-
conn
|
592
|
+
conn&.close if !succeeded
|
574
593
|
end
|
575
594
|
else
|
576
595
|
sock = makeport
|
@@ -748,7 +767,7 @@ module Net
|
|
748
767
|
ensure
|
749
768
|
conn.close if conn
|
750
769
|
end
|
751
|
-
|
770
|
+
getresp # The response might be important when connected to a mainframe
|
752
771
|
end
|
753
772
|
end
|
754
773
|
rescue Errno::EPIPE
|
@@ -870,13 +889,18 @@ module Net
|
|
870
889
|
# in +remotefile+. If callback or an associated block is supplied, calls it,
|
871
890
|
# passing in the transmitted data one line at a time.
|
872
891
|
#
|
892
|
+
# Returns the response which will contain a job number if the user was communicating with a mainframe in ASCII mode
|
893
|
+
# after issuing 'quote site filetype=jes'
|
894
|
+
#
|
873
895
|
def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
|
874
896
|
f = File.open(localfile)
|
897
|
+
response = ''
|
875
898
|
begin
|
876
|
-
storlines("STOR #{remotefile}", f, &block)
|
899
|
+
response = storlines("STOR #{remotefile}", f, &block)
|
877
900
|
ensure
|
878
901
|
f.close
|
879
902
|
end
|
903
|
+
response
|
880
904
|
end
|
881
905
|
|
882
906
|
#
|
@@ -1216,6 +1240,16 @@ module Net
|
|
1216
1240
|
return parse257(resp)
|
1217
1241
|
end
|
1218
1242
|
|
1243
|
+
#
|
1244
|
+
# The "quote" subcommand sends arguments verbatim to the remote ftp server.
|
1245
|
+
# The "literal" subcommand is an alias for "quote".
|
1246
|
+
# @param arguments Array[String] to be sent verbatim to the remote ftp server
|
1247
|
+
#
|
1248
|
+
def quote(arguments)
|
1249
|
+
sendcmd(arguments)
|
1250
|
+
end
|
1251
|
+
alias literal quote
|
1252
|
+
|
1219
1253
|
#
|
1220
1254
|
# Removes a remote directory.
|
1221
1255
|
#
|
@@ -1248,7 +1282,7 @@ module Net
|
|
1248
1282
|
#
|
1249
1283
|
def abort
|
1250
1284
|
line = "ABOR" + CRLF
|
1251
|
-
|
1285
|
+
debug_print "put: ABOR"
|
1252
1286
|
@sock.send(line, Socket::MSG_OOB)
|
1253
1287
|
resp = getmultiline
|
1254
1288
|
unless ["426", "226", "225"].include?(resp[0, 3])
|
@@ -1268,7 +1302,7 @@ module Net
|
|
1268
1302
|
if /[\r\n]/ =~ line
|
1269
1303
|
raise ArgumentError, "A line must not contain CR or LF"
|
1270
1304
|
end
|
1271
|
-
|
1305
|
+
debug_print "put: #{line}"
|
1272
1306
|
@sock.send(line + CRLF, Socket::MSG_OOB)
|
1273
1307
|
return getresp
|
1274
1308
|
end
|
@@ -1333,7 +1367,7 @@ module Net
|
|
1333
1367
|
end
|
1334
1368
|
|
1335
1369
|
feats = []
|
1336
|
-
resp.
|
1370
|
+
resp.each_line do |line|
|
1337
1371
|
next if !line.start_with?(' ') # skip status lines
|
1338
1372
|
|
1339
1373
|
feats << line.strip
|
@@ -1388,7 +1422,7 @@ module Net
|
|
1388
1422
|
if !resp.start_with?("227")
|
1389
1423
|
raise FTPReplyError, resp
|
1390
1424
|
end
|
1391
|
-
if m =
|
1425
|
+
if m = /(?<host>\d+(?:,\d+){3}),(?<port>\d+,\d+)/.match(resp)
|
1392
1426
|
if @use_pasv_ip
|
1393
1427
|
host = parse_pasv_ipv4_host(m["host"])
|
1394
1428
|
else
|
@@ -1401,24 +1435,6 @@ module Net
|
|
1401
1435
|
end
|
1402
1436
|
private :parse227
|
1403
1437
|
|
1404
|
-
# handler for response code 228
|
1405
|
-
# (Entering Long Passive Mode)
|
1406
|
-
#
|
1407
|
-
# Returns host and port.
|
1408
|
-
def parse228(resp) # :nodoc:
|
1409
|
-
if !resp.start_with?("228")
|
1410
|
-
raise FTPReplyError, resp
|
1411
|
-
end
|
1412
|
-
if m = /\(4,4,(?<host>\d+(?:,\d+){3}),2,(?<port>\d+,\d+)\)/.match(resp)
|
1413
|
-
return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
|
1414
|
-
elsif m = /\(6,16,(?<host>\d+(?:,\d+){15}),2,(?<port>\d+,\d+)\)/.match(resp)
|
1415
|
-
return parse_pasv_ipv6_host(m["host"]), parse_pasv_port(m["port"])
|
1416
|
-
else
|
1417
|
-
raise FTPProtoError, resp
|
1418
|
-
end
|
1419
|
-
end
|
1420
|
-
private :parse228
|
1421
|
-
|
1422
1438
|
def parse_pasv_ipv4_host(s)
|
1423
1439
|
return s.tr(",", ".")
|
1424
1440
|
end
|
@@ -1466,6 +1482,13 @@ module Net
|
|
1466
1482
|
end
|
1467
1483
|
private :parse257
|
1468
1484
|
|
1485
|
+
#
|
1486
|
+
# Writes debug message to the debug output stream
|
1487
|
+
#
|
1488
|
+
def debug_print(msg)
|
1489
|
+
@debug_output << msg + "\n" if @debug_mode && @debug_output
|
1490
|
+
end
|
1491
|
+
|
1469
1492
|
# :stopdoc:
|
1470
1493
|
class NullSocket
|
1471
1494
|
def read_timeout=(sec)
|
data/net-ftp.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.summary = %q{Support for the File Transfer Protocol.}
|
17
17
|
spec.description = %q{Support for the File Transfer Protocol.}
|
18
18
|
spec.homepage = "https://github.com/ruby/net-ftp"
|
19
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
20
20
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
21
21
|
|
22
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -25,10 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
# Specify which files should be added to the gem when it is released.
|
26
26
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
27
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
-
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(bin|test|spec|features)/}) }
|
29
29
|
end
|
30
|
-
spec.bindir = "exe"
|
31
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
30
|
spec.require_paths = ["lib"]
|
33
31
|
|
34
32
|
spec.add_dependency "net-protocol"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shugo Maeda
|
8
|
-
|
9
|
-
bindir: exe
|
8
|
+
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-10-03 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: net-protocol
|
@@ -45,14 +44,16 @@ executables: []
|
|
45
44
|
extensions: []
|
46
45
|
extra_rdoc_files: []
|
47
46
|
files:
|
47
|
+
- ".github/dependabot.yml"
|
48
|
+
- ".github/workflows/push_gem.yml"
|
48
49
|
- ".github/workflows/test.yml"
|
49
50
|
- ".gitignore"
|
51
|
+
- BSDL
|
52
|
+
- COPYING
|
50
53
|
- Gemfile
|
51
54
|
- LICENSE.txt
|
52
55
|
- README.md
|
53
56
|
- Rakefile
|
54
|
-
- bin/console
|
55
|
-
- bin/setup
|
56
57
|
- lib/net/ftp.rb
|
57
58
|
- net-ftp.gemspec
|
58
59
|
homepage: https://github.com/ruby/net-ftp
|
@@ -62,7 +63,6 @@ licenses:
|
|
62
63
|
metadata:
|
63
64
|
homepage_uri: https://github.com/ruby/net-ftp
|
64
65
|
source_code_uri: https://github.com/ruby/net-ftp
|
65
|
-
post_install_message:
|
66
66
|
rdoc_options: []
|
67
67
|
require_paths:
|
68
68
|
- lib
|
@@ -70,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 2.
|
73
|
+
version: 2.6.0
|
74
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
-
signing_key:
|
80
|
+
rubygems_version: 3.6.0.dev
|
82
81
|
specification_version: 4
|
83
82
|
summary: Support for the File Transfer Protocol.
|
84
83
|
test_files: []
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "net/ftp"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|