erlang/otp — pull request #492 by vinsentru (2014-10-02 00:00:34+00:00)
Title: inets ftp.erl patched to support override option which ignore (wrong) ad...

...dress from PASV

Some mis-configured FTP servers behind NAT returns on PASV command their internal private address, instead of external one, and FTP client is obviously unable to connect using that address. There is no good way to fix this issue automatically, because there is a little possibility that someone will use different addresses for FTP control and data connections. Some FTP clients (like lftp) automatically fix such issues and use correct address.
Erlang OTP FTP module just unable to work with such servers at all.

My patch is to add option "override" to control FTP client behavior in passive mode. With {override,true} passive connection will always made to address used by control connection, i.e. address specified in the ftp:open call.
As i can see this is already implemented for inet6 protocol (only port form PASV response is used and addres ignored), but for inet protocol address returned by PASV command is still used.
Default option value is {override,false}

Patch is very easy and shouldn't broke anything. I've just added option handling, storing option value in the State and a new version of handle_ctrl_result with override = true condition.