How to FTP through a SOCKS proxy

Please refer to the topic SOCKS Proxies for more information on this.

To direct socket communications via a SOCKS proxy, the ProxySettings of the client must be set appropriately. An example is shown below:

ProFTPClient ftp = new ProFTPClient();
ftp.getProxySettings().setProxyAddress("myinternalproxyaddress");
ftp.getProxySettings().setProxyPort(1080);
ftp.getProxySettings().setProxyPassword("myuser");
ftp.getProxySettings().setProxyUserName("mypassword");
ftp.getProxySettings().setPublicProxyAddress("mypublicproxy");
ftp.getProxySettings().setProxyType(ProxyType.SOCKS5); 

Note that the public proxy address is generally only required when using FTP in active mode. In this situation, the PORT command must advertise the public proxy address to the FTP server that will be connecting back to the client.

To use SOCKS4, simply use ProxyType.SOCKS4. The password is not required for SOCKS4, as authentication is not supported in SOCKS4.

SecureFileTransferClient, SSLFTPClient, SSHFTPClient, and ProFTPClient all support the use of a SOCKS proxy.