2
我的應用程序成功使用Tor,但我想發送NEWNYM請求以獲取新的身份。我可以殺死並重啓進程,或者可能使用shell腳本,但我更願意在本地Java中執行此操作。使用Java發送Tor NEWNYM請求
有一個Python solution,但我不太清楚如何將它映射到Java連接類型。我想這與我的Tor HTTP代碼非常相似,但我對Java連接類型不熟悉。
// My starter code.
public static String torNewIP() throws Exception {
Proxy proxy = new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(TOR_IP, TOR_CONTROL_PORT));
// This is how I open a web page using Tor, but the control
// port is probably not HTTP.
// HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
// connection.connect();
// Something like connection.send("NEWNYM");
}