Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tor circuit? #21

Open
ramsestom opened this issue Jan 16, 2016 · 2 comments
Open

New tor circuit? #21

ramsestom opened this issue Jan 16, 2016 · 2 comments

Comments

@ramsestom
Copy link

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 ramsestom changed the title New tor circuit New tor circuit? Jan 16, 2016
@thelegendmink
Copy link

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

@frypatch
Copy link

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants