Initializer
init(host:port:dataDirectory:)
Open a TCP connection to a listening Tor control port and wrap it.
convenience init(host: String, port: Int, dataDirectory: String? = nil) throws
Parameters
-
host
-
IPv4 literal or DNS name of the control-port host.
-
port
-
TCP port (typically 9051).
-
dataDirectory
-
Optional path to the daemon’s data directory, used by authenticate(password:) for cookie-based authentication.
Discussion
Convenience for the external-Tor scenario: an already-running tor daemon is exposing its control port over TCP (typically 127.0.0.1:9051) and swift-tor wants to drive it. The underlying ControlSocket owns the FD and closes it on deinit.
Throws
TorError.ioError(_:) on socket/connect/DNS failure propagated from init(host:port:).
Important
The resulting client is not authenticated. Call authenticate(password:) before any other command.