X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=protocols%2Fluci-proto-wireguard%2Fhtdocs%2Fluci-static%2Fresources%2Fprotocol%2Fwireguard.js;h=49f61c782a1459a2127f16202b0e905ee7eeb233;hb=59bc3173268313bb4546aa1c6da2309da408250d;hp=c8e1f8403e3d283e40a86443b32e958b6045e504;hpb=9684901dc27e37900d4c4cf09b1de3b836649e0e;p=oweals%2Fluci.git 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 c8e1f8403..49f61c782 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 @@ -1,4 +1,5 @@ 'use strict'; +'require uci'; 'require form'; 'require network'; @@ -123,7 +124,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.')); @@ -138,5 +146,11 @@ return network.registerProtocol('wireguard', { o = ss.option(form.Value, 'persistent_keepalive', _('Persistent Keep Alive'), _('Optional. Seconds between keep alive messages. Default is 0 (disabled). Recommended value if this device is behind a NAT is 25.')); o.datatype = 'range(0,65535)'; o.placeholder = '0'; + }, + + deleteConfiguration: function() { + uci.sections('network', 'wireguard_%s'.format(this.sid), function(s) { + uci.remove('network', s['.name']); + }); } });