summaryrefslogtreecommitdiffhomepage
path: root/protocols/luci-proto-wireguard
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2020-05-14 09:59:08 +0200
committerGitHub <noreply@github.com>2020-05-14 09:59:08 +0200
commit39861cc25dd1c9121440a78d2e1bf300cb9ed5dc (patch)
tree306cf47b65ccdd5654cf31686ae01d5f7d501c47 /protocols/luci-proto-wireguard
parentc997ae4a353ded65b31a4d2192af7744902c20f2 (diff)
parentdae15b8cf476fe761b2b6a7457c4d8e3e9950569 (diff)
Merge pull request #4047 from TDT-AG/pr/20200513-wireguard
luci-proto-wireguard: fix value validation
Diffstat (limited to 'protocols/luci-proto-wireguard')
-rw-r--r--protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js b/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js
index 46cf53798..e88c07c33 100644
--- a/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js
+++ b/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js
@@ -10,6 +10,9 @@ function validateBase64(section_id, value) {
if (value.length != 44 || !value.match(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/))
return _('Invalid Base64 key string');
+ if (value[43] != "=" )
+ return _('Invalid Base64 key string');
+
return true;
}
@@ -124,7 +127,14 @@ return network.registerProtocol('wireguard', {
o = ss.option(form.DynamicList, 'allowed_ips', _('Allowed IPs'), _("Required. IP addresses and prefixes that this peer is allowed to use inside the tunnel. Usually the peer's tunnel IP addresses and the networks the peer routes through the tunnel."));
o.datatype = 'ipaddr';
- o.rmempty = false;
+ o.validate = function(section, value) {
+ var opt = this.map.lookupOption('allowed_ips', section);
+ var ips = opt[0].formvalue(section);
+ if (ips.length == 0) {
+ return _('Value must not be empty');
+ }
+ return true;
+ };
o = ss.option(form.Flag, 'route_allowed_ips', _('Route Allowed IPs'), _('Optional. Create routes for Allowed IPs for this peer.'));