Connecting to TOR Java

I looked at the silvertunnel library but tried to build a successful connection. The problem I'm running into is that it takes more than 10 minutes to get the output. I was going through one of my tests and this is my code:

public boolean tryConnOLD() throws IOException {

    try {
        // define remote address
        String remoteHostname = "http://test.silvertunnel.com";
        int remotePort = 80;
        TcpipNetAddress remoteAddress = new TcpipNetAddress(remoteHostname, remotePort);
        // get TorNetLayer instance and wait until it is ready
        NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);
        netLayer.waitUntilReady();
        // open connection to remote address - this connection is tunneled through the TOR anonymity network
        netSocket = netLayer.createNetSocket(null, null, remoteAddress);
        InputStream is = netSocket.getInputStream();

        String content = CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8));
        Closeables.closeQuietly(is);

        is.close();
        System.out.println(is.read());
        java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");

        if(s.hasNext()) {
         System.out.println(s.next());   
         System.out.println();   
        }

        return true;

    } catch (IOException ex) {

    } finally {
        netSocket.close();
    }

    return false;
}

      

+3


source to share


1 answer


The problem is quite simple, when you are using the silvertunnel API you don't need to specify the protocol in the url, so a simple removal http://

should fix your mistakes.

try the following



                        //remove http://   
String remoteHostname = "test.silvertunnel.com";

      

+2


source







All Articles