aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-15 01:39:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-15 01:39:10 +0000
commitd01a919a1739fd91bad0e7cb7cd3e0ecd1300d80 (patch)
tree3673d55aa881e43aa2cd1ed1ce6799894e8437b8
parentd456bd473413a8e27ee543051bdf3505c659d544 (diff)
downloadruby-d01a919a1739fd91bad0e7cb7cd3e0ecd1300d80.tar.gz
ftp.rb: use Addrinfo
* lib/net/ftp.rb (sendport, makeport, makepasv, BufferedSocket): use Addrinfo interfaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/net/ftp.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index baa163d04d..c2c5e8ce7f 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -381,10 +381,10 @@ module Net
# Constructs and send the appropriate PORT (or EPRT) command
def sendport(host, port) # :nodoc:
- af = (@sock.peeraddr)[0]
- if af == "AF_INET"
+ remote_address = @sock.remote_address
+ if remote_address.ipv4?
cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
- elsif af == "AF_INET6"
+ elsif remote_address.ipv6?
cmd = sprintf("EPRT |2|%s|%d|", host, port)
else
raise FTPProtoError, host
@@ -395,13 +395,13 @@ module Net
# Constructs a TCPServer socket
def makeport # :nodoc:
- TCPServer.open(@sock.addr[3], 0)
+ TCPServer.open(@sock.local_address.ip_address, 0)
end
private :makeport
# sends the appropriate command to enable a passive connection
def makepasv # :nodoc:
- if @sock.peeraddr[0] == "AF_INET"
+ if @sock.remote_address.ipv4?
host, port = parse227(sendcmd("PASV"))
else
host, port = parse229(sendcmd("EPSV"))
@@ -1283,7 +1283,7 @@ module Net
end
class BufferedSocket < BufferedIO
- [:addr, :peeraddr, :send, :shutdown].each do |method|
+ [:local_address, :remote_address, :addr, :peeraddr, :send, :shutdown].each do |method|
define_method(method) { |*args|
@io.__send__(method, *args)
}