Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using FTP Proxy with apache commons-net

I want to set up an FTP connection using a proxy server with Apache's commons-net.

But looking at this Does FTPClient support FTP connections through an FTP proxy server? has me worried.

I have to meddle with the system properties and the Sun docs state that "If socksProxyHost is specified then all TCP sockets will use the SOCKS proxy server to establish a connection or accept one."
WTH? All TCP sockets? What about my database connections? Or other FTP connections i might want to open at the same time not using a proxy? Will they all be affected?

Is there some other way to do it that doesn't mess with the rest of my application?

like image 813
Stroboskop Avatar asked Jul 09 '09 14:07

Stroboskop


People also ask

Can you FTP proxy?

The FTP proxy functions as a relay for the File Transfer Protocol to enable you control connections based upon source and destination addresses and user authentication. It can also limit access to certain file transfer commands, such as put and get , based on source or destination addresses and user authentication.

What is HTTP FTP proxy?

A configuration to proxy browser-based connections to FTP sites. “FTP-over-HTTP” refers to proxying browser-based connections to FTP sites.


1 Answers

You have several ways of using proxies in Java, especially from version 1.5.

  1. Using System Properties: quick & powerfull but limited flexibility
    • You can use use a SOCKS proxy for all TCP connections.
    • You can also set a proxy per protocol, doable for HTTP, FTP and HTTPS
    • For both methods, you can specify a list of hosts that will not use proxy
  2. Using the java.net.Proxy class (Java 1.5+) to set (or not) a Proxy per Connection
  3. Impleting a java.net.ProxySelector (idem) which will determine a Proxy for each Connection according to your criteria

See the detailled Sun technote on networking & proxies.

like image 58
instanceof me Avatar answered Oct 19 '22 11:10

instanceof me