summaryrefslogtreecommitdiffhomepage
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/luci-proto-gre/Makefile21
-rw-r--r--protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gre.js96
-rw-r--r--protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gretap.js101
-rw-r--r--protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6.js98
-rw-r--r--protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6tap.js103
-rw-r--r--protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js12
-rw-r--r--protocols/luci-proto-sstp/Makefile15
-rw-r--r--protocols/luci-proto-sstp/htdocs/luci-static/resources/protocol/sstp.js85
-rw-r--r--protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js20
-rwxr-xr-xprotocols/luci-proto-wireguard/root/usr/libexec/rpcd/luci.wireguard26
-rw-r--r--protocols/luci-proto-wireguard/root/usr/share/rpcd/acl.d/luci-wireguard.json10
11 files changed, 584 insertions, 3 deletions
diff --git a/protocols/luci-proto-gre/Makefile b/protocols/luci-proto-gre/Makefile
new file mode 100644
index 0000000000..0b0fa541cb
--- /dev/null
+++ b/protocols/luci-proto-gre/Makefile
@@ -0,0 +1,21 @@
+#
+# Based on luci-proto-ipip.
+# Credited author of luci-proto-ipip is Roger Pueyo Centelles <roger.pueyo@guifi.net>
+# Copyright 2016 Roger Pueyo Centelles <roger.pueyo@guifi.net>
+#
+# Modified by Jan Betik <jan.betik@svine.su>
+# Copyright 2020 Jan Betik <jan.betik@svine.su>
+#
+# This is free software, licensed under the Apache License, Version 2.0 .
+#
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=Support for GRE tunnels (RFC2784)
+LUCI_DEPENDS:=+gre
+
+PKG_MAINTAINER:=Jan Betik <jan.betik@svine.su>
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gre.js b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gre.js
new file mode 100644
index 0000000000..e431bccd76
--- /dev/null
+++ b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gre.js
@@ -0,0 +1,96 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+network.registerPatternVirtual(/^gre4-.+$/);
+
+return network.registerProtocol('gre', {
+ getI18n: function() {
+ return _('GRE tunnel over IPv4');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'gre4-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'gre';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var o;
+
+ // -- general ---------------------------------------------------------------------
+
+ o = s.taboption('general', form.Value, 'peeraddr', _("Remote IPv4 address or FQDN"), _("The IPv4 address or the fully-qualified domain name of the remote tunnel end."));
+ o.optional = false;
+ o.datatype = 'or(hostname,ip4addr("nomask"))';
+
+ o = s.taboption('general', form.Value, 'ipaddr', _("Local IPv4 address"), _("The local IPv4 address over which the tunnel is created (optional)."));
+ o.optional = true;
+ o.datatype = 'ip4addr("nomask")';
+
+ // -- advanced ---------------------------------------------------------------------
+
+ o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _("Bind interface"), _("Bind the tunnel to this interface (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'mtu', _("Override MTU"), _("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes) (optional)."));
+ o.optional = true;
+ o.placeholder = 1280;
+ o.datatype = 'range(68, 9200)';
+
+ o = s.taboption('advanced', form.Value, 'ttl', _("Override TTL"), _("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64) (optional)."));
+ o.optional = true;
+ o.placeholder = 64;
+ o.datatype = 'min(1)';
+
+ o = s.taboption('advanced', form.Value, 'tos', _('Override TOS'), _("Specify a TOS (Type of Service). Can be either <code>inherit</code> (the outer header inherits the value of the inner header) or an hexadecimal value starting with <code>0x</code> (optional)."));
+ o.optional = true;
+ o.validate = function(section_id, value) {
+ if (value.length > 0 && !value.match(/^0x[a-fA-F0-9]{1,2}$/) && !value.match(/^inherit$/i))
+ return _('Invalid value');
+
+ return true;
+ };
+
+ o = s.taboption('advanced', form.Flag, 'df', _("Don't Fragment"), _("Enable the DF (Don't Fragment) flag of the encapsulating packets."));
+ o.default = o.enabled;
+
+ o = s.taboption('advanced', form.Flag, 'nohostroute', _("No host route"), _("Do not create host route to peer (optional)."));
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'ikey', _("Incoming key"), _("Key for incoming packets (optional)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ o = s.taboption('advanced', form.Value, 'okey', _("Outgoing key"), _("Key for outgoing packets (optinal)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ s.taboption('advanced', form.Flag, 'icsum', _("Incoming checksum"), _("Require incoming checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'ocsum', _("Outgoing checksum"), _("Compute outgoing checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'iseqno', _("Incoming serialization"), _("Require incoming packets serialization (optional)."));
+ s.taboption('advanced', form.Flag, 'oseqno', _("Outgoing serialization"), _("Perform outgoing packets serialization (optional)."));
+
+ }
+});
diff --git a/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gretap.js b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gretap.js
new file mode 100644
index 0000000000..426b5d98df
--- /dev/null
+++ b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/gretap.js
@@ -0,0 +1,101 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+network.registerPatternVirtual(/^gre4t-.+$/);
+
+return network.registerProtocol('gretap', {
+ getI18n: function() {
+ return _('GRETAP tunnel over IPv4');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'gre4t-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'gre';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var o;
+
+ // -- general ---------------------------------------------------------------------
+
+ o = s.taboption('general', form.Value, 'peeraddr', _("Remote IPv4 address or FQDN"), _("The IPv4 address or the fully-qualified domain name of the remote tunnel end."));
+ o.optional = false;
+ o.datatype = 'or(hostname,ip4addr("nomask"))';
+
+ o = s.taboption('general', form.Value, 'ipaddr', _("Local IPv4 address"), _("The local IPv4 address over which the tunnel is created (optional)."));
+ o.optional = true;
+ o.datatype = 'ip4addr("nomask")';
+
+ o = s.taboption('general', widgets.NetworkSelect, 'network', _("Network interface"), _("Logical network to which the tunnel will be added (bridged) (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ // -- advanced ---------------------------------------------------------------------
+
+ o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _("Bind interface"), _("Bind the tunnel to this interface (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'mtu', _("Override MTU"), _("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes) (optional)."));
+ o.optional = true;
+ o.placeholder = 1280;
+ o.datatype = 'range(68, 9200)';
+
+ o = s.taboption('advanced', form.Value, 'ttl', _("Override TTL"), _("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64) (optional)."));
+ o.optional = true;
+ o.placeholder = 64;
+ o.datatype = 'min(1)';
+
+ o = s.taboption('advanced', form.Value, 'tos', _('Override TOS'), _("Specify a TOS (Type of Service). Can be either <code>inherit</code> (the outer header inherits the value of the inner header) or an hexadecimal value starting with <code>0x</code> (optional)."));
+ o.optional = true;
+ o.validate = function(section_id, value) {
+ if (value.length > 0 && !value.match(/^0x[a-fA-F0-9]{1,2}$/) && !value.match(/^inherit$/i))
+ return _('Invalid value');
+
+ return true;
+ };
+
+ o = s.taboption('advanced', form.Flag, 'df', _("Don't Fragment"), _("Enable the DF (Don't Fragment) flag of the encapsulating packets."));
+ o.default = o.enabled;
+
+ o = s.taboption('advanced', form.Flag, 'nohostroute', _("No host route"), _("Do not create host route to peer (optional)."));
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'ikey', _("Incoming key"), _("Key for incoming packets (optional)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ o = s.taboption('advanced', form.Value, 'okey', _("Outgoing key"), _("Key for outgoing packets (optinal)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ s.taboption('advanced', form.Flag, 'icsum', _("Incoming checksum"), _("Require incoming checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'ocsum', _("Outgoing checksum"), _("Compute outgoing checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'iseqno', _("Incoming serialization"), _("Require incoming packets serialization (optional)."));
+ s.taboption('advanced', form.Flag, 'oseqno', _("Outgoing serialization"), _("Perform outgoing packets serialization (optional)."));
+
+ }
+});
diff --git a/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6.js b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6.js
new file mode 100644
index 0000000000..bd9a43e27b
--- /dev/null
+++ b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6.js
@@ -0,0 +1,98 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+network.registerPatternVirtual(/^gre6-.+$/);
+
+return network.registerProtocol('grev6', {
+ getI18n: function() {
+ return _('GRE tunnel over IPv6');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'gre6-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'gre';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var o;
+
+ // -- general ---------------------------------------------------------------------
+
+ o = s.taboption('general', form.Value, 'peer6addr', _("Remote IPv6 address or FQDN"), _("The IPv6 address or the fully-qualified domain name of the remote tunnel end."));
+ o.optional = false;
+ o.datatype = 'or(hostname,ip6addr("nomask"))';
+
+ o = s.taboption('general', form.Value, 'ip6addr', _("Local IPv6 address"), _("The local IPv6 address over which the tunnel is created (optional)."));
+ o.optional = true;
+ o.datatype = 'ip6addr("nomask")';
+
+ o = s.taboption('general', widgets.NetworkSelect, 'weakif', _("Source interface"), _("Logical network from which to select the local endpoint if local IPv6 address is empty and no WAN IPv6 is available (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ // -- advanced ---------------------------------------------------------------------
+
+ o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _("Bind interface"), _("Bind the tunnel to this interface (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'mtu', _("Override MTU"), _("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes) (optional)."));
+ o.optional = true;
+ o.placeholder = 1280;
+ o.datatype = 'range(68, 9200)';
+
+ o = s.taboption('advanced', form.Value, 'ttl', _("Override TTL"), _("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64) (optional)."));
+ o.optional = true;
+ o.placeholder = 64;
+ o.datatype = 'min(1)';
+
+ o = s.taboption('advanced', form.Value, 'tos', _('Traffic Class'), _("Specify a Traffic Class. Can be either <code>inherit</code> (the outer header inherits the value of the inner header) or an hexadecimal value starting with <code>0x</code> (optional)."));
+ o.optional = true;
+ o.validate = function(section_id, value) {
+ if (value.length > 0 && !value.match(/^0x[a-fA-F0-9]{1,2}$/) && !value.match(/^inherit$/i))
+ return _('Invalid value');
+
+ return true;
+ };
+
+ o = s.taboption('advanced', form.Flag, 'nohostroute', _("No host route"), _("Do not create host route to peer (optional)."));
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'ikey', _("Incoming key"), _("Key for incoming packets (optional)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ o = s.taboption('advanced', form.Value, 'okey', _("Outgoing key"), _("Key for outgoing packets (optinal)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ s.taboption('advanced', form.Flag, 'icsum', _("Incoming checksum"), _("Require incoming checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'ocsum', _("Outgoing checksum"), _("Compute outgoing checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'iseqno', _("Incoming serialization"), _("Require incoming packets serialization (optional)."));
+ s.taboption('advanced', form.Flag, 'oseqno', _("Outgoing serialization"), _("Perform outgoing packets serialization (optional)."));
+
+ }
+});
diff --git a/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6tap.js b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6tap.js
new file mode 100644
index 0000000000..3b1a503719
--- /dev/null
+++ b/protocols/luci-proto-gre/htdocs/luci-static/resources/protocol/grev6tap.js
@@ -0,0 +1,103 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+network.registerPatternVirtual(/^gre6t-.+$/);
+
+return network.registerProtocol('grev6tap', {
+ getI18n: function() {
+ return _('GRETAP tunnel over IPv6');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'gre6t-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'gre';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var o;
+
+ // -- general ---------------------------------------------------------------------
+
+ o = s.taboption('general', form.Value, 'peer6addr', _("Remote IPv6 address or FQDN"), _("The IPv6 address or the fully-qualified domain name of the remote tunnel end."));
+ o.optional = false;
+ o.datatype = 'or(hostname,ip6addr("nomask"))';
+
+ o = s.taboption('general', form.Value, 'ip6addr', _("Local IPv6 address"), _("The local IPv6 address over which the tunnel is created (optional)."));
+ o.optional = true;
+ o.datatype = 'ip6addr("nomask")';
+
+ o = s.taboption('general', widgets.NetworkSelect, 'weakif', _("Source interface"), _("Logical network from which to select the local endpoint if local IPv6 address is empty and no WAN IPv6 is available (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('general', widgets.NetworkSelect, 'network', _("Network interface"), _("Logical network to which the tunnel will be added (bridged) (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ // -- advanced ---------------------------------------------------------------------
+
+ o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _("Bind interface"), _("Bind the tunnel to this interface (optional)."));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'mtu', _("Override MTU"), _("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes) (optional)."));
+ o.optional = true;
+ o.placeholder = 1280;
+ o.datatype = 'range(68, 9200)';
+
+ o = s.taboption('advanced', form.Value, 'ttl', _("Override TTL"), _("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64) (optional)."));
+ o.optional = true;
+ o.placeholder = 64;
+ o.datatype = 'min(1)';
+
+ o = s.taboption('advanced', form.Value, 'tos', _('Traffic Class'), _("Specify a Traffic Class. Can be either <code>inherit</code> (the outer header inherits the value of the inner header) or an hexadecimal value starting with <code>0x</code> (optional)."));
+ o.optional = true;
+ o.validate = function(section_id, value) {
+ if (value.length > 0 && !value.match(/^0x[a-fA-F0-9]{1,2}$/) && !value.match(/^inherit$/i))
+ return _('Invalid value');
+
+ return true;
+ };
+
+ o = s.taboption('advanced', form.Flag, 'nohostroute', _("No host route"), _("Do not create host route to peer (optional)."));
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'ikey', _("Incoming key"), _("Key for incoming packets (optional)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ o = s.taboption('advanced', form.Value, 'okey', _("Outgoing key"), _("Key for outgoing packets (optinal)."));
+ o.optional = true;
+ o.datatype = 'integer';
+
+ s.taboption('advanced', form.Flag, 'icsum', _("Incoming checksum"), _("Require incoming checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'ocsum', _("Outgoing checksum"), _("Compute outgoing checksum (optional)."));
+ s.taboption('advanced', form.Flag, 'iseqno', _("Incoming serialization"), _("Require incoming packets serialization (optional)."));
+ s.taboption('advanced', form.Flag, 'oseqno', _("Outgoing serialization"), _("Perform outgoing packets serialization (optional)."));
+
+ }
+});
diff --git a/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js b/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js
index 804c567fac..646e10a948 100644
--- a/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js
+++ b/protocols/luci-proto-modemmanager/htdocs/luci-static/resources/protocol/modemmanager.js
@@ -37,9 +37,15 @@ function getModemList() {
}
network.registerPatternVirtual(/^mobiledata-.+$/);
-network.registerErrorCode('CALL_FAILED', _('Call failed'));
-network.registerErrorCode('NO_CID', _('Unable to obtain client ID'));
-network.registerErrorCode('PLMN_FAILED', _('Setting PLMN failed'));
+network.registerErrorCode('MM_CONNECT_FAILED', _('Connection attempt failed.'));
+network.registerErrorCode('MM_DISCONNECT_IN_PROGRESS', _('Modem disconnection in progress. Please wait.'));
+network.registerErrorCode('MM_CONNECT_IN_PROGRESS', _('Modem connection in progress. Please wait. This process will timeout after 2 minutes.'));
+network.registerErrorCode('MM_TEARDOWN_IN_PROGRESS', _('Modem bearer teardown in progress.'));
+network.registerErrorCode('MM_MODEM_DISABLED', _('Modem is disabled.'));
+network.registerErrorCode('DEVICE_NOT_MANAGED', _('Device not managed by ModemManager.'));
+network.registerErrorCode('INVALID_BEARER_LIST', _('Invalid bearer list. Possibly too many bearers created. This protocol supports one and only one bearer.'));
+network.registerErrorCode('UNKNOWN_METHOD', _('Unknown and unsupported connection method.'));
+network.registerErrorCode('DISCONNECT_FAILED', _('Disconnection attempt failed.'));
return network.registerProtocol('modemmanager', {
getI18n: function() {
diff --git a/protocols/luci-proto-sstp/Makefile b/protocols/luci-proto-sstp/Makefile
new file mode 100644
index 0000000000..afb4e1a379
--- /dev/null
+++ b/protocols/luci-proto-sstp/Makefile
@@ -0,0 +1,15 @@
+#
+# Copyright (C) 2020 Robert Koszewski <rkkoszewski@gmail.com>
+#
+# This is free software, licensed under the Apache License, Version 2.0 .
+#
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=Support for SSTP
+LUCI_DEPENDS:=+sstp-client
+LUCI_PKGARCH:=all
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/protocols/luci-proto-sstp/htdocs/luci-static/resources/protocol/sstp.js b/protocols/luci-proto-sstp/htdocs/luci-static/resources/protocol/sstp.js
new file mode 100644
index 0000000000..55ae2f97e6
--- /dev/null
+++ b/protocols/luci-proto-sstp/htdocs/luci-static/resources/protocol/sstp.js
@@ -0,0 +1,85 @@
+'use strict';
+'require form';
+'require network';
+
+network.registerPatternVirtual(/^sstp-.+$/);
+
+return network.registerProtocol('sstp', {
+ getI18n: function() {
+ return _('SSTP');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'sstp-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'sstp-client';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var dev = this.getL3Device() || this.getDevice(), o;
+
+ // -- general ---------------------------------------------------------------------
+
+ o = s.taboption('general', form.Value, 'server', _('SSTP Server'));
+ o.datatype = 'host';
+
+ o = s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
+
+ o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
+ o.password = true;
+
+ // -- advanced --------------------------------------------------------------------
+
+ o = s.taboption('advanced', form.Flag, 'ipv6', _('IPv6 support'), _('If checked, adds "+ipv6" to the pppd options'));
+
+ o = s.taboption('advanced', form.ListValue, 'log_level', _('sstpc Log-level'));
+ o.value('0', _('0', 'sstp log level value'));
+ o.value('1', _('1', 'sstp log level value'));
+ o.value('2', _('2', 'sstp log level value'));
+ o.value('3', _('3', 'sstp log level value'));
+ o.value('4', _('4', 'sstp log level value'));
+ o.default = '0';
+
+ var defaultroute = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
+ defaultroute.default = defaultroute.enabled;
+
+ o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
+ o.placeholder = '0';
+ o.datatype = 'uinteger';
+ o.depends('defaultroute', defaultroute.enabled);
+
+ o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
+ o.default = o.enabled;
+
+ o = s.taboption('advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
+ o.depends('peerdns', '0');
+ o.datatype = 'ipaddr';
+ o.cast = 'string';
+
+ o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
+ o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
+ o.datatype = 'max(9200)';
+
+ o = s.taboption('advanced', form.Value, 'sstp_options', _('Extra sstpc options'), _('e.g: --proxy 10.10.10.10'));
+
+ o = s.taboption('advanced', form.Value, 'pppd_options', _('Extra pppd options'), _('e.g: dump'));
+ }
+});
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 e88c07c339..4690ecfc7f 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,8 +1,16 @@
'use strict';
+'require ui';
'require uci';
+'require rpc';
'require form';
'require network';
+var generateKey = rpc.declare({
+ object: 'luci.wireguard',
+ method: 'generateKeyPair',
+ expect: { keys: {} }
+});
+
function validateBase64(section_id, value) {
if (value.length == 0)
return true;
@@ -55,6 +63,18 @@ return network.registerProtocol('wireguard', {
o.validate = validateBase64;
o.rmempty = false;
+ o = s.taboption('general', form.Button, 'generate_key', _('Generate Key'));
+ o.inputstyle = 'apply';
+ o.onclick = ui.createHandlerFn(this, function(section_id, ev) {
+ return generateKey().then(function(keypair) {
+ var keyInput = document.getElementById('widget.cbid.network.%s.private_key'.format(section_id)),
+ changeEvent = new Event('change');
+
+ keyInput.value = keypair.priv || '';
+ keyInput.dispatchEvent(changeEvent);
+ });
+ }, s.section);
+
o = s.taboption('general', form.Value, 'listen_port', _('Listen Port'), _('Optional. UDP port used for outgoing and incoming packets.'));
o.datatype = 'port';
o.placeholder = _('random');
diff --git a/protocols/luci-proto-wireguard/root/usr/libexec/rpcd/luci.wireguard b/protocols/luci-proto-wireguard/root/usr/libexec/rpcd/luci.wireguard
new file mode 100755
index 0000000000..a6c951f3de
--- /dev/null
+++ b/protocols/luci-proto-wireguard/root/usr/libexec/rpcd/luci.wireguard
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+. /usr/share/libubox/jshn.sh
+
+case "$1" in
+ list)
+ json_init
+ json_add_object "generateKeyPair"
+ json_close_object
+ json_dump
+ ;;
+ call)
+ case "$2" in
+ generateKeyPair)
+ prv=$(wg genkey)
+ pub=$(echo $prv | wg pubkey)
+ json_init
+ json_add_object "keys"
+ json_add_string "priv" "$prv"
+ json_add_string "pub" "$pub"
+ json_close_object
+ json_dump
+ ;;
+ esac
+ ;;
+esac
diff --git a/protocols/luci-proto-wireguard/root/usr/share/rpcd/acl.d/luci-wireguard.json b/protocols/luci-proto-wireguard/root/usr/share/rpcd/acl.d/luci-wireguard.json
new file mode 100644
index 0000000000..4bbcb81578
--- /dev/null
+++ b/protocols/luci-proto-wireguard/root/usr/share/rpcd/acl.d/luci-wireguard.json
@@ -0,0 +1,10 @@
+{
+ "luci-proto-wireguard": {
+ "description": "Grant access to LuCI Wireguard procedures",
+ "write": {
+ "ubus": {
+ "luci.wireguard": [ "generateKeyPair" ]
+ }
+ }
+ }
+}