Orchid
Orchid copied to clipboard
New tor circuit?
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
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
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();