зеркало из https://github.com/github/ruby.git
ftp.rb: use Addrinfo interfaces
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c4e660457f
Коммит
af36e316d7
|
@ -431,7 +431,8 @@ module Net
|
|||
else
|
||||
sock = makeport
|
||||
begin
|
||||
sendport(sock.addr[3], sock.addr[1])
|
||||
addr = sock.local_address
|
||||
sendport(addr.ip_address, addr.ip_port)
|
||||
if @resume and rest_offset
|
||||
resp = sendcmd("REST " + rest_offset.to_s)
|
||||
if !resp.start_with?("3")
|
||||
|
@ -1246,7 +1247,7 @@ module Net
|
|||
raise FTPReplyError, resp
|
||||
end
|
||||
if m = /\((?<d>[!-~])\k<d>\k<d>(?<port>\d+)\k<d>\)/.match(resp)
|
||||
return @sock.peeraddr[3], m["port"].to_i
|
||||
return @sock.remote_address.ip_address, m["port"].to_i
|
||||
else
|
||||
raise FTPProtoError, resp
|
||||
end
|
||||
|
|
|
@ -109,7 +109,8 @@ class FTPTest < Test::Unit::TestCase
|
|||
def test_parse229
|
||||
ftp = Net::FTP.new
|
||||
sock = OpenStruct.new
|
||||
sock.peeraddr = [nil, nil, nil, "1080:0000:0000:0000:0008:0800:200c:417a"]
|
||||
sock.remote_address = OpenStruct.new
|
||||
sock.remote_address.ip_address = "1080:0000:0000:0000:0008:0800:200c:417a"
|
||||
ftp.instance_variable_set(:@sock, sock)
|
||||
host, port = ftp.send(:parse229, "229 Entering Passive Mode (|||3106|)")
|
||||
assert_equal("1080:0000:0000:0000:0008:0800:200c:417a", host)
|
||||
|
|
Загрузка…
Ссылка в новой задаче