Fixed possible NPE from uninitialised control connection.

This commit is contained in:
akwizgran
2016-05-06 09:21:27 +01:00
parent 2ecccc66d1
commit e36d1c8954

View File

@@ -217,13 +217,13 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
// Now we should be able to connect to the new process
controlSocket = new Socket("127.0.0.1", CONTROL_PORT);
}
running = true;
// Open a control connection and authenticate using the cookie file
controlConnection = new TorControlConnection(controlSocket);
controlConnection.authenticate(read(cookieFile));
// Tell Tor to exit when the control connection is closed
controlConnection.takeOwnership();
controlConnection.resetConf(Collections.singletonList(OWNER));
running = true;
// Register to receive events from the Tor process
controlConnection.setEventHandler(this);
controlConnection.setEvents(Arrays.asList(EVENTS));