diff options
Diffstat (limited to 'app/src/main/kotlin/org/pacien/tincapp/commands/Tincd.kt')
-rw-r--r-- | app/src/main/kotlin/org/pacien/tincapp/commands/Tincd.kt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/src/main/kotlin/org/pacien/tincapp/commands/Tincd.kt b/app/src/main/kotlin/org/pacien/tincapp/commands/Tincd.kt new file mode 100644 index 0000000..92be0f5 --- /dev/null +++ b/app/src/main/kotlin/org/pacien/tincapp/commands/Tincd.kt | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon | ||
3 | * Copyright (C) 2017-2018 Pacien TRAN-GIRARD | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 3 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | package org.pacien.tincapp.commands | ||
20 | |||
21 | import org.pacien.tincapp.context.AppPaths | ||
22 | |||
23 | /** | ||
24 | * @author pacien | ||
25 | */ | ||
26 | object Tincd { | ||
27 | fun start(netName: String, deviceFd: Int, ed25519PrivateKeyFd: Int? = null, rsaPrivateKeyFd: Int? = null) = | ||
28 | Executor.forkExec(Command(AppPaths.tincd().absolutePath) | ||
29 | .withOption("no-detach") | ||
30 | .withOption("config", AppPaths.confDir(netName).absolutePath) | ||
31 | .withOption("pidfile", AppPaths.pidFile(netName).absolutePath) | ||
32 | .withOption("logfile", AppPaths.logFile(netName).absolutePath) | ||
33 | .withOption("option", "DeviceType=fd") | ||
34 | .withOption("option", "Device=$deviceFd") | ||
35 | .apply { if (ed25519PrivateKeyFd != null) withOption("option", "Ed25519PrivateKeyFile=/proc/self/fd/$ed25519PrivateKeyFd") } | ||
36 | .apply { if (rsaPrivateKeyFd != null) withOption("option", "PrivateKeyFile=/proc/self/fd/$rsaPrivateKeyFd") }) | ||
37 | } | ||