aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien
diff options
context:
space:
mode:
authorpacien2017-08-24 16:45:27 +0200
committerpacien2017-08-24 16:45:27 +0200
commit15c5b2f28509cd556fdf361c530368fbe6688cd8 (patch)
tree503a482ed90a0a08ab2236d5d96067513922cbbf /app/src/main/java/org/pacien
parentb91fabd057be80ecb028eccbc627f53c1ba63d76 (diff)
downloadtincapp-15c5b2f28509cd556fdf361c530368fbe6688cd8.tar.gz
Reject blank network name
Diffstat (limited to 'app/src/main/java/org/pacien')
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt22
1 files changed, 14 insertions, 8 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 0bb1da4..6acd4f2 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
@@ -27,15 +27,21 @@ object Tinc {
27 .thenApply<String> { it.joinToString("\n") } 27 .thenApply<String> { it.joinToString("\n") }
28 28
29 fun init(netName: String, nodeName: String): CompletableFuture<String> = 29 fun init(netName: String, nodeName: String): CompletableFuture<String> =
30 Executor.call(Command(AppPaths.tinc().absolutePath) 30 if (netName.isBlank())
31 .withOption("config", AppPaths.confDir(netName).absolutePath) 31 CompletableFuture.failedFuture(IllegalArgumentException("Network name cannot be blank."))
32 .withArguments("init", nodeName)) 32 else
33 .thenApply<String> { it.joinToString("\n") } 33 Executor.call(Command(AppPaths.tinc().absolutePath)
34 .withOption("config", AppPaths.confDir(netName).absolutePath)
35 .withArguments("init", nodeName))
36 .thenApply<String> { it.joinToString("\n") }
34 37
35 fun join(netName: String, invitationUrl: String): CompletableFuture<String> = 38 fun join(netName: String, invitationUrl: String): CompletableFuture<String> =
36 Executor.call(Command(AppPaths.tinc().absolutePath) 39 if (netName.isBlank())
37 .withOption("config", AppPaths.confDir(netName).absolutePath) 40 CompletableFuture.failedFuture(IllegalArgumentException("Network name cannot be blank."))
38 .withArguments("join", invitationUrl)) 41 else
39 .thenApply<String> { it.joinToString("\n") } 42 Executor.call(Command(AppPaths.tinc().absolutePath)
43 .withOption("config", AppPaths.confDir(netName).absolutePath)
44 .withArguments("join", invitationUrl))
45 .thenApply<String> { it.joinToString("\n") }
40 46
41} 47}