Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __ReloadTorrcOnSIGHUP 0 (false) to default config #426

Merged
merged 3 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions library/runtime-core/api/runtime-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2915,9 +2915,10 @@ public final class io/matthewnelson/kmp/tor/runtime/core/TorConfig$__OwningContr

public final class io/matthewnelson/kmp/tor/runtime/core/TorConfig$__ReloadTorrcOnSIGHUP : io/matthewnelson/kmp/tor/runtime/core/TorConfig$Setting$Builder {
public static final field Companion Lio/matthewnelson/kmp/tor/runtime/core/TorConfig$__ReloadTorrcOnSIGHUP$Companion;
public field reload Z
}

public final class io/matthewnelson/kmp/tor/runtime/core/TorConfig$__ReloadTorrcOnSIGHUP$Companion : io/matthewnelson/kmp/tor/runtime/core/TorConfig$Keyword {
public final class io/matthewnelson/kmp/tor/runtime/core/TorConfig$__ReloadTorrcOnSIGHUP$Companion : io/matthewnelson/kmp/tor/runtime/core/TorConfig$Setting$Factory {
}

public final class io/matthewnelson/kmp/tor/runtime/core/TorConfig$__SbwsExit : io/matthewnelson/kmp/tor/runtime/core/TorConfig$Setting$Builder {
Expand Down Expand Up @@ -3498,7 +3499,7 @@ public final class io/matthewnelson/kmp/tor/runtime/core/ctrl/TorCmd$Config$Rese
public fun <init> ([Lio/matthewnelson/kmp/tor/runtime/core/TorConfig$Keyword;)V
}

public final class io/matthewnelson/kmp/tor/runtime/core/ctrl/TorCmd$Config$Save : io/matthewnelson/kmp/tor/runtime/core/ctrl/TorCmd$Unprivileged {
public final class io/matthewnelson/kmp/tor/runtime/core/ctrl/TorCmd$Config$Save : io/matthewnelson/kmp/tor/runtime/core/ctrl/TorCmd$Privileged {
public final field force Z
public fun <init> ()V
public fun <init> (Z)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,28 @@ public class TorConfig private constructor(
)
}

/**
* [__ReloadTorrcOnSIGHUP](https://spec.torproject.org/control-spec/implementation-notes.html?highlight=__#special-config-options)
* */
@KmpTorDsl
public class __ReloadTorrcOnSIGHUP private constructor(): Setting.Builder(
keyword = Companion,
) {

@JvmField
public var reload: Boolean = true

public companion object: Setting.Factory<__ReloadTorrcOnSIGHUP, Setting>(
name = "__ReloadTorrcOnSIGHUP",
default = true.byte.toString(),
attributes = emptySet(),
isCmdLineArg = true,
isUnique = true,
factory = { __ReloadTorrcOnSIGHUP() },
build = { build(reload.byte.toString())!! },
)
}

/**
* [CacheDirectory](https://github.com/05nelsonm/kmp-tor-resource/blob/master/docs/tor-man.adoc#CacheDirectory)
* */
Expand Down Expand Up @@ -1994,21 +2016,7 @@ public class TorConfig private constructor(
)
}

/**
* [__ReloadTorrcOnSIGHUP](https://spec.torproject.org/control-spec/implementation-notes.html?highlight=__#special-config-options)
* */
@KmpTorDsl
public class __ReloadTorrcOnSIGHUP private constructor(): Setting.Builder(
keyword = Companion,
) {
public companion object: Keyword(
name = "__ReloadTorrcOnSIGHUP",
default = true.byte.toString(),
attributes = emptySet(),
isCmdLineArg = true,
isUnique = true,
)
}
// (IMPLEMENTED) __ReloadTorrcOnSIGHUP

/**
* [__SbwsExit](https://spec.torproject.org/control-spec/implementation-notes.html?highlight=__#special-config-options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public sealed class TorCmd<Success: Any> private constructor(
public class Save(
@JvmField
public val force: Boolean,
): Unprivileged<Reply.Success.OK>("SAVECONF") {
): Privileged<Reply.Success.OK>("SAVECONF") {

/** Default of [force] = `false` */
public constructor(): this(force = false)
Expand Down Expand Up @@ -439,7 +439,6 @@ public sealed class TorCmd<Success: Any> private constructor(
* */
public data object Signal {

public data object Reload: Unprivileged<Reply.Success.OK>("SIGNAL")
public data object Dump: Unprivileged<Reply.Success.OK>("SIGNAL")
public data object Debug: Unprivileged<Reply.Success.OK>("SIGNAL")

Expand All @@ -453,6 +452,7 @@ public sealed class TorCmd<Success: Any> private constructor(
public data object Active: Unprivileged<Reply.Success.OK>("SIGNAL")
public data object Dormant: Unprivileged<Reply.Success.OK>("SIGNAL")

public data object Reload: Unprivileged<Reply.Success.OK>("SIGNAL")
public data object Shutdown: Privileged<Reply.Success.OK>("SIGNAL")
public data object Halt: Privileged<Reply.Success.OK>("SIGNAL")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ internal fun TorCmd<*>.encodeToByteArray(LOG: Debugger?): ByteArray = when (this
is TorCmd.Ownership.Take -> encode(LOG)
is TorCmd.Resolve -> encode(LOG)
is TorCmd.SetEvents -> encode(LOG)
is TorCmd.Signal.Reload -> encodeSignal(LOG)
is TorCmd.Signal.Dump -> encodeSignal(LOG)
is TorCmd.Signal.Debug -> encodeSignal(LOG)
is TorCmd.Signal.NewNym -> encodeSignal(LOG)
is TorCmd.Signal.ClearDnsCache -> encodeSignal(LOG)
is TorCmd.Signal.Heartbeat -> encodeSignal(LOG)
is TorCmd.Signal.Active -> encodeSignal(LOG)
is TorCmd.Signal.Dormant -> encodeSignal(LOG)
is TorCmd.Signal.Reload -> encodeSignal(LOG)
is TorCmd.Signal.Shutdown -> encodeSignal(LOG)
is TorCmd.Signal.Halt -> encodeSignal(LOG)
}

internal fun TorCmd<*>.signalNameOrNull(): String? = when (this) {
is TorCmd.Signal.Reload -> "RELOAD"
is TorCmd.Signal.Dump -> "DUMP"
is TorCmd.Signal.Debug -> "DEBUG"
is TorCmd.Signal.NewNym -> "NEWNYM"
is TorCmd.Signal.ClearDnsCache -> "CLEARDNSCACHE"
is TorCmd.Signal.Heartbeat -> "HEARTBEAT"
is TorCmd.Signal.Active -> "ACTIVE"
is TorCmd.Signal.Dormant -> "DORMANT"
is TorCmd.Signal.Reload -> "RELOAD"
is TorCmd.Signal.Shutdown -> "SHUTDOWN"
is TorCmd.Signal.Halt -> "HALT"
else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ internal fun TorCmdJob<*>.respond(replies: ArrayList<Reply>) {
is TorCmd.Ownership.Take -> completeOK()
is TorCmd.Resolve -> completeOK()
is TorCmd.SetEvents -> completeOK()
is TorCmd.Signal.Reload -> completeOK()
is TorCmd.Signal.Dump -> completeOK()
is TorCmd.Signal.Debug -> completeOK()
is TorCmd.Signal.NewNym -> completeOK()
is TorCmd.Signal.ClearDnsCache -> completeOK()
is TorCmd.Signal.Heartbeat -> completeOK()
is TorCmd.Signal.Active -> completeOK()
is TorCmd.Signal.Dormant -> completeOK()
is TorCmd.Signal.Reload -> completeOK()
is TorCmd.Signal.Shutdown -> completeOK()
is TorCmd.Signal.Halt -> completeOK()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public fun interface ConfigBuilderCallback: ThisBlock.WithIt<TorConfig.Builder,
put(TorConfig.DisableNetwork) { disable = true }
put(TorConfig.RunAsDaemon) { enable = false }
put(TorConfig.__OwningControllerProcess) { /* default */ }
put(TorConfig.__ReloadTorrcOnSIGHUP) { reload = false }
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import io.matthewnelson.kmp.file.resolve
import io.matthewnelson.kmp.file.toFile
import io.matthewnelson.kmp.tor.core.api.ResourceInstaller
import io.matthewnelson.kmp.tor.core.api.ResourceInstaller.Paths
import io.matthewnelson.kmp.tor.core.api.annotation.InternalKmpTorApi
import io.matthewnelson.kmp.tor.runtime.ConfigBuilderCallback
import io.matthewnelson.kmp.tor.runtime.RuntimeEvent
import io.matthewnelson.kmp.tor.runtime.TorRuntime
Expand All @@ -36,7 +35,6 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
import kotlin.test.assertTrue

@OptIn(InternalKmpTorApi::class)
class TorConfigGeneratorUnitTest {

private val environment = "".toFile().absoluteFile.resolve("config-test").let { rootDir ->
Expand Down Expand Up @@ -100,6 +98,7 @@ class TorConfigGeneratorUnitTest {
assertContains(TorConfig.DisableNetwork)
assertContains(TorConfig.RunAsDaemon)
assertContains(TorConfig.__OwningControllerProcess)
assertContains(TorConfig.__ReloadTorrcOnSIGHUP)
}
}

Expand Down
Loading