aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien/tincapp/commands
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/commands')
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt24
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.kt8
2 files changed, 16 insertions, 16 deletions
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 5116d63..22cbe71 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
@@ -8,16 +8,16 @@ import java.io.IOException
8 */ 8 */
9object Tinc { 9object Tinc {
10 10
11 private fun newCommand(netConf: AppPaths.NetConf): Command = 11 private fun newCommand(netName: String): Command =
12 Command(AppPaths.tinc().absolutePath) 12 Command(AppPaths.tinc().absolutePath)
13 .withOption("config", AppPaths.confDir(netConf).absolutePath) 13 .withOption("config", AppPaths.confDir(netName).absolutePath)
14 .withOption("pidfile", AppPaths.pidFile(netConf).absolutePath) 14 .withOption("pidfile", AppPaths.pidFile(netName).absolutePath)
15 15
16 // independently runnable commands 16 // independently runnable commands
17 17
18 @Throws(IOException::class) 18 @Throws(IOException::class)
19 fun fsck(netConf: AppPaths.NetConf, fix: Boolean): List<String> { 19 fun fsck(netName: String, fix: Boolean): List<String> {
20 var cmd = newCommand(netConf).withArguments("fsck") 20 var cmd = newCommand(netName).withArguments("fsck")
21 if (fix) cmd = cmd.withOption("force") 21 if (fix) cmd = cmd.withOption("force")
22 return Executor.call(cmd) 22 return Executor.call(cmd)
23 } 23 }
@@ -25,18 +25,18 @@ object Tinc {
25 // commands requiring a running tinc daemon 25 // commands requiring a running tinc daemon
26 26
27 @Throws(IOException::class) 27 @Throws(IOException::class)
28 fun stop(netConf: AppPaths.NetConf) { 28 fun stop(netName: String) {
29 Executor.call(newCommand(netConf).withArguments("stop")) 29 Executor.call(newCommand(netName).withArguments("stop"))
30 } 30 }
31 31
32 @Throws(IOException::class) 32 @Throws(IOException::class)
33 fun dumpNodes(netConf: AppPaths.NetConf, reachable: Boolean): List<String> = 33 fun dumpNodes(netName: String, reachable: Boolean): List<String> =
34 Executor.call( 34 Executor.call(
35 if (reachable) newCommand(netConf).withArguments("dump", "reachable", "nodes") 35 if (reachable) newCommand(netName).withArguments("dump", "reachable", "nodes")
36 else newCommand(netConf).withArguments("dump", "nodes")) 36 else newCommand(netName).withArguments("dump", "nodes"))
37 37
38 @Throws(IOException::class) 38 @Throws(IOException::class)
39 fun info(netConf: AppPaths.NetConf, node: String): String = 39 fun info(netName: String, node: String): String =
40 Executor.call(newCommand(netConf).withArguments("info", node)).joinToString("\n") 40 Executor.call(newCommand(netName).withArguments("info", node)).joinToString("\n")
41 41
42} 42}
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 c54b328..19ebfbd 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Tincd.kt
@@ -9,12 +9,12 @@ import java.io.IOException
9object Tincd { 9object Tincd {
10 10
11 @Throws(IOException::class) 11 @Throws(IOException::class)
12 fun start(netConf: AppPaths.NetConf, fd: Int) { 12 fun start(netName: String, fd: Int) {
13 Executor.forkExec(Command(AppPaths.tincd().absolutePath) 13 Executor.forkExec(Command(AppPaths.tincd().absolutePath)
14 .withOption("no-detach") 14 .withOption("no-detach")
15 .withOption("config", AppPaths.confDir(netConf).absolutePath) 15 .withOption("config", AppPaths.confDir(netName).absolutePath)
16 .withOption("pidfile", AppPaths.pidFile(netConf).absolutePath) 16 .withOption("pidfile", AppPaths.pidFile(netName).absolutePath)
17 .withOption("logfile", AppPaths.logFile(netConf).absolutePath) 17 .withOption("logfile", AppPaths.logFile(netName).absolutePath)
18 .withOption("option", "DeviceType=fd") 18 .withOption("option", "DeviceType=fd")
19 .withOption("option", "Device=" + fd)) 19 .withOption("option", "Device=" + fd))
20 } 20 }