Skip to content
Snippets Groups Projects
Commit add3b53e authored by Sebastian's avatar Sebastian
Browse files

Allow Tor ports to be specified on the command line

parent 8b0c11fb
No related branches found
No related tags found
1 merge request!35Make it possible to run multiple versions of briar-desktop concurrently
......@@ -50,7 +50,11 @@ import javax.inject.Singleton
SocksModule::class
]
)
internal class DesktopModule(private val appDir: Path) {
internal class DesktopModule(
private val appDir: Path,
private val socksPort: Int = DEFAULT_SOCKS_PORT,
private val controlPort: Int = DEFAULT_CONTROL_PORT
) {
@Provides
@Singleton
......@@ -67,7 +71,7 @@ internal class DesktopModule(private val appDir: Path) {
@Provides
@Singleton
fun provideTorPorts(): TorPorts {
return TorPortsImpl(DEFAULT_SOCKS_PORT, DEFAULT_CONTROL_PORT)
return TorPortsImpl(socksPort, controlPort)
}
@Provides
......
......@@ -7,7 +7,10 @@ import com.github.ajalt.clikt.parameters.options.counted
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.int
import org.briarproject.bramble.BrambleCoreEagerSingletons
import org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_CONTROL_PORT
import org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_SOCKS_PORT
import org.briarproject.briar.BriarCoreEagerSingletons
import org.briarproject.briar.desktop.utils.FileUtils
import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n
......@@ -43,6 +46,14 @@ private class Main : CliktCommand(
metavar = "PATH",
envvar = "BRIAR_DATA_DIR"
).default(DEFAULT_DATA_DIR)
private val socksPort by option(
"--socks-port",
help = "Tor Socks Port"
).int().default(DEFAULT_SOCKS_PORT)
private val controlPort by option(
"--control-port",
help = "Tor Control Port"
).int().default(DEFAULT_CONTROL_PORT)
@OptIn(ExperimentalComposeUiApi::class)
override fun run() {
......@@ -57,7 +68,7 @@ private class Main : CliktCommand(
val dataDir = getDataDir()
val app =
DaggerBriarDesktopApp.builder().desktopModule(
DesktopModule(dataDir)
DesktopModule(dataDir, socksPort, controlPort)
).build()
// We need to load the eager singletons directly after making the
// dependency graphs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment