Initializer
init(fileDescriptor:preAuthenticated:dataDirectory:)
Wrap a raw file descriptor, optionally marking it as pre-authenticated.
init(fileDescriptor: Int32, preAuthenticated: Bool = false, dataDirectory: String? = nil)
Parameters
-
fileDescriptor
-
A valid, connected control-socket FD.
-
preAuthenticated
-
When true, isAuthenticated starts as true and authenticate(password:) is a no-op. Defaults to false.
-
dataDirectory
-
Optional path to Tor’s data directory (for cookie-based authentication on non-embedded sockets).
Mentioned In
Discussion
The primary embedded-mode initialiser. Swift-tor passes the FD returned by tor_main_configuration_setup_control_socket() with preAuthenticated: true, because the tor_api control socket is granted full control access without going through AUTHENTICATE.
Important
The wrapper does not take ownership of the FD (ownsDescriptor: false is passed to ControlSocket). Caller (usually stop()) is responsible for closing the FD when the Tor instance exits.