javaprogram using tor

Juliusz Chroboczek jch at pps.jussieu.fr
Sun Oct 28 20:36:56 UTC 2007


> i have searched the FAQ's and find the Torlib, and i cannot find
> where to download it or any sample of it.  And cannot find exactly
> how can i use it in my program.  Is there any other way to connect
> my java program to "tor", or kindly point me to something useful..

Tor appears to client applications as a SOCKS proxy.  Sun's JDK can
speak SOCKS out of the box if you set the system properties
socksProxyHost and socksProxyPort.

So I believe that your Java application will automatically go through
tor if you do

  java -DsocksProxyHost=localhost -DsocksProxyPort=9050 AlicesRestaurant

Alternatively, you could modify your application to explicitly use
a SOCKS proxy by creating your sockets as so:

  new Socket(new Proxy(Proxy.Type.SOCKS,
                       new InetSocketAddress("127.0.0.1", 9050)));

Note however that Java most probably implements SOCKS with IP
addresses, and unless you take special precautions, you will suffer
from DNS leaks.  Which may or may not be a problem for your application.

                                        Juliusz



More information about the tor-talk mailing list