- Tor
- TorConfiguration
- init(dataDirectory:cacheDirectory:socksPort:cookieAuthentication:controlPassword:extraArgs:ownsDataDirectory:)
Initializer
init(dataDirectory:cacheDirectory:socksPort:cookieAuthentication:controlPassword:extraArgs:ownsDataDirectory:)
Memberwise initialiser with sensible defaults for every field.
init(dataDirectory: String, cacheDirectory: String? = nil, socksPort: PortPolicy = .ephemeral, cookieAuthentication: Bool = false, controlPassword: String? = nil, extraArgs: [String] = [], ownsDataDirectory: Bool = false)
Parameters
-
dataDirectory
-
Required filesystem path for Tor state. See dataDirectory for collision rules.
-
cacheDirectory
-
Optional consensus-cache path for warm-boot performance; defaults to nil (cache lives inside dataDirectory).
-
socksPort
-
SOCKS port policy. Defaults to PortPolicy.ephemeral.
-
cookieAuthentication
-
Enable torrc CookieAuthentication. Defaults to false — the embedded control socket is pre-authenticated so this is rarely needed.
-
controlPassword
-
Optional HashedControlPassword value.
-
extraArgs
-
Escape-hatch argv pairs; defaults to [].
-
ownsDataDirectory
-
Whether to delete dataDirectory on stop(). Defaults to false.
Discussion
Construct a TorConfiguration directly when the convenience factories (makeDefault(), ephemeral(cacheDirectory:)) do not fit — e.g. a stable app-scoped data directory combined with a fixed 9050 SOCKS port for downstream compatibility. All optional parameters default to the values that most embedded deployments want; override only what you need to change.