[前][次][番号順一覧][スレッド一覧]

ruby-changes:44726

From: shugo <ko1@a...>
Date: Tue, 15 Nov 2016 17:16:50 +0900 (JST)
Subject: [ruby-changes:44726] shugo:r56799 (trunk): ftp.rb: use Addrinfo interfaces

shugo	2016-11-15 17:16:45 +0900 (Tue, 15 Nov 2016)

  New Revision: 56799

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56799

  Log:
    ftp.rb: use Addrinfo interfaces

  Modified files:
    trunk/lib/net/ftp.rb
    trunk/test/net/ftp/test_ftp.rb
Index: test/net/ftp/test_ftp.rb
===================================================================
--- test/net/ftp/test_ftp.rb	(revision 56798)
+++ test/net/ftp/test_ftp.rb	(revision 56799)
@@ -109,7 +109,8 @@ class FTPTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/ftp/test_ftp.rb#L109
   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)
Index: lib/net/ftp.rb
===================================================================
--- lib/net/ftp.rb	(revision 56798)
+++ lib/net/ftp.rb	(revision 56799)
@@ -431,7 +431,8 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L431
       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 https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L1247
         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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]