aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/assets
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-10-03 03:37:04 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-10-03 03:37:04 +0300
commitf33f3eeb58db2cddc95b69214160f02f9157537c (patch)
tree4517111704d50eee9055a3fefd20ad9255379088 /assets
parentmake config descriptions narrower (diff)
downloadwireguard-config-f33f3eeb58db2cddc95b69214160f02f9157537c.tar.gz
wireguard-config-f33f3eeb58db2cddc95b69214160f02f9157537c.zip
more input validation
Diffstat (limited to 'assets')
-rw-r--r--assets/js/main.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
index 51ace3b..79e0dd2 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -10,6 +10,9 @@ function parse_endpoint(val) {
if (val.length == 0) {
throw new Error('Server endpoint cannot be an empty string.');
}
+ if (!val.match(/^.+:[0-9]+$/)) {
+ throw new Error('Please specify a host and a port in the HOST:PORT format.');
+ }
return val;
}
@@ -18,6 +21,9 @@ function parse_key(val) {
if (val.length == 0) {
throw new Error('Key as used by WireGuard cannot be an empty string.');
}
+ if (!val.match(/^[0-9a-zA-Z+/=]+$/)) {
+ throw new Error('Key as used by WireGuard must be Base64-encoded.');
+ }
return val;
}