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:
parent
c4e660457f
commit
af36e316d7
@ -431,7 +431,8 @@ module Net
|
|||||||
else
|
else
|
||||||
sock = makeport
|
sock = makeport
|
||||||
begin
|
begin
|
||||||
sendport(sock.addr[3], sock.addr[1])
|
addr = sock.local_address
|
||||||
|
sendport(addr.ip_address, addr.ip_port)
|
||||||
if @resume and rest_offset
|
if @resume and rest_offset
|
||||||
resp = sendcmd("REST " + rest_offset.to_s)
|
resp = sendcmd("REST " + rest_offset.to_s)
|
||||||
if !resp.start_with?("3")
|
if !resp.start_with?("3")
|
||||||
@ -1246,7 +1247,7 @@ module Net
|
|||||||
raise FTPReplyError, resp
|
raise FTPReplyError, resp
|
||||||
end
|
end
|
||||||
if m = /\((?<d>[!-~])\k<d>\k<d>(?<port>\d+)\k<d>\)/.match(resp)
|
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
|
else
|
||||||
raise FTPProtoError, resp
|
raise FTPProtoError, resp
|
||||||
end
|
end
|
||||||
|
@ -109,7 +109,8 @@ class FTPTest < Test::Unit::TestCase
|
|||||||
def test_parse229
|
def test_parse229
|
||||||
ftp = Net::FTP.new
|
ftp = Net::FTP.new
|
||||||
sock = OpenStruct.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)
|
ftp.instance_variable_set(:@sock, sock)
|
||||||
host, port = ftp.send(:parse229, "229 Entering Passive Mode (|||3106|)")
|
host, port = ftp.send(:parse229, "229 Entering Passive Mode (|||3106|)")
|
||||||
assert_equal("1080:0000:0000:0000:0008:0800:200c:417a", host)
|
assert_equal("1080:0000:0000:0000:0008:0800:200c:417a", host)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user