Skip to content

topl-core-base / io.matthewnelson.topl_core_base / TorConfigFiles / Builder

Builder

class Builder (source)

Builder for TorConfig.

See also Companion.createConfig for convenience methods.

//  fun customTorConfigFilesSetup(context: Context): TorConfigFiles {

        // This is modifying the directory hierarchy from TorService's
        // default setup. For example, if you are using binaries for Tor that
        // are named differently that that expressed in TorConfigFiles.createConfig()

        // Post Android API 28 requires that executable files be contained in your
        // application's data/app directory, as they can no longer execute from data/data.
        val installDir = File(context.applicationInfo.nativeLibraryDir)

        // Will create a directory within your application's data/data dir
        val configDir = context.getDir("torservice", Context.MODE_PRIVATE)

        val builder = TorConfigFiles.Builder(installDir, configDir)

        // Customize the tor executable file name. Requires that the executable file
        // be in your module's src/main/jniLibs directory. If you are getting your
        // executable files via a dependency be sure to consult that Library's documentation.
        builder.torExecutable(File(installDir, "libtor.so"))

        // customize further via the builder methods...

        return builder.build()
//  }

Parameters

installDir - directory where the tor binaries are installed.

configDir - directory where the filesystem will be setup for tor.

Constructors

Name Summary
<init> Builder for TorConfig.Builder(installDir:File, configDir:File)

Functions

Name Summary
build Builds torConfig and sets default values if not explicitly configured through builder.fun build():TorConfigFiles
cookieAuthFile fun cookieAuthFile(file:File): Builder
dataDir Store working data in DIR. Can not be changed while tor is running.fun dataDir(directory:File): Builder
fileCreationTimeout When tor starts it waits for the control port and cookie auth files to be created before it proceeds to the next step in startup. If these files are not created after a certain amount of time, then the startup has failed.fun fileCreationTimeout(timeoutSeconds:Int): Builder
geoip A filename containing IPv4 GeoIP data, for use with by-country statistics.fun geoip(file:File): Builder
geoipv6 A filename containing IPv6 GeoIP data, for use with by-country statistics.fun geoipv6(file:File): Builder
hiddenServiceDir Store data files for a hidden service in DIRECTORY. Every hidden service must have a separate directory. You may use this option multiple times to specify multiple services. If DIRECTORY does not exist, Tor will create it. (Note: in current versions of Tor, if DIRECTORY is a relative path, it will be relative to the current working directory of Tor instance, not to its DataDirectory. Do not rely on this behavior; it is not guaranteed to remain the same in future versions.)fun hiddenServiceDir(directory:File): Builder
hostnameFile fun hostnameFile(file:File): Builder
libraryPath fun libraryPath(directory:File): Builder
resolveConf fun resolveConf(resolveConf:File): Builder
torExecutable fun torExecutable(file:File): Builder
torrc The configuration file, which contains “option value” pairs.fun torrc(file:File): Builder
v3AuthPrivateDir fun v3AuthPrivateDir(directory:File): Builder