
Supports embedding Tor into applications, enabling network privacy and security. Features include background service management, Unix domain socket support, and callback handling for non-coroutine environments.
Kotlin Multiplatform support for embedding Tor into your application.
val runtime = TorRuntime.Builder(myEnvironment) {
RuntimeEvent.entries().forEach { event ->
observerStatic(event, OnEvent.Executor.Immediate) { data ->
println(data.toString())
}
}
TorEvent.entries().forEach { event ->
observerStatic(event, OnEvent.Executor.Immediate) { data ->
println(data)
}
}
config { environment ->
TorOption.SocksPort.configure { auto() }
// ...
}
required(TorEvent.ERR)
required(TorEvent.WARN)
}// Asynchronous APIs
myScope.launch {
runtime.startDaemonAsync()
runtime.restartDaemonAsync()
runtime.executeAsync(TorCmd.Signal.NewNym)
runtime.stopDaemonAsync()
}// Synchronous APIs (Android/Jvm/Native)
runtime.startDaemonSync()
runtime.restartDaemonSync()
runtime.executeSync(TorCmd.Signal.NewNym)
runtime.stopDaemonSync()// Callback APIs
runtime.enqueue(
Action.StartDaemon,
OnFailure.noOp(),
OnSuccess {
runtime.enqueue(
Action.RestartDaemon,
OnFailure.noOp(),
OnSuccess {
runtime.enqueue(
TorCmd.Signal.NewNym,
OnFailure.noOp(),
OnSuccess {
runtime.enqueue(
Action.StopDaemon,
OnFailure.noOp(),
OnSuccess.noOp(),
)
},
)
},
)
},
)Add runtime dependency
dependencies {
implementation("io.matthewnelson.kmp-tor:runtime:2.6.0")
}If using Java9+, ensure you have defined module java.management for your application.
For Java or Android, see the NOTE for OnEvent.Executor.Main for when the
kotlinx-coroutines-{android/javafx/swing} UI dependency is needed.
Configure tor resources
Configure optional service dependency
Refer to the API docs
See kmp-tor-samples
Kotlin Multiplatform support for embedding Tor into your application.
val runtime = TorRuntime.Builder(myEnvironment) {
RuntimeEvent.entries().forEach { event ->
observerStatic(event, OnEvent.Executor.Immediate) { data ->
println(data.toString())
}
}
TorEvent.entries().forEach { event ->
observerStatic(event, OnEvent.Executor.Immediate) { data ->
println(data)
}
}
config { environment ->
TorOption.SocksPort.configure { auto() }
// ...
}
required(TorEvent.ERR)
required(TorEvent.WARN)
}// Asynchronous APIs
myScope.launch {
runtime.startDaemonAsync()
runtime.restartDaemonAsync()
runtime.executeAsync(TorCmd.Signal.NewNym)
runtime.stopDaemonAsync()
}// Synchronous APIs (Android/Jvm/Native)
runtime.startDaemonSync()
runtime.restartDaemonSync()
runtime.executeSync(TorCmd.Signal.NewNym)
runtime.stopDaemonSync()// Callback APIs
runtime.enqueue(
Action.StartDaemon,
OnFailure.noOp(),
OnSuccess {
runtime.enqueue(
Action.RestartDaemon,
OnFailure.noOp(),
OnSuccess {
runtime.enqueue(
TorCmd.Signal.NewNym,
OnFailure.noOp(),
OnSuccess {
runtime.enqueue(
Action.StopDaemon,
OnFailure.noOp(),
OnSuccess.noOp(),
)
},
)
},
)
},
)Add runtime dependency
dependencies {
implementation("io.matthewnelson.kmp-tor:runtime:2.6.0")
}If using Java9+, ensure you have defined module java.management for your application.
For Java or Android, see the NOTE for OnEvent.Executor.Main for when the
kotlinx-coroutines-{android/javafx/swing} UI dependency is needed.
Configure tor resources
Configure optional service dependency
Refer to the API docs
See kmp-tor-samples