diff options
author | pacien | 2018-02-16 18:42:02 +0100 |
---|---|---|
committer | pacien | 2018-02-16 18:42:02 +0100 |
commit | d360837d494a86930b8323a99691dc52925eb7ea (patch) | |
tree | 2fc1a8b1bf70d0fdbaa45a0185b0158f23a29a5d /app/src/main/java/org/pacien/tincapp/commands | |
parent | 5a4f0f964e41847b10ed44ac1f5b2bbf060102c3 (diff) | |
download | tincapp-d360837d494a86930b8323a99691dc52925eb7ea.tar.gz |
Cosmetic
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/commands')
5 files changed, 0 insertions, 11 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Command.kt b/app/src/main/java/org/pacien/tincapp/commands/Command.kt index cb95619..ccb5f10 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Command.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Command.kt | |||
@@ -6,7 +6,6 @@ import java.util.* | |||
6 | * @author pacien | 6 | * @author pacien |
7 | */ | 7 | */ |
8 | internal class Command(private val cmd: String) { | 8 | internal class Command(private val cmd: String) { |
9 | |||
10 | private data class Option(val key: String, val value: String?) { | 9 | private data class Option(val key: String, val value: String?) { |
11 | fun toCommandLineOption(): String = if (value != null) "--$key=$value" else "--$key" | 10 | fun toCommandLineOption(): String = if (value != null) "--$key=$value" else "--$key" |
12 | } | 11 | } |
@@ -25,7 +24,5 @@ internal class Command(private val cmd: String) { | |||
25 | } | 24 | } |
26 | 25 | ||
27 | fun asList(): List<String> = listOf(cmd) + opts.map { it.toCommandLineOption() } + args | 26 | fun asList(): List<String> = listOf(cmd) + opts.map { it.toCommandLineOption() } + args |
28 | |||
29 | fun asArray(): Array<String> = this.asList().toTypedArray() | 27 | fun asArray(): Array<String> = this.asList().toTypedArray() |
30 | |||
31 | } | 28 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt index a3b5cea..eb04f6d 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt | |||
@@ -12,7 +12,6 @@ import java.io.InputStreamReader | |||
12 | * @author pacien | 12 | * @author pacien |
13 | */ | 13 | */ |
14 | internal object Executor { | 14 | internal object Executor { |
15 | |||
16 | private const val FAILED = -1 | 15 | private const val FAILED = -1 |
17 | 16 | ||
18 | class CommandExecutionException(msg: String) : Exception(msg) | 17 | class CommandExecutionException(msg: String) : Exception(msg) |
@@ -56,5 +55,4 @@ internal object Executor { | |||
56 | 55 | ||
57 | fun runAsyncTask(r: () -> Unit) = CompletableFuture.runAsync(Runnable(r), AsyncTask.THREAD_POOL_EXECUTOR)!! | 56 | fun runAsyncTask(r: () -> Unit) = CompletableFuture.runAsync(Runnable(r), AsyncTask.THREAD_POOL_EXECUTOR)!! |
58 | fun <U> supplyAsyncTask(s: () -> U) = CompletableFuture.supplyAsync(Supplier(s), AsyncTask.THREAD_POOL_EXECUTOR)!! | 57 | fun <U> supplyAsyncTask(s: () -> U) = CompletableFuture.supplyAsync(Supplier(s), AsyncTask.THREAD_POOL_EXECUTOR)!! |
59 | |||
60 | } | 58 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt index e0cdb12..556288a 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt | |||
@@ -7,7 +7,6 @@ import org.pacien.tincapp.context.AppPaths | |||
7 | * @author pacien | 7 | * @author pacien |
8 | */ | 8 | */ |
9 | object Tinc { | 9 | object Tinc { |
10 | |||
11 | private fun newCommand(netName: String): Command = | 10 | private fun newCommand(netName: String): Command = |
12 | Command(AppPaths.tinc().absolutePath) | 11 | Command(AppPaths.tinc().absolutePath) |
13 | .withOption("config", AppPaths.confDir(netName).absolutePath) | 12 | .withOption("config", AppPaths.confDir(netName).absolutePath) |
@@ -47,5 +46,4 @@ object Tinc { | |||
47 | .withOption("config", AppPaths.confDir(netName).absolutePath) | 46 | .withOption("config", AppPaths.confDir(netName).absolutePath) |
48 | .withArguments("join", invitationUrl)) | 47 | .withArguments("join", invitationUrl)) |
49 | .thenApply<String> { it.joinToString("\n") } | 48 | .thenApply<String> { it.joinToString("\n") } |
50 | |||
51 | } | 49 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt index 11adb69..e5172c8 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt | |||
@@ -14,7 +14,6 @@ import java.io.FileNotFoundException | |||
14 | * @author pacien | 14 | * @author pacien |
15 | */ | 15 | */ |
16 | object TincApp { | 16 | object TincApp { |
17 | |||
18 | private val SCRIPT_SUFFIXES = listOf("-up", "-down", "-created", "-accepted") | 17 | private val SCRIPT_SUFFIXES = listOf("-up", "-down", "-created", "-accepted") |
19 | private val STATIC_SCRIPTS = listOf("tinc", "host", "subnet", "invitation").flatMap { s -> SCRIPT_SUFFIXES.map { s + it } } | 18 | private val STATIC_SCRIPTS = listOf("tinc", "host", "subnet", "invitation").flatMap { s -> SCRIPT_SUFFIXES.map { s + it } } |
20 | 19 | ||
@@ -49,5 +48,4 @@ object TincApp { | |||
49 | .map { Pair(if (newPassphrase?.isNotEmpty() == true) PemUtils.encrypt(it.first, newPassphrase) else it.first, it.second) } | 48 | .map { Pair(if (newPassphrase?.isNotEmpty() == true) PemUtils.encrypt(it.first, newPassphrase) else it.first, it.second) } |
50 | .forEach { PemUtils.write(it.first, it.second.writer()) } | 49 | .forEach { PemUtils.write(it.first, it.second.writer()) } |
51 | } | 50 | } |
52 | |||
53 | } | 51 | } |
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt b/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt index 44fcef5..9950b49 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt | |||
@@ -6,7 +6,6 @@ import org.pacien.tincapp.context.AppPaths | |||
6 | * @author pacien | 6 | * @author pacien |
7 | */ | 7 | */ |
8 | object Tincd { | 8 | object Tincd { |
9 | |||
10 | fun start(netName: String, deviceFd: Int, ed25519PrivateKeyFd: Int? = null, rsaPrivateKeyFd: Int? = null) = | 9 | fun start(netName: String, deviceFd: Int, ed25519PrivateKeyFd: Int? = null, rsaPrivateKeyFd: Int? = null) = |
11 | Executor.forkExec(Command(AppPaths.tincd().absolutePath) | 10 | Executor.forkExec(Command(AppPaths.tincd().absolutePath) |
12 | .withOption("no-detach") | 11 | .withOption("no-detach") |
@@ -17,5 +16,4 @@ object Tincd { | |||
17 | .withOption("option", "Device=" + deviceFd) | 16 | .withOption("option", "Device=" + deviceFd) |
18 | .apply { if (ed25519PrivateKeyFd != null) withOption("option", "Ed25519PrivateKeyFile=/proc/self/fd/$ed25519PrivateKeyFd") } | 17 | .apply { if (ed25519PrivateKeyFd != null) withOption("option", "Ed25519PrivateKeyFile=/proc/self/fd/$ed25519PrivateKeyFd") } |
19 | .apply { if (rsaPrivateKeyFd != null) withOption("option", "PrivateKeyFile=/proc/self/fd/$rsaPrivateKeyFd") }) | 18 | .apply { if (rsaPrivateKeyFd != null) withOption("option", "PrivateKeyFile=/proc/self/fd/$rsaPrivateKeyFd") }) |
20 | |||
21 | } | 19 | } |