TorApi
Abstraction for ResourceLoader.Tor.NoExec implementations to provide.
Implementations of TorApi must support restart capabilities. The only reliable way to do this with the tor
C library is dynamic loading/unloading before/after each invocation of tor_run_main
. This is due to static variables in tor
that are never uninitialized, requiring that it be unloaded from memory via dlclose
(or FreeLibrary
for Windows
) after tor_run_main
completes and all necessary cleanup has been performed. If tor
is not unloaded after completion of tor_run_main
, successive calls to torRunMain run the highly probable risk of encountering a segmentation fault. The API design of TorApi was conceived with this necessity in mind.
Functions
Terminates tor (if it is running) and releases resources. This MUST be called before another invocation of torRunMain can be had.
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.
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.