Initializer
init(socket:dataDirectory:)
Wrap an existing ControlSocket.
init(socket: ControlSocket, dataDirectory: String? = nil)
Parameters
-
socket
-
The underlying transport. Ownership is shared; the client does not close the socket on deinit.
-
dataDirectory
-
Optional path to Tor’s data directory. When non-nil, authenticate(password:) will try cookie authentication by reading <dataDir>/control_auth_cookie.
Discussion
The primary low-level initialiser. Use when the caller already has a ControlSocket in hand — typically because they constructed one from a TCP endpoint or are injecting a mock for tests. The socket may be freshly-connected or already authenticated externally.
Note
Freshly constructed instances have isAuthenticated = false. Callers must explicitly invoke authenticate(password:) before issuing any other command.