luci-proto-wireguard: remove peer sections when deleting interface
authorJo-Philipp Wich <jo@mein.io>
Tue, 3 Mar 2020 20:14:04 +0000 (21:14 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 3 Mar 2020 20:22:46 +0000 (21:22 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js

index c8e1f8403e3d283e40a86443b32e958b6045e504..46cf5379893fe08e4d06d8ef7cfdaa716aa7f190 100644 (file)
@@ -1,4 +1,5 @@
 'use strict';
+'require uci';
 'require form';
 'require network';
 
@@ -138,5 +139,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']);
+               });
        }
 });