From e7c870ea385b91fcfe28d8e9f6c77dbbf0468518 Mon Sep 17 00:00:00 2001 From: Aaron Goodman Date: Sun, 14 Jun 2020 11:59:15 -0400 Subject: luci-proto-openfortivpn: add luci interface for openfortivpn Signed-off-by: Aaron Goodman --- protocols/luci-proto-openfortivpn/Makefile | 14 ++++ .../luci-static/resources/protocol/openfortivpn.js | 79 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 protocols/luci-proto-openfortivpn/Makefile create mode 100644 protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js diff --git a/protocols/luci-proto-openfortivpn/Makefile b/protocols/luci-proto-openfortivpn/Makefile new file mode 100644 index 0000000000..17a63f78eb --- /dev/null +++ b/protocols/luci-proto-openfortivpn/Makefile @@ -0,0 +1,14 @@ +# +# Copyright (C) 2008-2020 The LuCI Team +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=Support for OpenFortivpn +LUCI_DEPENDS:=+openfortivpn + +include ../../luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js b/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js new file mode 100644 index 0000000000..d8e3c50aa3 --- /dev/null +++ b/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js @@ -0,0 +1,79 @@ +'use strict'; +'require rpc'; +'require form'; +'require network'; +'require tools.widgets as widgets'; + +network.registerPatternVirtual(/^vpn-.+$/); + + +return network.registerProtocol('openfortivpn', { + getI18n: function() { + return _('OpenFortivpn'); + }, + + getIfname: function() { + return this._ubus('l3_device') || 'vpn-%s'.format(this.sid); + }, + + getOpkgPackage: function() { + return 'openfortivpn'; + }, + + 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; + + o = s.taboption('general', form.Value, 'server', _('VPN Server')); + o.datatype = 'host(0)'; + + o = s.taboption('general', form.Value, 'port', _('VPN Server port')); + o.placeholder = '443'; + o.datatype = 'port'; + o.optional = true; + + s.taboption("general", form.Value, "username", _("Username")); + + o = s.taboption('general', form.Value, 'password', _('Password')); + o.password = true; + + o = s.taboption('advanced', widgets.NetworkSelect, 'iface_name', _('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, 'trusted_cert', _("VPN Server's certificate SHA1 hash")); + o.datatype = 'and(hexstring,length(64))' + o.optional = true; + + o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS server provided by VPN')); + o.default = o.enabled; + o.optional = true; + + o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric')); + o.placeholder = '0'; + o.datatype = 'uinteger'; + o.optional = true; + + o = s.taboption("advanced", form.Value, 'local_ip', _("Local IP address")); + o.placeholder = '192.168.0.5' + o.dataype = 'ipaddr' + o.optional = true; + + } +}); -- cgit v1.2.3 From 3e480874ff85bb7728c8314f0df0b3ac0d34fecd Mon Sep 17 00:00:00 2001 From: Aaron Goodman Date: Wed, 29 Jul 2020 00:43:05 -0400 Subject: luci-proto-openfortivpn: add default route, remove disabled, update text Signed-off-by: Aaron Goodman --- .../htdocs/luci-static/resources/protocol/openfortivpn.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js b/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js index d8e3c50aa3..b1c7c229f0 100644 --- a/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js +++ b/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js @@ -61,7 +61,11 @@ return network.registerProtocol('openfortivpn', { o.datatype = 'and(hexstring,length(64))' o.optional = true; - o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS server provided by VPN')); + o = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured')); + o.default = o.enabled; + o.optional = true; + + 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.optional = true; -- cgit v1.2.3 From 642f738ead202c1f82bf3a5712cac09444cbd77f Mon Sep 17 00:00:00 2001 From: Aaron Goodman Date: Wed, 26 Aug 2020 21:54:06 -0400 Subject: luci-proto-openfortivpn: update config option names update config option names for openfortivpn version 1.14-1-8 Signed-off-by: Aaron Goodman --- .../htdocs/luci-static/resources/protocol/openfortivpn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js b/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js index b1c7c229f0..d0e6bdb011 100644 --- a/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js +++ b/protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js @@ -39,7 +39,7 @@ return network.registerProtocol('openfortivpn', { renderFormOptions: function(s) { var o; - o = s.taboption('general', form.Value, 'server', _('VPN Server')); + o = s.taboption('general', form.Value, 'peeraddr', _('VPN Server')); o.datatype = 'host(0)'; o = s.taboption('general', form.Value, 'port', _('VPN Server port')); @@ -52,7 +52,7 @@ return network.registerProtocol('openfortivpn', { o = s.taboption('general', form.Value, 'password', _('Password')); o.password = true; - o = s.taboption('advanced', widgets.NetworkSelect, 'iface_name', _('Bind interface'), _('Bind the tunnel to this interface (optional).')); + 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; -- cgit v1.2.3