Java: Tor HTTP Request using Silvertunnel Netlib

3.2k Views Asked by At

I'm trying to make an anonymized HTTP-request from within a Java application over the Tor network using Silvertunnel Netlib (https://silvertunnel.org/doc/netlib.html). I'm using the example code, which works when making the request over TCPIP but when using the TOR setting, it ends with the following exception (after about 10 minutes of trying to connect):

java.io.IOException: Tor.connect: unable to connect to null:80 after 11 full retries with 5 sub retries
    at org.silvertunnel.netlib.layer.tor.clientimpl.Tor.connect(Tor.java:281)
    at org.silvertunnel.netlib.layer.tor.TorNetLayer.createNetSocket(TorNetLayer.java:113)
    at org.silvertunnel.netlib.util.HttpUtil.get(HttpUtil.java:121)
    at FlightBot.main(FlightBot.java:48)

Here is the code I'm using:

NetLayer lowerNetLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);

// wait until TOR is ready (optional) - this is only relevant for anonymous communication:
lowerNetLayer.waitUntilReady();

// prepare parameters (http default port: 80)
TcpipNetAddress httpServerNetAddress = new TcpipNetAddress("httptest.silvertunnel.org", 80);
String pathOnHttpServer = "/httptest/bigtest.jsp?id=example";
long timeoutInMs = 5000;

// do the HTTP request and wait for the response
byte[] responseBody = HttpUtil.getInstance().get(lowerNetLayer, httpServerNetAddress, pathOnHttpServer, timeoutInMs);

// print out the response
System.out.println(new String(responseBody));

Am I doing something wrong or is the Tor network just currently unavailable?

To be clear, it works when using:

NetLayer lowerNetLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TCPIP)

on the first line.

1

There are 1 best solutions below

3
On BEST ANSWER

The problem is the underlying Tor implementation. The Tor network evolved and not all changes have been implemented into Silvertunnel Netlib. The silvertunnel project has been stopped due to personal reasons. I've created a new version: SilverTunnel-NG which is a fork of the original project.

Now the connections to the Tor network are working again.

Hope this is not too late for you :)