From d221543bb9d6bc9b7344cc96f010a501ff35bb7f Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 1 Jul 2017 23:18:40 +0200 Subject: Support config located on external storage with the "external/" prefix --- .../main/java/org/pacien/tincapp/commands/Tinc.kt | 30 +++++++++------------- .../main/java/org/pacien/tincapp/commands/Tincd.kt | 8 +++--- 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'app/src/main/java/org/pacien/tincapp/commands') 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 91a2678..5116d63 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt @@ -8,22 +8,16 @@ import java.io.IOException */ object Tinc { - private fun newCommand(netName: String): Command = + private fun newCommand(netConf: AppPaths.NetConf): Command = Command(AppPaths.tinc().absolutePath) - .withOption("config", AppPaths.confDir(netName).absolutePath) - .withOption("pidfile", AppPaths.pidFile(netName).absolutePath) + .withOption("config", AppPaths.confDir(netConf).absolutePath) + .withOption("pidfile", AppPaths.pidFile(netConf).absolutePath) // independently runnable commands @Throws(IOException::class) - fun network(): List = - Executor.call(Command(AppPaths.tinc().absolutePath) - .withOption("config", AppPaths.confDir().absolutePath) - .withArguments("network")) - - @Throws(IOException::class) - fun fsck(netName: String, fix: Boolean): List { - var cmd = newCommand(netName).withArguments("fsck") + fun fsck(netConf: AppPaths.NetConf, fix: Boolean): List { + var cmd = newCommand(netConf).withArguments("fsck") if (fix) cmd = cmd.withOption("force") return Executor.call(cmd) } @@ -31,18 +25,18 @@ object Tinc { // commands requiring a running tinc daemon @Throws(IOException::class) - fun stop(netName: String) { - Executor.call(newCommand(netName).withArguments("stop")) + fun stop(netConf: AppPaths.NetConf) { + Executor.call(newCommand(netConf).withArguments("stop")) } @Throws(IOException::class) - fun dumpNodes(netName: String, reachable: Boolean): List = + fun dumpNodes(netConf: AppPaths.NetConf, reachable: Boolean): List = Executor.call( - if (reachable) newCommand(netName).withArguments("dump", "reachable", "nodes") - else newCommand(netName).withArguments("dump", "nodes")) + if (reachable) newCommand(netConf).withArguments("dump", "reachable", "nodes") + else newCommand(netConf).withArguments("dump", "nodes")) @Throws(IOException::class) - fun info(netName: String, node: String): String = - Executor.call(newCommand(netName).withArguments("info", node)).joinToString("\n") + fun info(netConf: AppPaths.NetConf, node: String): String = + Executor.call(newCommand(netConf).withArguments("info", node)).joinToString("\n") } 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 19ebfbd..c54b328 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 object Tincd { @Throws(IOException::class) - fun start(netName: String, fd: Int) { + fun start(netConf: AppPaths.NetConf, fd: Int) { Executor.forkExec(Command(AppPaths.tincd().absolutePath) .withOption("no-detach") - .withOption("config", AppPaths.confDir(netName).absolutePath) - .withOption("pidfile", AppPaths.pidFile(netName).absolutePath) - .withOption("logfile", AppPaths.logFile(netName).absolutePath) + .withOption("config", AppPaths.confDir(netConf).absolutePath) + .withOption("pidfile", AppPaths.pidFile(netConf).absolutePath) + .withOption("logfile", AppPaths.logFile(netConf).absolutePath) .withOption("option", "DeviceType=fd") .withOption("option", "Device=" + fd)) } -- cgit v1.2.3