summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-08 05:54:35 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-08 05:54:35 -0500
commit99973a4b08f955bbd9af01873120e8c3eeb84e1e (patch)
treefd7c732c41e04063f75d34ca5bb7fabdc2792b9d /app/src/main/java/com
parentc59b3e1230a17e288a50fbe685601e83c8f99de3 (diff)
Profile: Add helper to check name validity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/wireguard/config/Profile.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/config/Profile.java b/app/src/main/java/com/wireguard/config/Profile.java
index ab4d645b..e04cab3e 100644
--- a/app/src/main/java/com/wireguard/config/Profile.java
+++ b/app/src/main/java/com/wireguard/config/Profile.java
@@ -20,6 +20,11 @@ import java.nio.charset.StandardCharsets;
*/
public class Profile extends BaseObservable implements Copyable<Profile>, Observable {
+ public static boolean isNameValid(String name) {
+ final int IFNAMSIZ = 16;
+ return !name.contains(" ") && name.getBytes(StandardCharsets.UTF_8).length <= IFNAMSIZ;
+ }
+
private final Interface iface = new Interface();
private boolean isConnected;
private String name;