summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/ConfigEditFragment.java6
-rw-r--r--app/src/main/java/com/wireguard/config/Config.java8
2 files changed, 13 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/android/ConfigEditFragment.java b/app/src/main/java/com/wireguard/android/ConfigEditFragment.java
index 7cbcfddd..384aadef 100644
--- a/app/src/main/java/com/wireguard/android/ConfigEditFragment.java
+++ b/app/src/main/java/com/wireguard/android/ConfigEditFragment.java
@@ -73,7 +73,11 @@ public class ConfigEditFragment extends BaseConfigFragment {
}
private void saveConfig() {
- // FIXME: validate input
+ final String errorMessage = localConfig.validate();
+ if (errorMessage != null) {
+ Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_SHORT).show();
+ return;
+ }
try {
if (getCurrentConfig() != null)
VpnService.getInstance().update(getCurrentConfig().getName(), localConfig);
diff --git a/app/src/main/java/com/wireguard/config/Config.java b/app/src/main/java/com/wireguard/config/Config.java
index 9f1dbf4c..3f98cbcb 100644
--- a/app/src/main/java/com/wireguard/config/Config.java
+++ b/app/src/main/java/com/wireguard/config/Config.java
@@ -127,4 +127,12 @@ public class Config extends BaseObservable
sb.append('\n').append(peer);
return sb.toString();
}
+
+ public String validate() {
+ if (name == null || !isNameValid(name))
+ return "This configuration does not have a valid name.";
+ if (iface.getPublicKey() == null)
+ return "This configuration does not have a valid keypair.";
+ return null;
+ }
}