Orchid icon indicating copy to clipboard operation
Orchid copied to clipboard

New tor circuit?

Open ramsestom opened this issue 9 years ago • 2 comments

How can I request a new Tor circuit (to change my output IP) from a started TorClient? I do not found any documentation to help... Thanks

ramsestom avatar Jan 16 '16 00:01 ramsestom

yeah i would love to know the same thing, and maybe even implementing 2 connections at the same time so if one fails it automatically falls back to the other one so I dont get disconnected

thelegendmink avatar Aug 14 '16 13:08 thelegendmink

In my experience, every time you create a new socket connection over tor your output ip will change.

Sudo Code:

        TorClient client = //initialized somehow
        String host = //initialized somehow
        String path = //initialized somehow
        String query = //initialized somehow
        Socket socket = client.getSocketFactory().createSocket(host, 80);
        PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);
        InputStream inputStream = socket.getInputStream();
        writer.println("GET "+path+query+" HTTP/1.0");
        writer.println("Host: "+host);
        writer.println("Connection: close");
        writer.println("");
        writer.flush();

For instance, I have a wrapper project tor Orchid. By slightly modifying one of my HTTP GET request example you will be able to see the change in IP address with every request.

        TorRequest.openTunnel();
        TorRequest whatIsMyIp = TorRequest.getInstance("http://ip-api.com/json");
        try{
            whatIsMyIp.executeRequest();
            System.out.println("Attempt #1: "+whatIsMyIp.getResponse().getContent());
            Thread.sleep(100l);
        } catch(Exception e){
            System.out.println("Attempt #1 Failed: "+e.getMessage());
        }
        try{
            whatIsMyIp.executeRequest();
            System.out.println("Attempt #2: "+whatIsMyIp.getResponse().getContent());
            Thread.sleep(100l);
        } catch(Exception e){
            System.out.println("Attempt #2 Failed: "+e.getMessage());
        }
        try{
            whatIsMyIp.executeRequest();
            System.out.println("Attempt #3: "+whatIsMyIp.getResponse().getContent());
        } catch(Exception e){
            System.out.println("Attempt #3 Failed: "+e.getMessage());
        }
        TorRequest.closeTunnel();

frypatch avatar Aug 15 '16 12:08 frypatch