diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-08 05:54:35 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-08 05:54:35 -0500 |
commit | e6986292b09f1a40f7e889e6336efde2ce1990fc (patch) | |
tree | fd7c732c41e04063f75d34ca5bb7fabdc2792b9d /app/src/main/java/com | |
parent | d5c7e84b6e98a1c75cf183342d0cfbc046226c6e (diff) |
Profile: Add helper to check name validity
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r-- | app/src/main/java/com/wireguard/config/Profile.java | 5 |
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; |