torRunMain

fun torRunMain(configuration: List<String>)(source)

Executes tor's tor_run_main function. If it does not throw, tor has been started. A following call to terminateAndAwaitResult MUST be had before calling torRunMain again.

Callers are expected to poll state for a value of State.STOPPED, then call terminateAndAwaitResult to release resources.

NOTE: argv[0] is always set to "tor" when converting configuration to an array to pass to the implementation.

NOTE: This is a blocking API and should be called from a background thread.

e.g.

torRunMain(listOf("--SocksPort", "0", "--verify-config"))

Parameters

configuration

Arguments to populate tor's tor_main_configuration_t struct with.

Throws

IllegalStateException

If State is not State.OFF, or there was an issue with startup.

If there was an issue extracting tor to the filesystem.


protected abstract fun torRunMain(args: Array<String>)(source)

Design is such that implementations must start tor in its own thread and return upon successful startup. Any errors must be thrown as the annotated exceptions and state must be reset to State.OFF.