Issue #13382 has been updated by shugo (Shugo Maeda).


osa (Shunsuke OSA) wrote:
> > The default mode of Net::FTP is now passive, but do you really need the active mode?
> 
> In the real world, sometimes we have to connect FTP servers without passive mode support. But modern server environment such as clouds like AWS EC2, inbound port is strictly restricted. To connect to the server from such environment with active mode, we need a support of explicit incoming data port.

Understood.

> > Do you know any FTP client implementation which provides similar options?
> 
> Net::FTP of Perl has `port` method. (And it resembles to FTP PORT command)
> http://perldoc.perl.org/Net/FTP.html#port-(-[-PORT-]-)
> 
> I've considered an interface like `port(host, port)` but I think passing host to `port` method will confuse and `port` method is looks like getter method.

FTPClient of Apache Commons seems to have setActivePortRange() and setActiveExternalIPAddress().

https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html#setActiveExternalIPAddress(java.lang.String)

However, setActiveExternalIPAddress() seems to be for specifying the address to bind.


----------------------------------------
Feature #13382: [PATCH] Options for FTP PORT command
https://bugs.ruby-lang.org/issues/13382#change-63999

* Author: osa (Shunsuke OSA)
* Status: Open
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
* Target version: 
----------------------------------------
# Abstract

Add options to Net::FTP to set data listening host and port.

# Background

Net::FTP sends local address and default port to remote FTP server.
In FTP active mode, remote server will connect to client to establish data connection, but it will fail if there is NAT in network.
(NAT doesn't rewrite address and port in PORT command because they are not in packet header but payload)
So, it's necessary to set host and port for FTP PORT command explicitly.

# Real use cases

Active FTP is not working in AWS EC2.

- https://forums.aws.amazon.com/thread.jspa?messageID=75667 (Login required)
- http://osa.hatenablog.com/entry/2015/02/24/134826 (Japanese)

# Pull request

- https://github.com/ruby/ruby/pull/1561



-- 
https://bugs.ruby-lang.org/