summaryrefslogtreecommitdiffhomepage
path: root/app
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
commite6986292b09f1a40f7e889e6336efde2ce1990fc (patch)
treefd7c732c41e04063f75d34ca5bb7fabdc2792b9d /app
parentd5c7e84b6e98a1c75cf183342d0cfbc046226c6e (diff)
Profile: Add helper to check name validity
Diffstat (limited to 'app')
-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;