diff options
author | Pacien TRAN-GIRARD | 2017-06-30 10:21:51 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2017-06-30 10:21:51 +0200 |
commit | c89016e7427defd1f8a095d7aeb30292a42fad92 (patch) | |
tree | aec80e6f501824f966ea727d2f6e102a75e9655f /app/src/main/java/org/pacien/tincapp/commands/Tinc.java | |
parent | 94d77ce43152a4e144417d8d5cfff363f65c904e (diff) | |
download | tincapp-c89016e7427defd1f8a095d7aeb30292a42fad92.tar.gz |
Conversion to Kotlin
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/commands/Tinc.java')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/commands/Tinc.java | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Tinc.java b/app/src/main/java/org/pacien/tincapp/commands/Tinc.java deleted file mode 100644 index ca11698..0000000 --- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.java +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | package org.pacien.tincapp.commands; | ||
2 | |||
3 | import android.content.Context; | ||
4 | |||
5 | import com.annimon.stream.Stream; | ||
6 | |||
7 | import org.pacien.tincapp.context.AppPaths; | ||
8 | |||
9 | import java.io.IOException; | ||
10 | import java.util.List; | ||
11 | |||
12 | /** | ||
13 | * @author pacien | ||
14 | */ | ||
15 | final public class Tinc { | ||
16 | |||
17 | private Tinc() { | ||
18 | // static class | ||
19 | } | ||
20 | |||
21 | static private Command newCommand(Context ctx, String netName) { | ||
22 | return new Command(AppPaths.tinc(ctx).getAbsolutePath()) | ||
23 | .withOption("config", AppPaths.confDir(ctx, netName).getAbsolutePath()) | ||
24 | .withOption("pidfile", AppPaths.pidFile(ctx, netName).getAbsolutePath()); | ||
25 | } | ||
26 | |||
27 | // independently runnable commands | ||
28 | |||
29 | static public List<String> network(Context ctx) throws IOException { | ||
30 | return Executor.call(new Command(AppPaths.tinc(ctx).getAbsolutePath()) | ||
31 | .withOption("config", AppPaths.confDir(ctx).getAbsolutePath()) | ||
32 | .withArguments("network")); | ||
33 | } | ||
34 | |||
35 | static public List<String> fsck(Context ctx, String netName, Boolean fix) throws IOException { | ||
36 | Command cmd = newCommand(ctx, netName).withArguments("fsck"); | ||
37 | if (fix) cmd = cmd.withOption("force"); | ||
38 | return Executor.call(cmd); | ||
39 | } | ||
40 | |||
41 | // commands requiring a running tinc daemon | ||
42 | |||
43 | static public void stop(Context ctx, String netName) throws IOException { | ||
44 | Executor.call(newCommand(ctx, netName).withArguments("stop")); | ||
45 | } | ||
46 | |||
47 | static public List<String> dumpNodes(Context ctx, String netName, Boolean reachable) throws IOException { | ||
48 | Command cmd = reachable | ||
49 | ? newCommand(ctx, netName).withArguments("dump", "reachable", "nodes") | ||
50 | : newCommand(ctx, netName).withArguments("dump", "nodes"); | ||
51 | |||
52 | return Executor.call(cmd); | ||
53 | } | ||
54 | |||
55 | static public String info(Context ctx, String netName, String node) throws IOException { | ||
56 | List<String> output = Executor.call(newCommand(ctx, netName).withArguments("info", node)); | ||
57 | return Stream.of(output).reduce((l, r) -> l + '\n' + r).get(); | ||
58 | } | ||
59 | |||
60 | } | ||