Skip to content

Commit

Permalink
Update dependencies (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Jun 16, 2024
1 parent 7c73182 commit 7491f49
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 24 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
[![badge-kotlin]][url-kotlin]
[![badge-coroutines]][url-coroutines]
[![badge-encoding]][url-encoding]
[![badge-kmp-process]][url-kmp-process]
[![badge-kmp-tor-core]][url-kmp-tor-core]
[![badge-kotlincrypto-hash]][url-kotlincrypto-hash]
[![badge-kotlincrypto-secure-random]][url-kotlincrypto-secure-random]
[![badge-androidx-startup]][url-androidx-startup]

![badge-platform-android]
![badge-platform-jvm]
Expand All @@ -27,10 +31,14 @@ published until `2.0.0` work has been completed.
[badge-license]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat

<!-- TAG_DEPENDENCIES -->
[badge-kotlin]: https://img.shields.io/badge/kotlin-1.9.23-blue.svg?logo=kotlin
[badge-coroutines]: https://img.shields.io/badge/kotlinx.coroutines-1.8.0-blue.svg?logo=kotlin
[badge-androidx-startup]: https://img.shields.io/badge/androidx.startup-1.1.1-6EDB8D.svg?logo=android
[badge-coroutines]: https://img.shields.io/badge/kotlinx.coroutines-1.8.1-blue.svg?logo=kotlin
[badge-encoding]: https://img.shields.io/badge/encoding-2.2.1-blue.svg?style=flat
[badge-kmp-tor-core]: https://img.shields.io/badge/kmp--tor--core-2.0.0--alpha10-blue.svg?style=flat
[badge-kmp-process]: https://img.shields.io/badge/kmp--process-0.1.0--beta01-blue.svg?style=flat
[badge-kmp-tor-core]: https://img.shields.io/badge/kmp--tor--core-2.0.0-blue.svg?style=flat
[badge-kotlin]: https://img.shields.io/badge/kotlin-1.9.24-blue.svg?logo=kotlin
[badge-kotlincrypto-hash]: https://img.shields.io/badge/KotlinCrypto.hash-0.5.1-blue.svg?style=flat
[badge-kotlincrypto-secure-random]: https://img.shields.io/badge/KotlinCrypto.secure--random-0.3.1-blue.svg?style=flat

<!-- TAG_PLATFORMS -->
[badge-platform-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat
Expand All @@ -52,7 +60,11 @@ published until `2.0.0` work has been completed.
[url-1.x.x]: https://github.com/05nelsonm/kmp-tor/tree/1.x.x
[url-latest-release]: https://github.com/05nelsonm/kmp-tor/releases/latest
[url-license]: https://www.apache.org/licenses/LICENSE-2.0
[url-kotlin]: https://kotlinlang.org
[url-androidx-startup]: https://developer.android.com/jetpack/androidx/releases/startup
[url-coroutines]: https://github.com/Kotlin/kotlinx.coroutines
[url-encoding]: https://github.com/05nelsonm/component-encoding
[url-kmp-process]: https://github.com/05nelsonm/kmp-process
[url-kmp-tor-core]: https://github.com/05nelsonm/kmp-tor-core
[url-kotlin]: https://kotlinlang.org
[url-kotlincrypto-hash]: https://github.com/KotlinCrypto/hash
[url-kotlincrypto-secure-random]: https://github.com/KotlinCrypto/secure-random
9 changes: 2 additions & 7 deletions build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import io.matthewnelson.kmp.configuration.ExperimentalKmpConfigurationApi
import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
import io.matthewnelson.kmp.configuration.extension.container.target.TargetAndroidContainer
Expand All @@ -22,7 +21,6 @@ import org.gradle.api.JavaVersion

fun KmpConfigurationExtension.configureShared(
androidNamespace: String? = null,
java9ModuleName: String? = null,
publish: Boolean = false,
action: Action<KmpConfigurationContainerDsl>
) {
Expand All @@ -37,9 +35,6 @@ fun KmpConfigurationExtension.configureShared(
kotlinJvmTarget = JavaVersion.VERSION_1_8
compileSourceCompatibility = JavaVersion.VERSION_1_8
compileTargetCompatibility = JavaVersion.VERSION_1_8

@OptIn(ExperimentalKmpConfigurationApi::class)
java9MultiReleaseModuleInfo(java9ModuleName)
}

js {
Expand Down Expand Up @@ -78,8 +73,8 @@ fun KmpConfigurationExtension.configureShared(

fun KmpConfigurationContainerDsl.androidLibrary(
namespace: String,
buildTools: String? = "33.0.2",
compileSdk: Int = 33,
buildTools: String? = "34.0.0",
compileSdk: Int = 34,
minSdk: Int = 16,
javaVersion: JavaVersion = JavaVersion.VERSION_1_8,
action: (Action<TargetAndroidContainer.Library>)? = null,
Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ androidx-test-runner = "1.5.2"

encoding = "2.2.1"

gradle-android = "8.1.4"
gradle-android = "8.2.2"
gradle-binary-compat = "0.14.0"
gradle-kmp-configuration = "0.2.1"
gradle-kotlin = "1.9.23"
gradle-publish-maven = "0.27.0"
gradle-kmp-configuration = "0.2.2"
gradle-kotlin = "1.9.24"
gradle-publish-maven = "0.28.0"

kmp-process = "0.1.0-alpha03"
kmp-tor-core = "2.0.0-alpha10"
kmp-process = "0.1.0-beta01"
kmp-tor-core = "2.0.0"
kmp-tor-resource = "408.10.0-SNAPSHOT"
kotlinx-coroutines = "1.8.0"
kotlinx-coroutines = "1.8.1"

# Tests only
ktor = "2.3.11"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

# https://gradle.org/release-checksums/
distributionSha256Sum=85719317abd2112f021d4f41f09ec370534ba288432065f4b477b6a3b652910d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
7 changes: 6 additions & 1 deletion library/runtime-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import io.matthewnelson.kmp.configuration.ExperimentalKmpConfigurationApi

plugins {
id("configuration")
}

kmpConfiguration {
configureShared(java9ModuleName = "io.matthewnelson.kmp.tor.runtime.core", publish = true) {
configureShared(publish = true) {
jvm {
@OptIn(ExperimentalKmpConfigurationApi::class)
java9ModuleInfoName = "io.matthewnelson.kmp.tor.runtime.core"

sourceSetTest {
dependencies {
implementation(kotlin("reflect"))
Expand Down
8 changes: 7 additions & 1 deletion library/runtime-ctrl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import io.matthewnelson.kmp.configuration.ExperimentalKmpConfigurationApi
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.Family
import org.jetbrains.kotlin.konan.target.HostManager
Expand All @@ -22,7 +23,12 @@ plugins {
}

kmpConfiguration {
configureShared(java9ModuleName = "io.matthewnelson.kmp.tor.runtime.ctrl", publish = true) {
configureShared(publish = true) {
jvm {
@OptIn(ExperimentalKmpConfigurationApi::class)
java9ModuleInfoName = "io.matthewnelson.kmp.tor.runtime.ctrl"
}

common {
sourceSetMain {
dependencies {
Expand Down
7 changes: 6 additions & 1 deletion library/runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import io.matthewnelson.kmp.configuration.ExperimentalKmpConfigurationApi

plugins {
id("configuration")
}

kmpConfiguration {
configureShared(java9ModuleName = "io.matthewnelson.kmp.tor.runtime", publish = true) {
configureShared(publish = true) {
jvm {
@OptIn(ExperimentalKmpConfigurationApi::class)
java9ModuleInfoName = "io.matthewnelson.kmp.tor.runtime"

sourceSetTest {
dependencies {
implementation(kotlin("reflect"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package io.matthewnelson.kmp.tor.runtime.internal

import io.matthewnelson.kmp.file.File
import io.matthewnelson.kmp.tor.runtime.TorRuntime
import io.matthewnelson.kmp.tor.runtime.internal.process.TorDaemon
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.delay
import kotlin.time.Duration
Expand All @@ -30,6 +31,10 @@ internal expect inline fun TorRuntime.Environment.newRuntimeDispatcher(): Corout
@Throws(Throwable::class)
internal expect fun File.setDirectoryPermissions()

// TODO: https://github.com/05nelsonm/kmp-process/issues/108
@Throws(Throwable::class)
internal expect fun TorDaemon.kill(pid: Int)

// No matter the Delay implementation (Coroutines Test library)
// Will delay the specified duration using a TimeSource.
internal suspend fun timedDelay(duration: Duration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.matthewnelson.kmp.tor.core.api.ResourceInstaller
import io.matthewnelson.kmp.tor.runtime.*
import io.matthewnelson.kmp.tor.runtime.FileID.Companion.toFIDString
import io.matthewnelson.kmp.tor.runtime.RuntimeEvent.Notifier.Companion.d
import io.matthewnelson.kmp.tor.runtime.RuntimeEvent.Notifier.Companion.e
import io.matthewnelson.kmp.tor.runtime.RuntimeEvent.Notifier.Companion.i
import io.matthewnelson.kmp.tor.runtime.RuntimeEvent.Notifier.Companion.lce
import io.matthewnelson.kmp.tor.runtime.RuntimeEvent.Notifier.Companion.stderr
Expand All @@ -39,6 +40,7 @@ import io.matthewnelson.kmp.tor.runtime.core.address.IPSocketAddress.Companion.t
import io.matthewnelson.kmp.tor.runtime.core.apply
import io.matthewnelson.kmp.tor.runtime.core.ctrl.TorCmd
import io.matthewnelson.kmp.tor.runtime.ctrl.TorCtrl
import io.matthewnelson.kmp.tor.runtime.internal.*
import io.matthewnelson.kmp.tor.runtime.internal.InstanceKeeper
import io.matthewnelson.kmp.tor.runtime.internal.TorConfigGenerator
import io.matthewnelson.kmp.tor.runtime.internal.process.TorDaemon.StartArgs.Companion.createStartArgs
Expand Down Expand Up @@ -242,9 +244,28 @@ internal class TorDaemon private constructor(
// or via invokeOnCompletion handler.
val completion = Executable.Once.of(concurrent = true, executable = {
state.stopMark = TimeSource.Monotonic.markNow()
process.destroy()

try {
// TODO: https://github.com/05nelsonm/kmp-process/issues/108
// Node.js is awful, especially on Windows...
with(process) {
try {
destroy()
} catch (_: Throwable) {
NOTIFIER.w(this@TorDaemon, "Process.destroy threw exception, attempting to kill.")
}

if (!isAlive) return@with
val pid = pid()
if (pid < 1) return@with

try {
kill(pid)
} catch (t: Throwable) {
NOTIFIER.e(t)
}
}

NOTIFIER.lce(Lifecycle.Event.OnStop(this@TorDaemon))
} finally {
manager.update(TorState.Daemon.Off)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
package io.matthewnelson.kmp.tor.runtime.internal

import io.matthewnelson.kmp.tor.runtime.TorRuntime
import io.matthewnelson.kmp.tor.runtime.internal.process.TorDaemon
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers

@Suppress("NOTHING_TO_INLINE")
internal actual inline fun TorRuntime.Environment.newRuntimeDispatcher(): CoroutineDispatcher = Dispatchers.Main

// @Throws(Throwable::class)
@Suppress("ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT")
internal actual fun TorDaemon.kill(pid: Int) {
process_kill(pid, "SIGKILL")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
@file:JsModule("process")
@file:JsNonModule
@file:Suppress("FunctionName")

package io.matthewnelson.kmp.tor.runtime.internal

/** [docs](https://nodejs.org/api/process.html#processkillpid-signal) */
@JsName("kill")
internal external fun process_kill(pid: Number, signal: String)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import io.matthewnelson.kmp.tor.core.resource.OSHost
import io.matthewnelson.kmp.tor.core.resource.OSInfo
import io.matthewnelson.kmp.tor.runtime.FileID.Companion.fidEllipses
import io.matthewnelson.kmp.tor.runtime.TorRuntime
import io.matthewnelson.kmp.tor.runtime.internal.process.TorDaemon
import kotlinx.coroutines.*
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicLong
Expand All @@ -42,6 +43,9 @@ internal actual inline fun TorRuntime.Environment.newRuntimeDispatcher(): Corout
return executor.asCoroutineDispatcher()
}

@Throws(Throwable::class)
internal actual fun TorDaemon.kill(pid: Int) {}

@Throws(Throwable::class)
internal actual fun File.setDirectoryPermissions() {
@OptIn(InternalKmpTorApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,28 @@

package io.matthewnelson.kmp.tor.runtime.internal

import io.matthewnelson.kmp.file.errnoToIOException
import io.matthewnelson.kmp.tor.runtime.FileID.Companion.fidEllipses
import io.matthewnelson.kmp.tor.runtime.TorRuntime
import io.matthewnelson.kmp.tor.runtime.internal.process.TorDaemon
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.newSingleThreadContext
import platform.posix.SIGKILL
import platform.posix.errno

@Suppress("NOTHING_TO_INLINE")
internal actual inline fun TorRuntime.Environment.newRuntimeDispatcher(): CoroutineDispatcher {
@OptIn(DelicateCoroutinesApi::class, ExperimentalCoroutinesApi::class)
return newSingleThreadContext("Tor[$fidEllipses]")
}

@Throws(Throwable::class)
internal actual fun TorDaemon.kill(pid: Int) {
if (platform.posix.kill(pid, SIGKILL) == -1) {
@OptIn(ExperimentalForeignApi::class)
throw errnoToIOException(errno)
}
}

0 comments on commit 7491f49

Please sign in to comment.