I have a customer whose FTP Server is not correctly configured. They will not change it, which is very frustrating. When my FTPS Client issues the PASV command, the server responds with its local IP address and a port number. It should of course respond with the public IP, if the FTP Server was configured correctly. The TSslFtpClient tries to connect to the local IP that is sent by the server, but obviously fails, as the local IP is hidden behind a NAT router. I noticed that the FileZilla Client gets round this problem by trying the local IP and when it fails it then tries the public IP that it originally connected to.
Command: PASV
Response: 227 Entering Passive Mode (192,168,0,173,113,168).
Status: Server sent passive reply with unroutable address. Using server address instead.
My Delphi skills are awful (I code in C++ Builder), so I can't attempt to replicate what FileZilla does. I have made two small changes to my copy of OverbyteIcsFtpCli.pas. I apologise for the poor code, but can anyone tell me if this is OK to do to or if there is a better way.
This code is added to DoGetAsync and DoPutAppendAsync
if (FDnsResult <> TargetIP) and (FDnsResult.Length > 0) then
DataSocketGetInit(IntToStr(TargetPort), FDnsResult)
else
DataSocketGetInit(IntToStr(TargetPort), TargetIP);
The original code was just
DataSocketGetInit(IntToStr(TargetPort), TargetIP);
Thanks,
Richard