Java telnet connection to request new tor identity

571 views Asked by At

I'm trying to use telnet to request a new identity for tor. From my understanding, you're supposed to send

authenticate ""

and then if the response is "250 OK" send

signal newnym

Using this code, I get a response of "null." I have also used several telnet client libraries and get the same kind of results.

try {
        Socket socket = new Socket("localhost", 9050);
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        out.println("authenticate \"\"");
        System.out.println(in.readLine()); //should be 250 but is null

        out.close();
        in.close();
        socket.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
1

There are 1 answers

0
defectus On

The documentation says that all commands are case sensitive. So you should be sending them in UPPER case (as per documentation).

I also found that a valid new identity request looks like

AUTHENTICATE
250 OK
SIGNAL NEWNYM
250 OK

Hope that helps!